]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cd_linux.c
fixed a couple warnings on memsetting shm
[xonotic/darkplaces.git] / cd_linux.c
index eb8ef45f0abf11570930783c31625b0f78feaf12..c502e0ace8d21d0135be85242c2d614fc524387e 100644 (file)
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
@@ -56,7 +56,7 @@ static void CDAudio_Eject(void)
        if (cdfile == -1 || !enabled)
                return; // no cd init'd
 
-       if ( ioctl(cdfile, CDROMEJECT) == -1 ) 
+       if ( ioctl(cdfile, CDROMEJECT) == -1 )
                Con_DPrintf("ioctl cdromeject failed\n");
 }
 
@@ -66,7 +66,7 @@ static void CDAudio_CloseDoor(void)
        if (cdfile == -1 || !enabled)
                return; // no cd init'd
 
-       if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 ) 
+       if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
                Con_DPrintf("ioctl cdromclosetray failed\n");
 }
 
@@ -76,7 +76,7 @@ static int CDAudio_GetAudioDiskInfo(void)
 
        cdValid = false;
 
-       if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 ) 
+       if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
     {
       Con_DPrintf("ioctl cdromreadtochdr failed\n");
          return -1;
@@ -102,7 +102,7 @@ void CDAudio_Play(qbyte track, qboolean looping)
 
        if (cdfile == -1 || !enabled)
                return;
-       
+
        if (!cdValid)
        {
                CDAudio_GetAudioDiskInfo();
@@ -144,13 +144,13 @@ void CDAudio_Play(qbyte track, qboolean looping)
        ti.cdti_ind0 = 1;
        ti.cdti_ind1 = 99;
 
-       if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 ) 
+       if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
     {
                Con_DPrintf("ioctl cdromplaytrkind failed\n");
                return;
     }
 
-       if ( ioctl(cdfile, CDROMRESUME) == -1 ) 
+       if ( ioctl(cdfile, CDROMRESUME) == -1 )
                Con_DPrintf("ioctl cdromresume failed\n");
 
        playLooping = looping;
@@ -166,7 +166,7 @@ void CDAudio_Stop(void)
 {
        if (cdfile == -1 || !enabled)
                return;
-       
+
        if (!playing)
                return;
 
@@ -185,7 +185,7 @@ void CDAudio_Pause(void)
        if (!playing)
                return;
 
-       if ( ioctl(cdfile, CDROMPAUSE) == -1 ) 
+       if ( ioctl(cdfile, CDROMPAUSE) == -1 )
                Con_DPrintf("ioctl cdrompause failed\n");
 
        wasPlaying = playing;
@@ -197,13 +197,13 @@ void CDAudio_Resume(void)
 {
        if (cdfile == -1 || !enabled)
                return;
-       
+
        if (!cdValid)
                return;
 
        if (!wasPlaying)
                return;
-       
+
        if ( ioctl(cdfile, CDROMRESUME) == -1 )
                Con_DPrintf("ioctl cdromresume failed\n");
        playing = true;
@@ -220,13 +220,13 @@ static void CD_f (void)
 
        command = Cmd_Argv (1);
 
-       if (Q_strcasecmp(command, "on") == 0)
+       if (strcasecmp(command, "on") == 0)
        {
                enabled = true;
                return;
        }
 
-       if (Q_strcasecmp(command, "off") == 0)
+       if (strcasecmp(command, "off") == 0)
        {
                if (playing)
                        CDAudio_Stop();
@@ -234,7 +234,7 @@ static void CD_f (void)
                return;
        }
 
-       if (Q_strcasecmp(command, "reset") == 0)
+       if (strcasecmp(command, "reset") == 0)
        {
                enabled = true;
                if (playing)
@@ -245,7 +245,7 @@ static void CD_f (void)
                return;
        }
 
-       if (Q_strcasecmp(command, "remap") == 0)
+       if (strcasecmp(command, "remap") == 0)
        {
                ret = Cmd_Argc() - 2;
                if (ret <= 0)
@@ -260,7 +260,7 @@ static void CD_f (void)
                return;
        }
 
-       if (Q_strcasecmp(command, "close") == 0)
+       if (strcasecmp(command, "close") == 0)
        {
                CDAudio_CloseDoor();
                return;
@@ -276,37 +276,37 @@ static void CD_f (void)
                }
        }
 
-       if (Q_strcasecmp(command, "play") == 0)
+       if (strcasecmp(command, "play") == 0)
        {
                CDAudio_Play((qbyte)atoi(Cmd_Argv (2)), false);
                return;
        }
 
-       if (Q_strcasecmp(command, "loop") == 0)
+       if (strcasecmp(command, "loop") == 0)
        {
                CDAudio_Play((qbyte)atoi(Cmd_Argv (2)), true);
                return;
        }
 
-       if (Q_strcasecmp(command, "stop") == 0)
+       if (strcasecmp(command, "stop") == 0)
        {
                CDAudio_Stop();
                return;
        }
 
-       if (Q_strcasecmp(command, "pause") == 0)
+       if (strcasecmp(command, "pause") == 0)
        {
                CDAudio_Pause();
                return;
        }
 
-       if (Q_strcasecmp(command, "resume") == 0)
+       if (strcasecmp(command, "resume") == 0)
        {
                CDAudio_Resume();
                return;
        }
 
-       if (Q_strcasecmp(command, "eject") == 0)
+       if (strcasecmp(command, "eject") == 0)
        {
                if (playing)
                        CDAudio_Stop();
@@ -315,7 +315,7 @@ static void CD_f (void)
                return;
        }
 
-       if (Q_strcasecmp(command, "info") == 0)
+       if (strcasecmp(command, "info") == 0)
        {
                Con_Printf("%u tracks\n", maxTrack);
                if (playing)
@@ -379,36 +379,41 @@ int CDAudio_Init(void)
                return -1;
 
        if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1) {
-               strncpy(cd_dev, com_argv[i + 1], sizeof(cd_dev));
+               strlcpy (cd_dev, com_argv[i + 1], sizeof (cd_dev));
                cd_dev[sizeof(cd_dev) - 1] = 0;
        }
 
-       if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
-               Con_Printf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
-               cdfile = -1;
-               return -1;
-       }
+       Cmd_AddCommand("cd", CD_f);
 
        for (i = 0; i < 100; i++)
                remap[i] = i;
        cdaudioinitialized = true;
-       initialized = true;
        enabled = true;
 
+       return 0;
+}
+
+int CDAudio_Startup(void)
+{
+       if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
+               Con_DPrintf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
+               cdfile = -1;
+               return -1;
+       }
+
        if (CDAudio_GetAudioDiskInfo())
        {
-               Con_Printf("CDAudio_Init: No CD in player.\n");
+               Con_DPrintf("CDAudio_Init: No CD in player.\n");
                cdValid = false;
        }
 
-       Cmd_AddCommand ("cd", CD_f);
+       initialized = true;
 
-       Con_Printf("CD Audio Initialized\n");
+       Con_DPrintf("CD Audio Started\n");
 
        return 0;
 }
 
-
 void CDAudio_Shutdown(void)
 {
        if (!initialized)
@@ -416,12 +421,6 @@ void CDAudio_Shutdown(void)
        CDAudio_Stop();
        close(cdfile);
        cdfile = -1;
+       initialized = false;
 }
 
-void CDAudio_Open(void)
-{
-}
-
-void CDAudio_Close(void)
-{
-}