X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=cd_linux.c;h=05bf5c7e6d5a4a7a3b8219ff02698f7d9e2d70ae;hb=d3cbe906d0eedcff735096a08340d8ca90457fa9;hp=32c0c3f071963411fdb540b33575c7a26d3197a5;hpb=4373c092bf0fd4af24faa72d3fd83b7adc8a408e;p=xonotic%2Fdarkplaces.git diff --git a/cd_linux.c b/cd_linux.c index 32c0c3f0..05bf5c7e 100644 --- a/cd_linux.c +++ b/cd_linux.c @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "quakedef.h" +#include "cdaudio.h" static int cdfile = -1; @@ -41,7 +42,7 @@ void CDAudio_SysEject (void) return; if (ioctl(cdfile, CDROMEJECT) == -1) - Con_DPrintf("ioctl CDROMEJECT failed\n"); + Con_Print("ioctl CDROMEJECT failed\n"); } @@ -51,22 +52,25 @@ void CDAudio_SysCloseDoor (void) return; if (ioctl(cdfile, CDROMCLOSETRAY) == -1) - Con_DPrintf("ioctl CDROMCLOSETRAY failed\n"); + Con_Print("ioctl CDROMCLOSETRAY failed\n"); } int CDAudio_SysGetAudioDiskInfo (void) { struct cdrom_tochdr tochdr; + if (cdfile == -1) + return -1; + if (ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1) { - Con_DPrintf("ioctl CDROMREADTOCHDR failed\n"); + Con_Print("ioctl CDROMREADTOCHDR failed\n"); return -1; } if (tochdr.cdth_trk0 < 1) { - Con_DPrintf("CDAudio: no music tracks\n"); + Con_Print("CDAudio: no music tracks\n"); return -1; } @@ -74,6 +78,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_Print("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_Print("ioctl CDROMVOLCTRL failed\n"); +} + + int CDAudio_SysPlay (qbyte track) { struct cdrom_tocentry entry; @@ -87,7 +123,7 @@ int CDAudio_SysPlay (qbyte track) entry.cdte_format = CDROM_MSF; if (ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1) { - Con_DPrintf("ioctl CDROMREADTOCENTRY failed\n"); + Con_Print("ioctl CDROMREADTOCENTRY failed\n"); return -1; } if (entry.cdte_ctrl == CDROM_DATA_TRACK) @@ -106,13 +142,13 @@ int CDAudio_SysPlay (qbyte track) if (ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1) { - Con_DPrintf("ioctl CDROMPLAYTRKIND failed\n"); + Con_Print("ioctl CDROMPLAYTRKIND failed\n"); return -1; } if (ioctl(cdfile, CDROMRESUME) == -1) { - Con_DPrintf("ioctl CDROMRESUME failed\n"); + Con_Print("ioctl CDROMRESUME failed\n"); return -1; } @@ -127,7 +163,7 @@ int CDAudio_SysStop (void) if (ioctl(cdfile, CDROMSTOP) == -1) { - Con_DPrintf("ioctl CDROMSTOP failed (%d)\n", errno); + Con_Printf("ioctl CDROMSTOP failed (%d)\n", errno); return -1; } @@ -141,7 +177,7 @@ int CDAudio_SysPause (void) if (ioctl(cdfile, CDROMPAUSE) == -1) { - Con_DPrintf("ioctl CDROMPAUSE failed\n"); + Con_Print("ioctl CDROMPAUSE failed\n"); return -1; } @@ -155,7 +191,7 @@ int CDAudio_SysResume (void) return -1; if (ioctl(cdfile, CDROMRESUME) == -1) - Con_DPrintf("ioctl CDROMRESUME failed\n"); + Con_Print("ioctl CDROMRESUME failed\n"); return 0; } @@ -171,7 +207,7 @@ int CDAudio_SysUpdate (void) subchnl.cdsc_format = CDROM_MSF; if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1) { - Con_DPrintf("ioctl CDROMSUBCHNL failed\n"); + Con_Print("ioctl CDROMSUBCHNL failed\n"); cdPlaying = false; return -1; } @@ -193,15 +229,16 @@ void CDAudio_SysInit (void) { int i; +// COMMANDLINEOPTION: Linux Sound: -cddev chooses which CD drive to use if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1) strlcpy(cd_dev, com_argv[i + 1], sizeof(cd_dev)); } 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", + Con_Printf("CDAudio_SysStartup: open of \"%s\" failed (%i)\n", cd_dev, errno); cdfile = -1; return -1;