X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=cd_linux.c;h=9d4b447699c48eeeb3751d393e33660d10b6fe4c;hb=a2a8098c98290345b7f60dcc13710d6521a58d23;hp=6331c00ec9c49c203c0f9e990f9a3422820cb2b1;hpb=ff46d6ff516fda192c5adc55a5c9b82007545bd2;p=xonotic%2Fdarkplaces.git diff --git a/cd_linux.c b/cd_linux.c index 6331c00e..9d4b4476 100644 --- a/cd_linux.c +++ b/cd_linux.c @@ -58,6 +58,9 @@ int CDAudio_SysGetAudioDiskInfo (void) { struct cdrom_tochdr tochdr; + if (cdfile == -1) + return -1; + if (ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1) { Con_DPrint("ioctl CDROMREADTOCHDR failed\n"); @@ -74,6 +77,38 @@ 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; + vol.channel2 = vol.channel3 = 0; + + if (ioctl (cdfile, CDROMVOLCTRL, &vol) == -1) + Con_DPrint("ioctl CDROMVOLCTRL failed\n"); +} + + int CDAudio_SysPlay (qbyte track) { struct cdrom_tocentry entry; @@ -199,7 +234,7 @@ void CDAudio_SysInit (void) int CDAudio_SysStartup (void) { - if ((cdfile = open(cd_dev, O_RDONLY)) == -1) + if ((cdfile = open(cd_dev, O_RDONLY | O_NONBLOCK)) == -1) { Con_DPrintf("CDAudio_SysStartup: open of \"%s\" failed (%i)\n", cd_dev, errno);