]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cd_bsd.c
added COMMANDLINEOPTION comments for every commandline option, these will be listed...
[xonotic/darkplaces.git] / cd_bsd.c
index 14bb317260ada047bbc5d3e3a1e2977f34b0ef20..eaf2666959e2b2e1b667792dfe551eb463ecf696 100644 (file)
--- a/cd_bsd.c
+++ b/cd_bsd.c
@@ -44,7 +44,7 @@ void CDAudio_SysEject (void)
 
        ioctl(cdfile, CDIOCALLOW);
        if (ioctl(cdfile, CDIOCEJECT) == -1)
-               Con_DPrintf("ioctl CDIOCEJECT failed\n");
+               Con_DPrint("ioctl CDIOCEJECT failed\n");
 }
 
 
@@ -55,22 +55,25 @@ void CDAudio_SysCloseDoor (void)
 
        ioctl(cdfile, CDIOCALLOW);
        if (ioctl(cdfile, CDIOCCLOSE) == -1)
-               Con_DPrintf("ioctl CDIOCCLOSE failed\n");
+               Con_DPrint("ioctl CDIOCCLOSE failed\n");
 }
 
 int CDAudio_SysGetAudioDiskInfo (void)
 {
        struct ioc_toc_header tochdr;
 
+       if (cdfile == -1)
+               return -1;
+
        if (ioctl(cdfile, CDIOREADTOCHEADER, &tochdr) == -1)
        {
-               Con_DPrintf("ioctl CDIOREADTOCHEADER failed\n");
+               Con_DPrint("ioctl CDIOREADTOCHEADER failed\n");
                return -1;
        }
 
        if (tochdr.starting_track < 1)
        {
-               Con_DPrintf("CDAudio: no music tracks\n");
+               Con_DPrint("CDAudio: no music tracks\n");
                return -1;
        }
 
@@ -78,6 +81,38 @@ int CDAudio_SysGetAudioDiskInfo (void)
 }
 
 
+float CDAudio_SysGetVolume (void)
+{
+       struct ioc_vol vol;
+
+       if (cdfile == -1)
+               return -1.0f;
+
+       if (ioctl (cdfile, CDIOCGETVOL, &vol) == -1)
+       {
+               Con_DPrint("ioctl CDIOCGETVOL failed\n");
+               return -1.0f;
+       }
+
+       return (vol.vol[0] + vol.vol[1]) / 2.0f / 255.0f;
+}
+
+
+void CDAudio_SysSetVolume (float volume)
+{
+       struct ioc_vol vol;
+
+       if (cdfile == -1)
+               return;
+
+       vol.vol[0] = vol.vol[1] = volume * 255;
+       vol.vol[2] = vol.vol[3] = 0;
+
+       if (ioctl (cdfile, CDIOCSETVOL, &vol) == -1)
+               Con_DPrintf ("ioctl CDIOCSETVOL failed\n");
+}
+
+
 int CDAudio_SysPlay (qbyte track)
 {
        struct ioc_read_toc_entry rte;
@@ -94,7 +129,7 @@ int CDAudio_SysPlay (qbyte track)
        rte.data = &entry;
        if (ioctl(cdfile, CDIOREADTOCENTRYS, &rte) == -1)
        {
-               Con_DPrintf("ioctl CDIOREADTOCENTRYS failed\n");
+               Con_DPrint("ioctl CDIOREADTOCENTRYS failed\n");
                return -1;
        }
        if (entry.control & 4)  // if it's a data track
@@ -113,13 +148,13 @@ int CDAudio_SysPlay (qbyte track)
 
        if (ioctl(cdfile, CDIOCPLAYTRACKS, &ti) == -1)
        {
-               Con_DPrintf("ioctl CDIOCPLAYTRACKS failed\n");
+               Con_DPrint("ioctl CDIOCPLAYTRACKS failed\n");
                return -1;
        }
 
        if (ioctl(cdfile, CDIOCRESUME) == -1)
        {
-               Con_DPrintf("ioctl CDIOCRESUME failed\n");
+               Con_DPrint("ioctl CDIOCRESUME failed\n");
                return -1;
        }
 
@@ -149,7 +184,7 @@ int CDAudio_SysPause (void)
 
        if (ioctl(cdfile, CDIOCPAUSE) == -1)
        {
-               Con_DPrintf("ioctl CDIOCPAUSE failed\n");
+               Con_DPrint("ioctl CDIOCPAUSE failed\n");
                return -1;
        }
 
@@ -163,7 +198,7 @@ int CDAudio_SysResume (void)
                return -1;
 
        if (ioctl(cdfile, CDIOCRESUME) == -1)
-               Con_DPrintf("ioctl CDIOCRESUME failed\n");
+               Con_DPrint("ioctl CDIOCRESUME failed\n");
 
        return 0;
 }
@@ -186,7 +221,7 @@ int CDAudio_SysUpdate (void)
 
                if (ioctl(cdfile, CDIOCREADSUBCHANNEL, &subchnl) == -1)
                {
-                       Con_DPrintf("ioctl CDIOCREADSUBCHANNEL failed\n");
+                       Con_DPrint("ioctl CDIOCREADSUBCHANNEL failed\n");
                        cdPlaying = false;
                        return -1;
                }
@@ -208,6 +243,7 @@ void CDAudio_SysInit (void)
 {
        int i;
 
+// COMMANDLINEOPTION: -cddev <devicepath> chooses which CD drive to use (bsd and Linux only)
        if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1)
                strlcpy(cd_dev, com_argv[i + 1], sizeof(cd_dev));
 }