X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=cd_shared.c;h=33a5dcc627a52bcede4369fc0791fde6f3e3d161;hb=8216c759ec0c77afe2ff9264a3b35a85248c1fe6;hp=69c2df5263a407cadfa71d8b2fac81a4675d04ae;hpb=bca9ce32c07abac828a3e3a0201946de48a74cdb;p=xonotic%2Fdarkplaces.git diff --git a/cd_shared.c b/cd_shared.c index 69c2df52..33a5dcc6 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "cdaudio.h" #include "sound.h" -#define MAXTRACKS 256 - // Prototypes of the system dependent functions extern void CDAudio_SysEject (void); extern void CDAudio_SysCloseDoor (void); @@ -50,7 +48,9 @@ static qboolean initialized = false; static qboolean enabled = false; static float cdvolume; typedef char filename_t[MAX_QPATH]; +#ifdef MAXTRACKS static filename_t remap[MAXTRACKS]; +#endif static unsigned char maxTrack; static int faketrack = -1; @@ -121,7 +121,7 @@ qboolean CDAudio_Play_real (int track, qboolean looping, qboolean complain) if (!cdValid) { if(complain) - Con_Print ("No CD in player.\n"); + Con_DPrint ("No CD in player.\n"); return false; } } @@ -129,15 +129,15 @@ qboolean CDAudio_Play_real (int track, qboolean looping, qboolean complain) if (track > maxTrack) { if(complain) - Con_Printf("CDAudio: Bad track number %u.\n", track); + Con_DPrintf("CDAudio: Bad track number %u.\n", track); return false; } if (CDAudio_SysPlay(track) == -1) return false; - if(cdaudio.integer != 3 || developer.integer) - Con_Printf ("CD track %u playing...\n", track); + if(cdaudio.integer != 3) + Con_DPrintf ("CD track %u playing...\n", track); return true; } @@ -156,6 +156,7 @@ void CDAudio_Play_byName (const char *trackname, qboolean looping) if(strspn(trackname, "0123456789") == strlen(trackname)) { track = (unsigned char) atoi(trackname); +#ifdef MAXTRACKS if(track > 0 && track < MAXTRACKS) if(*remap[track]) { @@ -183,6 +184,7 @@ void CDAudio_Play_byName (const char *trackname, qboolean looping) } } } +#endif } if(strspn(trackname, "0123456789") == strlen(trackname)) @@ -190,7 +192,7 @@ void CDAudio_Play_byName (const char *trackname, qboolean looping) track = (unsigned char) atoi(trackname); if (track < 1) { - Con_Printf("CDAudio: Bad track number %u.\n", track); + Con_DPrintf("CDAudio: Bad track number %u.\n", track); return; } } @@ -231,7 +233,7 @@ void CDAudio_Play_byName (const char *trackname, qboolean looping) } else { - Con_Print ("No CD in player.\n"); + Con_DPrint ("No CD in player.\n"); } return; } @@ -267,8 +269,8 @@ void CDAudio_Play_byName (const char *trackname, qboolean looping) S_SetChannelFlag (faketrack, CHANNELFLAG_LOCALSOUND, true); // not pausable if(track >= 1) { - if(cdaudio.integer != 0 || developer.integer) // we don't need these messages if only fake tracks can be played anyway - Con_Printf ("Fake CD track %u playing...\n", track); + if(cdaudio.integer != 0) // we don't need these messages if only fake tracks can be played anyway + Con_DPrintf ("Fake CD track %u playing...\n", track); } else Con_DPrintf ("BGM track %s playing...\n", trackname); @@ -306,7 +308,7 @@ void CDAudio_Play (int track, qboolean looping) CDAudio_Play_byName(buf, looping); } -float CDAudio_GetPosition () +float CDAudio_GetPosition (void) { if(faketrack != -1) return S_GetChannelPosition(faketrack); @@ -327,7 +329,7 @@ void CDAudio_Stop (void) return; else if(wasPlaying) { - CDAudio_Resume(); // needed by SDL - can't stop while paused there + CDAudio_Resume(); // needed by SDL - can't stop while paused there (causing pause/stop to fail after play, pause, stop, play otherwise) if (cdPlaying && (CDAudio_SysStop() == -1)) return; } @@ -366,10 +368,12 @@ void CDAudio_Resume (void) static void CD_f (void) { const char *command; +#ifdef MAXTRACKS int ret; int n; +#endif - command = (Cmd_Argc() >= 2) ? Cmd_Argv (1) : ""; + command = Cmd_Argv (1); if (strcasecmp(command, "remap") != 0) Host_StartVideo(); @@ -391,15 +395,16 @@ static void CD_f (void) { enabled = true; CDAudio_Stop(); +#ifdef MAXTRACKS for (n = 0; n < MAXTRACKS; n++) *remap[n] = 0; // empty string, that is, unremapped +#endif CDAudio_GetAudioDiskInfo(); return; } if (strcasecmp(command, "rescan") == 0) { - CDAudio_Stop(); CDAudio_Shutdown(); CDAudio_Startup(); return; @@ -407,6 +412,7 @@ static void CD_f (void) if (strcasecmp(command, "remap") == 0) { +#ifdef MAXTRACKS ret = Cmd_Argc() - 2; if (ret <= 0) { @@ -417,6 +423,7 @@ static void CD_f (void) } for (n = 1; n <= ret; n++) strlcpy(remap[n], Cmd_Argv (n+1), sizeof(*remap)); +#endif return; } @@ -458,7 +465,7 @@ static void CD_f (void) if (strcasecmp(command, "eject") == 0) { - if (cdPlaying && faketrack == -1) + if (faketrack == -1) CDAudio_Stop(); CDAudio_Eject(); cdValid = false; @@ -486,7 +493,8 @@ static void CD_f (void) Con_Printf("CD commands:\n"); Con_Printf("cd on - enables CD audio system\n"); Con_Printf("cd off - stops and disables CD audio system\n"); - Con_Printf("cd reset - resets CD audio system (clears track remapping and re-reads disc information)"); + Con_Printf("cd reset - resets CD audio system (clears track remapping and re-reads disc information)\n"); + Con_Printf("cd rescan - rescans disks in drives (to use another disc)\n"); Con_Printf("cd remap [remap2] [remap3] [...] - chooses (possibly emulated) CD tracks to play when a map asks for a particular track, this has many uses\n"); Con_Printf("cd close - closes CD tray\n"); Con_Printf("cd eject - stops playing music and opens CD tray to allow you to change disc\n"); @@ -535,7 +543,9 @@ void CDAudio_Update (void) int CDAudio_Init (void) { +#ifdef MAXTRACKS int i; +#endif if (cls.state == ca_dedicated) return -1; @@ -546,8 +556,10 @@ int CDAudio_Init (void) CDAudio_SysInit(); +#ifdef MAXTRACKS for (i = 0; i < MAXTRACKS; i++) *remap[i] = 0; +#endif Cvar_RegisterVariable(&cdaudio); Cvar_RegisterVariable(&cdaudioinitialized);