]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cd_bsd.c
changed lhrandom to use the full RAND_MAX limit (more random, after all the low bits...
[xonotic/darkplaces.git] / cd_bsd.c
index 41de20a1653886448a08d354a8dc7066532d8bc1..0608297fc2af5f812b3d3eb616f50c88eb79c9e8 100644 (file)
--- a/cd_bsd.c
+++ b/cd_bsd.c
@@ -17,8 +17,6 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */
-// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
-// rights reserved.
 
 #include <sys/types.h>
 #include <sys/cdio.h>
@@ -28,13 +26,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <fcntl.h>
 #include <paths.h>
 #include <unistd.h>
-#include <util.h>
+#include <time.h>
+#ifndef __FreeBSD__
+# include <util.h>
+#endif
 
 #include "quakedef.h"
+#include "cdaudio.h"
 
 
+#ifndef __FreeBSD__
+# define DEFAULT_CD_DEVICE _PATH_DEV "cd0"
+#else
+# define DEFAULT_CD_DEVICE "/dev/acd0c"
+#endif
+
 static int cdfile = -1;
-static char cd_dev[64] = _PATH_DEV "cd0";
+static char cd_dev[64] = DEFAULT_CD_DEVICE;
 
 
 void CDAudio_SysEject (void)
@@ -81,6 +89,38 @@ int CDAudio_SysGetAudioDiskInfo (void)
 }
 
 
+float CDAudio_SysGetVolume (void)
+{
+       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)
+{
+       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");
+}
+
+
 int CDAudio_SysPlay (qbyte track)
 {
        struct ioc_read_toc_entry rte;
@@ -211,15 +251,20 @@ void CDAudio_SysInit (void)
 {
        int i;
 
+// COMMANDLINEOPTION: BSD Sound: -cddev <devicepath> 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)
 {
+#ifndef __FreeBSD__
        char buff [80];
 
        if ((cdfile = opendisk(cd_dev, O_RDONLY, buff, sizeof(buff), 0)) == -1)
+#else
+       if ((cdfile = open(cd_dev, O_RDONLY)) < 0)
+#endif
        {
                Con_DPrintf("CDAudio_SysStartup: open of \"%s\" failed (%i)\n",
                                        cd_dev, errno);