]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Fine-grained CD volume support for Linux. Note that it uses the CD player internal...
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 15 Apr 2004 14:24:03 +0000 (14:24 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 15 Apr 2004 14:24:03 +0000 (14:24 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4108 d7cf8633-e32d-0410-b094-e92efae38249

cd_bsd.c
cd_linux.c
cd_null.c
cd_shared.c
cd_win.c

index 41de20a1653886448a08d354a8dc7066532d8bc1..6c8f9a81aa89149ad39e210c9d50986f6bda668f 100644 (file)
--- a/cd_bsd.c
+++ b/cd_bsd.c
@@ -81,6 +81,19 @@ int CDAudio_SysGetAudioDiskInfo (void)
 }
 
 
+float CDAudio_SysGetVolume (void)
+{
+       // IMPLEMENTME
+       return -1.0f;
+}
+
+
+void CDAudio_SysSetVolume (float volume)
+{
+       // IMPLEMENTME
+}
+
+
 int CDAudio_SysPlay (qbyte track)
 {
        struct ioc_read_toc_entry rte;
index feaa5b3a1104ca8fe95d20c5dd0eed76c690af2b..7877e83f5b7131374d2188c7871b0aa4b28a0885 100644 (file)
@@ -77,6 +77,36 @@ int CDAudio_SysGetAudioDiskInfo (void)
 }
 
 
+float CDAudio_SysGetVolume (void)
+{
+       struct cdrom_volctrl vol;
+
+       if (cdfile == -1)
+               return -1.0f;
+
+       if (ioctl (cdfile, CDROMVOLREAD, &vol) == -1)
+       {
+               Con_DPrint("ioctl CDROMVOLREAD failed\n");
+               return -1.0f;
+       }
+
+       return (vol.channel0 + vol.channel1) / 2.0f / 255.0f;
+}
+
+
+void CDAudio_SysSetVolume (float volume)
+{
+       struct cdrom_volctrl vol;
+
+       if (cdfile == -1)
+               return;
+
+       vol.channel0 = vol.channel1 = volume * 255;
+       if (ioctl (cdfile, CDROMVOLCTRL, &vol) == -1)
+               Con_DPrint("ioctl CDROMVOLCTRL failed\n");
+}
+
+
 int CDAudio_SysPlay (qbyte track)
 {
        struct cdrom_tocentry entry;
index 7bfe2f3e163ca5a01ac2bdfa1332c43b3d6690ba..300334a2af7fb83376f0586f6b3d02e90480f4e5 100644 (file)
--- a/cd_null.c
+++ b/cd_null.c
@@ -37,6 +37,17 @@ int CDAudio_SysGetAudioDiskInfo (void)
 }
 
 
+float CDAudio_SysGetVolume (void)
+{
+       return -1.0f;
+}
+
+
+void CDAudio_SysSetVolume (float volume)
+{
+}
+
+
 int CDAudio_SysPlay (qbyte track)
 {
        return -1;
index 6f15257090413e6da5f7f72a88e5b24d1757c07e..d1106c3701adab518d52025ba2f894034f64b059 100644 (file)
@@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 extern void CDAudio_SysEject (void);
 extern void CDAudio_SysCloseDoor (void);
 extern int CDAudio_SysGetAudioDiskInfo (void);
+extern float CDAudio_SysGetVolume (void);
+extern void CDAudio_SysSetVolume (float volume);
 extern int CDAudio_SysPlay (qbyte track);
 extern int CDAudio_SysStop (void);
 extern int CDAudio_SysPause (void);
@@ -46,6 +48,8 @@ static qbyte remap[100];
 static qbyte maxTrack;
 static int faketrack = -1;
 
+static float saved_vol = 1.0f;
+
 // exported variables
 qboolean cdValid = false;
 qboolean cdPlaying = false;
@@ -323,10 +327,7 @@ void CDAudio_SetVolume (float newvol)
 
                if (faketrack != -1)
                        S_SetChannelVolume (faketrack, newvol);
-               else
-               {
-                       // TODO: add support for the "real CD" mixer
-               }
+               CDAudio_SysSetVolume (newvol);
        }
 
        cdvolume = newvol;
@@ -377,6 +378,10 @@ int CDAudio_Startup (void)
                cdValid = false;
        }
 
+       saved_vol = CDAudio_SysGetVolume ();
+       if (saved_vol < 0.0f)
+               saved_vol = 1.0f;
+
        initialized = true;
 
        Con_DPrint("CD Audio Initialized\n");
@@ -388,6 +393,9 @@ void CDAudio_Shutdown (void)
 {
        if (!initialized)
                return;
+
+       CDAudio_SysSetVolume (saved_vol);
+
        CDAudio_Stop();
        CDAudio_SysShutdown();
        initialized = false;
index dee8ef63eb27950b1006df802575c2a28d70b312..b7c49173cba5d9549074043fae5a03fb135747de 100644 (file)
--- a/cd_win.c
+++ b/cd_win.c
@@ -81,6 +81,19 @@ int CDAudio_SysGetAudioDiskInfo(void)
 }
 
 
+float CDAudio_SysGetVolume (void)
+{
+       // IMPLEMENTME
+       return -1.0f;
+}
+
+
+void CDAudio_SysSetVolume (float volume)
+{
+       // IMPLEMENTME
+}
+
+
 int CDAudio_SysPlay (qbyte track)
 {
        DWORD                           dwReturn;