From a2a8098c98290345b7f60dcc13710d6521a58d23 Mon Sep 17 00:00:00 2001 From: molivier Date: Fri, 16 Apr 2004 06:28:12 +0000 Subject: [PATCH] Fine-grained CD volume for NetBSD. Made the CD error message "Bad track number" a normal (non-developer) message. Zeroed the 3rd and 4th channel volumes in the Linux CD module too. The initial CD volume is now printed at startup (developer message). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4111 d7cf8633-e32d-0410-b094-e92efae38249 --- cd_bsd.c | 25 ++++++++++++++++++++++--- cd_linux.c | 2 ++ cd_shared.c | 7 ++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/cd_bsd.c b/cd_bsd.c index 6c8f9a81..5f4aa2b2 100644 --- a/cd_bsd.c +++ b/cd_bsd.c @@ -83,14 +83,33 @@ int CDAudio_SysGetAudioDiskInfo (void) float CDAudio_SysGetVolume (void) { - // IMPLEMENTME - return -1.0f; + 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) { - // IMPLEMENTME + 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"); } diff --git a/cd_linux.c b/cd_linux.c index 7877e83f..9d4b4476 100644 --- a/cd_linux.c +++ b/cd_linux.c @@ -102,6 +102,8 @@ void CDAudio_SysSetVolume (float volume) return; vol.channel0 = vol.channel1 = volume * 255; + vol.channel2 = vol.channel3 = 0; + if (ioctl (cdfile, CDROMVOLCTRL, &vol) == -1) Con_DPrint("ioctl CDROMVOLCTRL failed\n"); } diff --git a/cd_shared.c b/cd_shared.c index d1106c37..bce1c14b 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -137,7 +137,7 @@ void CDAudio_Play (qbyte track, qboolean looping) if (track > maxTrack) { - Con_DPrintf("CDAudio: Bad track number %u.\n", track); + Con_Printf("CDAudio: Bad track number %u.\n", track); return; } @@ -380,7 +380,12 @@ int CDAudio_Startup (void) saved_vol = CDAudio_SysGetVolume (); if (saved_vol < 0.0f) + { + Con_DPrint ("Can't get initial CD volume\n"); saved_vol = 1.0f; + } + else + Con_DPrintf ("Initial CD volume: %g\n", saved_vol); initialized = true; -- 2.39.2