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");
}
return;
vol.channel0 = vol.channel1 = volume * 255;
+ vol.channel2 = vol.channel3 = 0;
+
if (ioctl (cdfile, CDROMVOLCTRL, &vol) == -1)
Con_DPrint("ioctl CDROMVOLCTRL failed\n");
}
if (track > maxTrack)
{
- Con_DPrintf("CDAudio: Bad track number %u.\n", track);
+ Con_Printf("CDAudio: Bad track number %u.\n", track);
return;
}
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;