mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-10 20:11:42 +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://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@500 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
b774adc6df
commit
199cc406ed
1 changed files with 24 additions and 8 deletions
|
@ -45,6 +45,7 @@ static qboolean enabled = true;
|
||||||
static qboolean playLooping = false;
|
static qboolean playLooping = false;
|
||||||
static byte remap[100];
|
static byte remap[100];
|
||||||
static byte playTrack;
|
static byte playTrack;
|
||||||
|
static double endOfTrack = -1.0, pausetime = -1.0;
|
||||||
static SDL_CD *cd_handle;
|
static SDL_CD *cd_handle;
|
||||||
static int cd_dev = -1;
|
static int cd_dev = -1;
|
||||||
static float old_cdvolume;
|
static float old_cdvolume;
|
||||||
|
@ -77,6 +78,8 @@ static int CDAudio_GetAudioDiskInfo(void)
|
||||||
|
|
||||||
int CDAudio_Play(byte track, qboolean looping)
|
int CDAudio_Play(byte track, qboolean looping)
|
||||||
{
|
{
|
||||||
|
int len_m, len_s, len_f;
|
||||||
|
|
||||||
if (!cd_handle || !enabled)
|
if (!cd_handle || !enabled)
|
||||||
return -1;
|
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)
|
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);
|
Con_Printf ("CDAudio_Play: Unable to play track %d: %s\n", track, SDL_GetError ());
|
||||||
if (cd_status > 0)
|
|
||||||
Con_Printf ("CDAudio_Play: Unable to play %d: %s\n", track, SDL_GetError ());
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +121,16 @@ int CDAudio_Play(byte track, qboolean looping)
|
||||||
playTrack = track;
|
playTrack = track;
|
||||||
playing = true;
|
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 */
|
if (bgmvolume.value == 0) /* don't bother advancing */
|
||||||
CDAudio_Pause ();
|
CDAudio_Pause ();
|
||||||
|
|
||||||
|
@ -139,6 +150,8 @@ void CDAudio_Stop(void)
|
||||||
|
|
||||||
wasPlaying = false;
|
wasPlaying = false;
|
||||||
playing = false;
|
playing = false;
|
||||||
|
pausetime = -1.0;
|
||||||
|
endOfTrack = -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDAudio_Pause(void)
|
void CDAudio_Pause(void)
|
||||||
|
@ -154,6 +167,7 @@ void CDAudio_Pause(void)
|
||||||
|
|
||||||
wasPlaying = playing;
|
wasPlaying = playing;
|
||||||
playing = false;
|
playing = false;
|
||||||
|
pausetime = realtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDAudio_Resume(void)
|
void CDAudio_Resume(void)
|
||||||
|
@ -170,6 +184,8 @@ void CDAudio_Resume(void)
|
||||||
if (SDL_CDResume(cd_handle) == -1)
|
if (SDL_CDResume(cd_handle) == -1)
|
||||||
Con_Printf ("Unable to resume CD-ROM: %s\n", SDL_GetError());
|
Con_Printf ("Unable to resume CD-ROM: %s\n", SDL_GetError());
|
||||||
playing = true;
|
playing = true;
|
||||||
|
endOfTrack += realtime - pausetime;
|
||||||
|
pausetime = -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CD_f (void)
|
static void CD_f (void)
|
||||||
|
@ -346,8 +362,7 @@ static qboolean CDAudio_SetVolume (float value)
|
||||||
void CDAudio_Update(void)
|
void CDAudio_Update(void)
|
||||||
{
|
{
|
||||||
CDstatus curstat;
|
CDstatus curstat;
|
||||||
Uint32 timechk;
|
/* static double lastchk;*/
|
||||||
static Uint32 lastchk;
|
|
||||||
|
|
||||||
if (!cd_handle || !enabled)
|
if (!cd_handle || !enabled)
|
||||||
return;
|
return;
|
||||||
|
@ -355,14 +370,15 @@ void CDAudio_Update(void)
|
||||||
if (old_cdvolume != bgmvolume.value)
|
if (old_cdvolume != bgmvolume.value)
|
||||||
CDAudio_SetVolume (bgmvolume.value);
|
CDAudio_SetVolume (bgmvolume.value);
|
||||||
|
|
||||||
timechk = SDL_GetTicks ();
|
/* if (playing && realtime > lastchk)*/
|
||||||
if (playing && lastchk < timechk)
|
if (playing && realtime > endOfTrack)
|
||||||
{
|
{
|
||||||
lastchk = timechk + 2000; /* two seconds between chks */
|
/* lastchk = realtime + 2;*/ /* two seconds between chks */
|
||||||
curstat = SDL_CDStatus(cd_handle);
|
curstat = SDL_CDStatus(cd_handle);
|
||||||
if (curstat != CD_PLAYING && curstat != CD_PAUSED)
|
if (curstat != CD_PLAYING && curstat != CD_PAUSED)
|
||||||
{
|
{
|
||||||
playing = false;
|
playing = false;
|
||||||
|
endOfTrack = -1.0;
|
||||||
if (playLooping)
|
if (playLooping)
|
||||||
CDAudio_Play(playTrack, true);
|
CDAudio_Play(playTrack, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue