]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cd_shared.c
migrated a large number of #define MAX values to quakedef.h and added a
[xonotic/darkplaces.git] / cd_shared.c
index 69c2df5263a407cadfa71d8b2fac81a4675d04ae..f00f66123aae8d245015acc4a5ee2ac87751b3af 100644 (file)
@@ -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;
 
@@ -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))
@@ -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 <remap1> [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);