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>
#include <fcntl.h>
#include <paths.h>
#include <unistd.h>
-#include <util.h>
+#include <time.h>
+#ifndef __FreeBSD__
+# include <util.h>
+#endif
#include "quakedef.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)
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);
if (jpeg_dll)
return true;
+// TODO: make Sys_LoadLibrary support multiple names
#ifdef WIN32
dllname = "libjpeg.dll";
+#elif defined(__FreeBSD__)
+ dllname = "libjpeg.so";
#else
dllname = "libjpeg.so.62";
#endif
#ifdef WIN32
#include <winsock.h>
#else
-#include <netdb.h>
-#include <netinet/in.h>
-//#include <arpa/inet.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <errno.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#endif
// for Z_Malloc/Z_Free in quake
# UNIXes
DP_ARCH:=$(shell uname)
-ifeq ($(DP_ARCH),NetBSD)
+ifneq ($(filter %BSD,$(DP_ARCH)),)
DP_MAKE_TARGET=bsd
else
DP_MAKE_TARGET=linux
endif
+# If we're not on compiling for Win32, we need additional information
+ifneq ($(DP_MAKE_TARGET), mingw)
+ DP_ARCH:=$(shell uname)
+ DP_MACHINE:=$(shell uname -m)
+endif
+
# Command used to delete files
ifdef windir
CMD_RM=$(CMD_UNIXRM)
endif
-
-DP_MACHINE:=$(shell uname -m)
+# 64bits AMD CPUs use another lib directory
ifeq ($(DP_MACHINE),x86_64)
UNIX_X11LIBPATH:=-L/usr/X11R6/lib64
else
# BSD configuration
ifeq ($(DP_MAKE_TARGET), bsd)
+ifeq ($(DP_ARCH),FreeBSD)
+ OBJ_SOUND=$(OBJ_OSSSOUND)
+ LIB_SOUND=$(LIB_OSSSOUND)
+else
OBJ_SOUND=$(OBJ_BSDSOUND)
LIB_SOUND=$(LIB_BSDSOUND)
+endif
OBJ_CD=$(OBJ_BSDCD)
OBJ_CL=$(OBJ_GLX)
# BSD configuration
.if $(DP_MAKE_TARGET) == "bsd"
+# FreeBSD uses OSS
+.if exists(/usr/include/sys/soundcard.h)
+OBJ_SOUND=$(OBJ_OSSSOUND)
+.else
OBJ_SOUND=$(OBJ_BSDSOUND)
+.endif
LIB_SOUND=$(LIB_BSDSOUND)
OBJ_CD=$(OBJ_BSDCD)
# Sound objects
OBJ_COMMONSOUND=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
OBJ_NOSOUND=snd_null.o
+OBJ_OSSSOUND=$(OBJ_COMMONSOUND) snd_oss.o
+LIB_OSSSOUND=
# CD objects
OBJ_NOCD=cd_null.o
##### Linux specific variables #####
# Recommended for: anyone not using ALSA
-OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_oss.o
-LIB_LINUXSOUND=
+OBJ_LINUXSOUND=$(OBJ_OSSSOUND)
+LIB_LINUXSOUND=$(LIB_OSSSOUND)
# Recommended for: anyone using ALSA
#OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_alsa.o
#LIB_LINUXSOUND=-lasound
#ifndef QUAKEDEF_H
#define QUAKEDEF_H
-#define QUAKE_GAME // as opposed to utilities
+#include <sys/types.h>
#include <math.h>
#include <string.h>
#include <stdarg.h>
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
+// OSS module, used by Linux and FreeBSD
+
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
snd_inited = 0;
// open /dev/dsp, confirm capability to mmap, and get size of dma buffer
- audio_fd = open("/dev/dsp", O_RDWR);
+ audio_fd = open("/dev/dsp", O_RDWR); // we have to open it O_RDWR for mmap
if (audio_fd < 0)
{
perror("/dev/dsp");
shm->format.speed = atoi(com_argv[i+1]);
else
{
- for (i = 0;i < (int) sizeof(tryrates) / 4;i++)
+ for (i = 0;i < (int) sizeof(tryrates) / sizeof(tryrates[0]);i++)
if (!ioctl(audio_fd, SNDCTL_DSP_SPEED, &tryrates[i]))
break;
else if ((i = COM_CheckParm("-sndmono")) != 0)
shm->format.channels = 1;
// COMMANDLINEOPTION: Linux OSS Sound: -sndstereo sets sound output to stereo
- else if ((i = COM_CheckParm("-sndstereo")) != 0)
- shm->format.channels = 2;
- else
+ else // if ((i = COM_CheckParm("-sndstereo")) != 0)
shm->format.channels = 2;
- shm->samples = info.fragstotal * info.fragsize / shm->format.width;
-
- // memory map the dma buffer
- shm->bufferlength = info.fragstotal * info.fragsize;
- shm->buffer = (unsigned char *) mmap(NULL, shm->bufferlength, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
- if (!shm->buffer || shm->buffer == (unsigned char *)-1)
- {
- perror("/dev/dsp");
- Con_Print("Could not mmap /dev/dsp\n");
- close(audio_fd);
- return 0;
- }
-
- tmp = 0;
- if (shm->format.channels == 2)
- tmp = 1;
-
+ tmp = (shm->format.channels == 2);
rc = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
if (rc < 0)
{
perror("/dev/dsp");
- Con_Printf("Could not set /dev/dsp to stereo=%d\n", shm->format.channels);
+ Con_Printf("Could not set /dev/dsp to stereo=%d\n", tmp);
close(audio_fd);
return 0;
}
- if (tmp)
- shm->format.channels = 2;
- else
- shm->format.channels = 1;
rc = ioctl(audio_fd, SNDCTL_DSP_SPEED, &shm->format.speed);
if (rc < 0)
return 0;
}
+ shm->samples = info.fragstotal * info.fragsize / shm->format.width;
+
+ // memory map the dma buffer
+ shm->bufferlength = info.fragstotal * info.fragsize;
+ shm->buffer = (unsigned char *) mmap(NULL, shm->bufferlength, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
+ if (!shm->buffer || shm->buffer == (unsigned char *)-1)
+ {
+ perror("/dev/dsp");
+ Con_Print("Could not mmap /dev/dsp\n");
+ close(audio_fd);
+ return 0;
+ }
+
// toggle the trigger & start her up
tmp = 0;
rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
os = "Linux";
#elif defined(WIN32)
os = "Windows";
+#elif defined(__FreeBSD__)
+ os = "FreeBSD";
#elif defined(__NetBSD__)
os = "NetBSD";
#elif defined(__OpenBSD__)