mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-04-13 13:43:27 +00:00
get the fallback to CD hardware working
This commit is contained in:
parent
0f8f8381d0
commit
35f0014502
6 changed files with 69 additions and 70 deletions
|
@ -102,7 +102,6 @@
|
|||
48FA25B712437EAB00667668 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 48FA25B612437EAB00667668 /* dsa_pub.pem */; };
|
||||
48FE585B0D3A82C8006BB491 /* QuakeArguments.m in Sources */ = {isa = PBXBuildFile; fileRef = 48FE585A0D3A82C8006BB491 /* QuakeArguments.m */; };
|
||||
66A5467212E3AF2300FFA7D5 /* cd_shared.c in Sources */ = {isa = PBXBuildFile; fileRef = 66A5467012E3AF2300FFA7D5 /* cd_shared.c */; };
|
||||
66A5467312E3AF2300FFA7D5 /* cd_ogg.c in Sources */ = {isa = PBXBuildFile; fileRef = 66A5467112E3AF2300FFA7D5 /* cd_ogg.c */; };
|
||||
66A5470D12E3CF8100FFA7D5 /* snd_codec.c in Sources */ = {isa = PBXBuildFile; fileRef = 66A5470A12E3CF8100FFA7D5 /* snd_codec.c */; };
|
||||
66A5470E12E3CF8100FFA7D5 /* snd_codec_wav.c in Sources */ = {isa = PBXBuildFile; fileRef = 66A5470B12E3CF8100FFA7D5 /* snd_codec_wav.c */; };
|
||||
66A5470F12E3CF8100FFA7D5 /* snd_codec_ogg.c in Sources */ = {isa = PBXBuildFile; fileRef = 66A5470C12E3CF8100FFA7D5 /* snd_codec_ogg.c */; };
|
||||
|
@ -283,7 +282,6 @@
|
|||
48FE58590D3A82C8006BB491 /* QuakeArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuakeArguments.h; sourceTree = "<group>"; };
|
||||
48FE585A0D3A82C8006BB491 /* QuakeArguments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuakeArguments.m; sourceTree = "<group>"; };
|
||||
66A5467012E3AF2300FFA7D5 /* cd_shared.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cd_shared.c; path = ../Quake/cd_shared.c; sourceTree = SOURCE_ROOT; };
|
||||
66A5467112E3AF2300FFA7D5 /* cd_ogg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cd_ogg.c; path = ../Quake/cd_ogg.c; sourceTree = SOURCE_ROOT; };
|
||||
66A5470912E3CF6B00FFA7D5 /* snd_codec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = snd_codec.h; path = ../Quake/snd_codec.h; sourceTree = SOURCE_ROOT; };
|
||||
66A5470A12E3CF8100FFA7D5 /* snd_codec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = snd_codec.c; path = ../Quake/snd_codec.c; sourceTree = SOURCE_ROOT; };
|
||||
66A5470B12E3CF8100FFA7D5 /* snd_codec_wav.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = snd_codec_wav.c; path = ../Quake/snd_codec_wav.c; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -492,7 +490,6 @@
|
|||
483A77E10D2EE91000CB2E4C /* Headers */,
|
||||
483A78500D2EEAC300CB2E4C /* cd_sdl.c */,
|
||||
66A5467012E3AF2300FFA7D5 /* cd_shared.c */,
|
||||
66A5467112E3AF2300FFA7D5 /* cd_ogg.c */,
|
||||
486577C80D31A22A00E7920A /* snd_dma.c */,
|
||||
486577C90D31A22A00E7920A /* snd_mem.c */,
|
||||
486577CA0D31A22A00E7920A /* snd_mix.c */,
|
||||
|
@ -774,7 +771,6 @@
|
|||
48134A1812102F400015BF15 /* net_bsd.c in Sources */,
|
||||
48134A1912102F400015BF15 /* net_udp.c in Sources */,
|
||||
66A5467212E3AF2300FFA7D5 /* cd_shared.c in Sources */,
|
||||
66A5467312E3AF2300FFA7D5 /* cd_ogg.c in Sources */,
|
||||
66A5470D12E3CF8100FFA7D5 /* snd_codec.c in Sources */,
|
||||
66A5470E12E3CF8100FFA7D5 /* snd_codec_wav.c in Sources */,
|
||||
66A5470F12E3CF8100FFA7D5 /* snd_codec_ogg.c in Sources */,
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
static qboolean enabled = false;
|
||||
static qboolean cdValid = false;
|
||||
static qboolean playing = false;
|
||||
static qboolean wasPlaying = false;
|
||||
|
@ -73,6 +74,11 @@ static int CDAudioBackend_GetAudioDiskInfo(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
qboolean CDAudioBackend_IsPlaying()
|
||||
{
|
||||
return playing;
|
||||
}
|
||||
|
||||
void CDAudioBackend_Play(byte track, qboolean looping)
|
||||
{
|
||||
int len_m, len_s, len_f;
|
||||
|
@ -87,17 +93,15 @@ void CDAudioBackend_Play(byte track, qboolean looping)
|
|||
return;
|
||||
}
|
||||
|
||||
track = remap[track];
|
||||
|
||||
if (track < 1 || track > cd_handle->numtracks)
|
||||
{
|
||||
Con_Printf ("CDAudio_Play: Bad track number %d.\n", track);
|
||||
Con_Printf ("CDAudioBackend_Play: Bad track number %d.\n", track);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cd_handle->track[track-1].type == SDL_DATA_TRACK)
|
||||
{
|
||||
Con_Printf ("CDAudio_Play: track %d is not audio\n", track);
|
||||
Con_Printf ("CDAudioBackend_Play: track %d is not audio\n", track);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,7 +118,7 @@ void CDAudioBackend_Play(byte track, qboolean looping)
|
|||
int cd_status = SDL_CDStatus(cd_handle);
|
||||
|
||||
if (cd_status > 0)
|
||||
Con_Printf ("CDAudio_Play: Unable to play %d: %s\n", track, SDL_GetError ());
|
||||
Con_Printf ("CDAudioBackend_Play: Unable to play %d: %s\n", track, SDL_GetError ());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -135,7 +139,7 @@ void CDAudioBackend_Play(byte track, qboolean looping)
|
|||
pausetime = -1.0;
|
||||
|
||||
if (!hw_vol_works && bgmvolume.value == 0.0)
|
||||
CDAudio_Pause ();
|
||||
CDAudioBackend_Pause ();
|
||||
}
|
||||
|
||||
void CDAudioBackend_Stop(void)
|
||||
|
@ -147,7 +151,7 @@ void CDAudioBackend_Stop(void)
|
|||
return;
|
||||
|
||||
if (SDL_CDStop(cd_handle) == -1)
|
||||
Con_Printf ("CDAudio_Stop: Unable to stop CD-ROM (%s)\n", SDL_GetError());
|
||||
Con_Printf ("CDAudioBackend_Stop: Unable to stop CD-ROM (%s)\n", SDL_GetError());
|
||||
|
||||
wasPlaying = false;
|
||||
playing = false;
|
||||
|
@ -169,7 +173,7 @@ void CDAudioBackend_Next(void)
|
|||
if (track > cd_handle->numtracks)
|
||||
track = 1;
|
||||
|
||||
CDAudio_Play (track, playLooping);
|
||||
CDAudioBackend_Play (track, playLooping);
|
||||
}
|
||||
|
||||
void CDAudioBackend_Prev(void)
|
||||
|
@ -186,7 +190,7 @@ void CDAudioBackend_Prev(void)
|
|||
if (track < 1)
|
||||
track = cd_handle->numtracks;
|
||||
|
||||
CDAudio_Play (track, playLooping);
|
||||
CDAudioBackend_Play (track, playLooping);
|
||||
}
|
||||
|
||||
void CDAudioBackend_Pause(void)
|
||||
|
@ -225,31 +229,29 @@ void CDAudioBackend_Resume(void)
|
|||
|
||||
void CDAudioBackend_Info()
|
||||
{
|
||||
int current_min, current_sec, current_frame;
|
||||
int length_min, length_sec, length_frame;
|
||||
int current_min, current_sec, current_frame;
|
||||
int length_min, length_sec, length_frame;
|
||||
|
||||
Con_Printf ("%u tracks\n", cd_handle->numtracks);
|
||||
Con_Printf ("%u tracks\n", cd_handle->numtracks);
|
||||
|
||||
if (playing)
|
||||
Con_Printf ("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack);
|
||||
else if (wasPlaying)
|
||||
Con_Printf ("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack);
|
||||
if (playing)
|
||||
Con_Printf ("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack);
|
||||
else if (wasPlaying)
|
||||
Con_Printf ("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack);
|
||||
|
||||
if (playing || wasPlaying)
|
||||
{
|
||||
SDL_CDStatus(cd_handle);
|
||||
FRAMES_TO_MSF(cd_handle->cur_frame, ¤t_min, ¤t_sec, ¤t_frame);
|
||||
FRAMES_TO_MSF(cd_handle->track[playTrack-1].length, &length_min, &length_sec, &length_frame);
|
||||
if (playing || wasPlaying)
|
||||
{
|
||||
SDL_CDStatus(cd_handle);
|
||||
FRAMES_TO_MSF(cd_handle->cur_frame, ¤t_min, ¤t_sec, ¤t_frame);
|
||||
FRAMES_TO_MSF(cd_handle->track[playTrack-1].length, &length_min, &length_sec, &length_frame);
|
||||
|
||||
Con_Printf ("Current position: %d:%02d.%02d (of %d:%02d.%02d)\n",
|
||||
current_min, current_sec, current_frame * 60 / CD_FPS,
|
||||
length_min, length_sec, length_frame * 60 / CD_FPS);
|
||||
}
|
||||
Con_Printf ("Volume is %f\n", bgmvolume.value);
|
||||
|
||||
return;
|
||||
Con_Printf ("Current position: %d:%02d.%02d (of %d:%02d.%02d)\n",
|
||||
current_min, current_sec, current_frame * 60 / CD_FPS,
|
||||
length_min, length_sec, length_frame * 60 / CD_FPS);
|
||||
}
|
||||
Con_Printf ("cd: no such command. Use \"cd\" for help.\n");
|
||||
Con_Printf ("Volume is %f\n", bgmvolume.value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static qboolean CD_GetVolume (void *unused)
|
||||
|
@ -285,9 +287,9 @@ static qboolean CDAudioBackend_SetVolume (cvar_t *var)
|
|||
else
|
||||
{
|
||||
if (old_cdvolume == 0.0)
|
||||
CDAudio_Pause ();
|
||||
CDAudioBackend_Pause ();
|
||||
else
|
||||
CDAudio_Resume();
|
||||
CDAudioBackend_Resume();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +302,7 @@ void CDAudioBackend_Update(void)
|
|||
return;
|
||||
|
||||
if (old_cdvolume != bgmvolume.value)
|
||||
CDAudio_SetVolume (&bgmvolume);
|
||||
CDAudioBackend_SetVolume (&bgmvolume);
|
||||
|
||||
if (playing && realtime > endOfTrack)
|
||||
{
|
||||
|
@ -311,10 +313,10 @@ void CDAudioBackend_Update(void)
|
|||
endOfTrack = -1.0;
|
||||
if (playLooping) {
|
||||
playing = false;
|
||||
CDAudio_Play(playTrack, true);
|
||||
CDAudioBackend_Play(playTrack, true);
|
||||
}
|
||||
else
|
||||
CDAudio_Next();
|
||||
CDAudioBackend_Next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -431,30 +433,26 @@ int CDAudioBackend_Init(void)
|
|||
cd_handle = SDL_CDOpen(cd_dev);
|
||||
if (!cd_handle)
|
||||
{
|
||||
Con_Printf ("CDAudio_Init: Unable to open CD-ROM drive %s (%s)\n",
|
||||
Con_Printf ("CDAudioBackend_Init: Unable to open CD-ROM drive %s (%s)\n",
|
||||
SDL_CDName(cd_dev), SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
remap[i] = i;
|
||||
enabled = true;
|
||||
old_cdvolume = bgmvolume.value;
|
||||
|
||||
Con_Printf("CDAudio initialized (SDL, using %s)\n", SDL_CDName(cd_dev));
|
||||
|
||||
if (CDAudio_GetAudioDiskInfo())
|
||||
if (CDAudioBackend_GetAudioDiskInfo())
|
||||
{
|
||||
Con_Printf("CDAudio_Init: No CD in drive\n");
|
||||
Con_Printf("CDAudioBackend_Init: No CD in drive\n");
|
||||
cdValid = false;
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("cd", CD_f);
|
||||
|
||||
// cd hardware volume: no SDL support at present.
|
||||
hw_vol_works = CD_GetVolume (NULL);
|
||||
if (hw_vol_works)
|
||||
hw_vol_works = CDAudio_SetVolume (&bgmvolume);
|
||||
hw_vol_works = CDAudioBackend_SetVolume (&bgmvolume);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -54,12 +54,6 @@ static void CDAudio_FinishedCallback(void *userdata)
|
|||
static qboolean CDAudio_TryPlayNamed(const char *name, qboolean looping)
|
||||
{
|
||||
qboolean success = S_Base_StartBackgroundTrack(name, looping, CDAudio_FinishedCallback, NULL);
|
||||
if (success)
|
||||
{
|
||||
playLooping = looping;
|
||||
playing = true;
|
||||
sprintf(playTrackName, "%s", name);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -69,11 +63,14 @@ void CDAudio_PlayNamed(const char *name, qboolean looping)
|
|||
return;
|
||||
|
||||
// already playing the correct track?
|
||||
if (playing && (0 == strcmp(name, playTrackName)))
|
||||
if ((0 == strcmp(name, playTrackName)) &&
|
||||
(S_BackgroundTrackIsPlaying() || (usingBackend && CDAudioBackend_IsPlaying())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CDAudio_Stop();
|
||||
|
||||
// copy the track name to playTrackName
|
||||
if (CDAudio_IsNumberedTrack(name))
|
||||
{
|
||||
|
@ -93,22 +90,30 @@ void CDAudio_PlayNamed(const char *name, qboolean looping)
|
|||
sprintf(playTrackName, "%s", name);
|
||||
}
|
||||
|
||||
if (playing)
|
||||
{
|
||||
CDAudio_Stop();
|
||||
}
|
||||
|
||||
|
||||
// FIXME: make backend play
|
||||
// First try to play a music file
|
||||
|
||||
char fullTrackName[MAX_QPATH];
|
||||
sprintf(fullTrackName, "music/%s", playTrackName);
|
||||
qboolean success = S_Base_StartBackgroundTrack(fullTrackName, playLooping, CDAudio_FinishedCallback, NULL);
|
||||
if (!success)
|
||||
{
|
||||
Con_Printf("WARNING: Couldn't open music file %s\n", fullTrackName);
|
||||
}
|
||||
|
||||
CDAudio_TryPlayNamed
|
||||
q_snprintf(fullTrackName, sizeof(fullTrackName), "music/%s", playTrackName);
|
||||
if (CDAudio_TryPlayNamed(fullTrackName, looping)) return;
|
||||
|
||||
q_snprintf(fullTrackName, sizeof(fullTrackName), "music/track%s", playTrackName);
|
||||
if (CDAudio_TryPlayNamed(fullTrackName, looping)) return;
|
||||
|
||||
q_snprintf(fullTrackName, sizeof(fullTrackName), "music/t%s", playTrackName);
|
||||
if (CDAudio_TryPlayNamed(fullTrackName, looping)) return;
|
||||
|
||||
Con_Printf("WARNING: Couldn't open music file %s\n", playTrackName);
|
||||
|
||||
if (CDAudio_IsNumberedTrack(playTrackName))
|
||||
{
|
||||
CDAudioBackend_Play(atoi(playTrackName), looping);
|
||||
if (CDAudioBackend_IsPlaying())
|
||||
{
|
||||
usingBackend = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDAudio_Play(byte track, qboolean looping)
|
||||
|
@ -143,7 +148,7 @@ static void CDAudio_Next(void)
|
|||
|
||||
if (usingBackend)
|
||||
{
|
||||
CDAudio_BackendNext();
|
||||
CDAudioBackend_Next();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -168,7 +173,7 @@ static void CDAudio_Prev(void)
|
|||
|
||||
if (usingBackend)
|
||||
{
|
||||
CDAudio_BackendPrev();
|
||||
CDAudioBackend_Prev();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@ void CDAudio_Update(void);
|
|||
|
||||
void CDAudioBackend_Eject(void);
|
||||
void CDAudioBackend_Play(byte track, qboolean looping);
|
||||
qboolean CDAudioBackend_IsPlaying();
|
||||
void CDAudioBackend_Stop(void);
|
||||
void CDAudioBackend_Next(void);
|
||||
void CDAudioBackend_Prev(void);
|
||||
|
|
|
@ -1150,7 +1150,7 @@ qboolean S_BackgroundTrackIsPaused( void )
|
|||
*/
|
||||
qboolean S_BackgroundTrackIsLooping( void )
|
||||
{
|
||||
return s_backgroundLoop;
|
||||
return s_backgroundLoop[0];
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue