mirror of
https://git.code.sf.net/p/quake/quake2forge
synced 2024-11-10 07:12:01 +00:00
- Applied patch from icculus.org CVS for supporting shuffle
on CDs with 100+ tracks
This commit is contained in:
parent
db5b1a5164
commit
27349bfd44
3 changed files with 39 additions and 13 deletions
16
src/cd.c
16
src/cd.c
|
@ -258,7 +258,7 @@ void CDAudio_RandomPlay(void)
|
|||
{
|
||||
int track, i = 0, free_tracks = 0, remap_track;
|
||||
float f;
|
||||
unsigned char track_bools[100];
|
||||
unsigned char * track_bools;
|
||||
struct cdrom_tocentry entry;
|
||||
struct cdrom_ti ti;
|
||||
|
||||
|
@ -267,6 +267,11 @@ void CDAudio_RandomPlay(void)
|
|||
|
||||
// create array of available audio tracknumbers
|
||||
|
||||
track_bools = (unsigned char *) malloc(maxTrack * sizeof(unsigned char));
|
||||
|
||||
if (track_bools == 0)
|
||||
return;
|
||||
|
||||
for (; i < maxTrack; i++)
|
||||
{
|
||||
entry.cdte_track = remap[i];
|
||||
|
@ -284,7 +289,7 @@ void CDAudio_RandomPlay(void)
|
|||
if (!free_tracks)
|
||||
{
|
||||
Com_DPrintf("CDAudio_RandomPlay: Unable to find and play a random audio track, insert an audio cd please");
|
||||
return;
|
||||
goto free_end;
|
||||
}
|
||||
|
||||
// choose random audio track
|
||||
|
@ -302,7 +307,7 @@ void CDAudio_RandomPlay(void)
|
|||
if (playing)
|
||||
{
|
||||
if (playTrack == remap_track)
|
||||
return;
|
||||
goto free_end;
|
||||
CDAudio_Stop();
|
||||
}
|
||||
|
||||
|
@ -321,10 +326,13 @@ void CDAudio_RandomPlay(void)
|
|||
playLooping = true;
|
||||
playTrack = remap_track;
|
||||
playing = true;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (free_tracks > 0);
|
||||
|
||||
free_end:
|
||||
free(track_bools);
|
||||
}
|
||||
#else /* let the others compile at least */
|
||||
void CDAudio_RandomPlay(void) {
|
||||
|
|
18
src/cd_sdl.c
18
src/cd_sdl.c
|
@ -94,13 +94,18 @@ void CDAudio_RandomPlay(void)
|
|||
int track, i = 0, free_tracks = 0;
|
||||
float f;
|
||||
CDstatus cd_stat;
|
||||
unsigned char track_bools[100];
|
||||
unsigned char * track_bools;
|
||||
|
||||
if (!cd_id || !enabled)
|
||||
return;
|
||||
|
||||
//create array of available audio tracknumbers
|
||||
|
||||
track_bools = (unsigned char *) malloc(cd_id->numtracks * sizeof(byte));
|
||||
|
||||
if (track_bools == 0)
|
||||
return;
|
||||
|
||||
for (; i < cd_id->numtracks; i++)
|
||||
{
|
||||
track_bools[i] = cd_id->track[i].type == SDL_AUDIO_TRACK;
|
||||
|
@ -110,7 +115,7 @@ void CDAudio_RandomPlay(void)
|
|||
if (!free_tracks)
|
||||
{
|
||||
Com_DPrintf("CDAudio_RandomPlay: Unable to find and play a random audio track, insert an audio cd please");
|
||||
return;
|
||||
goto free_end;
|
||||
}
|
||||
|
||||
//choose random audio track
|
||||
|
@ -130,14 +135,14 @@ void CDAudio_RandomPlay(void)
|
|||
if(!cdValid)
|
||||
{
|
||||
if(!CD_INDRIVE(cd_stat) ||(!cd_id->numtracks))
|
||||
return;
|
||||
goto free_end;
|
||||
cdValid = true;
|
||||
}
|
||||
|
||||
if(cd_stat == CD_PLAYING)
|
||||
{
|
||||
if(cd_id->cur_track == track + 1)
|
||||
return;
|
||||
goto free_end;
|
||||
CDAudio_Stop();
|
||||
}
|
||||
|
||||
|
@ -150,10 +155,13 @@ void CDAudio_RandomPlay(void)
|
|||
else
|
||||
{
|
||||
playLooping = true;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (free_tracks > 0);
|
||||
|
||||
free_end:
|
||||
free(track_bools);
|
||||
}
|
||||
|
||||
void CDAudio_Stop()
|
||||
|
|
|
@ -190,7 +190,7 @@ void CDAudio_RandomPlay(void)
|
|||
{
|
||||
int track, i = 0, free_tracks = 0, remap_track;
|
||||
float f;
|
||||
unsigned char track_bools[100];
|
||||
unsigned char * track_bools;
|
||||
DWORD dwReturn;
|
||||
MCI_PLAY_PARMS mciPlayParms;
|
||||
MCI_STATUS_PARMS mciStatusParms;
|
||||
|
@ -199,6 +199,12 @@ void CDAudio_RandomPlay(void)
|
|||
return;
|
||||
|
||||
//create array of available audio tracknumbers
|
||||
|
||||
track_bools = (unsigned char *) malloc(maxTrack * sizeof(unsigned char));
|
||||
|
||||
if (track_bools == 0)
|
||||
return;
|
||||
|
||||
for (; i < maxTrack; i++)
|
||||
{
|
||||
// don't try to play a non-audio track
|
||||
|
@ -218,7 +224,7 @@ void CDAudio_RandomPlay(void)
|
|||
if (!free_tracks)
|
||||
{
|
||||
Com_DPrintf("CDAudio_RandomPlay: Unable to find and play a random audio track, insert an audio cd please");
|
||||
return;
|
||||
goto free_end;
|
||||
}
|
||||
|
||||
//choose random audio track
|
||||
|
@ -240,13 +246,13 @@ void CDAudio_RandomPlay(void)
|
|||
if (dwReturn)
|
||||
{
|
||||
Com_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
|
||||
return;
|
||||
goto free_end;
|
||||
}
|
||||
|
||||
if (playing)
|
||||
{
|
||||
if (playTrack == remap_track)
|
||||
return;
|
||||
goto free_end;
|
||||
CDAudio_Stop();
|
||||
}
|
||||
|
||||
|
@ -264,9 +270,13 @@ void CDAudio_RandomPlay(void)
|
|||
playLooping = true;
|
||||
playTrack = remap_track;
|
||||
playing = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (free_tracks > 0);
|
||||
|
||||
free_end:
|
||||
free(track_bools);
|
||||
}
|
||||
|
||||
void CDAudio_Stop(void)
|
||||
|
|
Loading…
Reference in a new issue