mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-15 16:41:22 +00:00
cd_sdl.c: Reverted the CDAudio_Update() change from 27 Oct: it does
not make things better. Removed the SDL_CDStatus() check before the error message in case of SDL_CDPlay() failures: I don't really know the significance to it and witnessed that it caused the error report once, so I don't see any merit in its presence. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@500 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
fd39405580
commit
3246601197
1 changed files with 24 additions and 8 deletions
|
@ -45,6 +45,7 @@ static qboolean enabled = true;
|
|||
static qboolean playLooping = false;
|
||||
static byte remap[100];
|
||||
static byte playTrack;
|
||||
static double endOfTrack = -1.0, pausetime = -1.0;
|
||||
static SDL_CD *cd_handle;
|
||||
static int cd_dev = -1;
|
||||
static float old_cdvolume;
|
||||
|
@ -77,6 +78,8 @@ static int CDAudio_GetAudioDiskInfo(void)
|
|||
|
||||
int CDAudio_Play(byte track, qboolean looping)
|
||||
{
|
||||
int len_m, len_s, len_f;
|
||||
|
||||
if (!cd_handle || !enabled)
|
||||
return -1;
|
||||
|
||||
|
@ -110,9 +113,7 @@ int CDAudio_Play(byte track, qboolean looping)
|
|||
|
||||
if (SDL_CDPlay(cd_handle, cd_handle->track[track-1].offset, cd_handle->track[track-1].length) == -1)
|
||||
{
|
||||
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 ("CDAudio_Play: Unable to play track %d: %s\n", track, SDL_GetError ());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -120,6 +121,16 @@ int CDAudio_Play(byte track, qboolean looping)
|
|||
playTrack = track;
|
||||
playing = true;
|
||||
|
||||
FRAMES_TO_MSF(cd_handle->track[track-1].length, &len_m, &len_s, &len_f);
|
||||
endOfTrack = realtime + ((double)len_m * 60.0) + (double)len_s + (double)len_f / (double)CD_FPS;
|
||||
|
||||
/* Add the pregap for the next track. This means that disc-at-once CDs
|
||||
* won't loop smoothly, but they wouldn't anyway so it doesn't really
|
||||
* matter. SDL doesn't give us pregap information anyway, so you'll
|
||||
* just have to live with it. */
|
||||
endOfTrack += 2.0;
|
||||
pausetime = -1.0;
|
||||
|
||||
if (bgmvolume.value == 0) /* don't bother advancing */
|
||||
CDAudio_Pause ();
|
||||
|
||||
|
@ -139,6 +150,8 @@ void CDAudio_Stop(void)
|
|||
|
||||
wasPlaying = false;
|
||||
playing = false;
|
||||
pausetime = -1.0;
|
||||
endOfTrack = -1.0;
|
||||
}
|
||||
|
||||
void CDAudio_Pause(void)
|
||||
|
@ -154,6 +167,7 @@ void CDAudio_Pause(void)
|
|||
|
||||
wasPlaying = playing;
|
||||
playing = false;
|
||||
pausetime = realtime;
|
||||
}
|
||||
|
||||
void CDAudio_Resume(void)
|
||||
|
@ -170,6 +184,8 @@ void CDAudio_Resume(void)
|
|||
if (SDL_CDResume(cd_handle) == -1)
|
||||
Con_Printf ("Unable to resume CD-ROM: %s\n", SDL_GetError());
|
||||
playing = true;
|
||||
endOfTrack += realtime - pausetime;
|
||||
pausetime = -1.0;
|
||||
}
|
||||
|
||||
static void CD_f (void)
|
||||
|
@ -346,8 +362,7 @@ static qboolean CDAudio_SetVolume (float value)
|
|||
void CDAudio_Update(void)
|
||||
{
|
||||
CDstatus curstat;
|
||||
Uint32 timechk;
|
||||
static Uint32 lastchk;
|
||||
/* static double lastchk;*/
|
||||
|
||||
if (!cd_handle || !enabled)
|
||||
return;
|
||||
|
@ -355,14 +370,15 @@ void CDAudio_Update(void)
|
|||
if (old_cdvolume != bgmvolume.value)
|
||||
CDAudio_SetVolume (bgmvolume.value);
|
||||
|
||||
timechk = SDL_GetTicks ();
|
||||
if (playing && lastchk < timechk)
|
||||
/* if (playing && realtime > lastchk)*/
|
||||
if (playing && realtime > endOfTrack)
|
||||
{
|
||||
lastchk = timechk + 2000; /* two seconds between chks */
|
||||
/* lastchk = realtime + 2;*/ /* two seconds between chks */
|
||||
curstat = SDL_CDStatus(cd_handle);
|
||||
if (curstat != CD_PLAYING && curstat != CD_PAUSED)
|
||||
{
|
||||
playing = false;
|
||||
endOfTrack = -1.0;
|
||||
if (playLooping)
|
||||
CDAudio_Play(playTrack, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue