Sound cleanups from Marcus: snd_linux.c -> snd_oss.c, the OSS API is used

on a lot more than just Linux.  Updated Autoconf to check for OSS rather
than check for Linux and just assume OSS is there.
This commit is contained in:
Joseph Carter 2000-01-02 16:18:22 +00:00
parent 6d9ae5f2ef
commit 8ee8699d16
6 changed files with 120 additions and 32 deletions

View file

@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "quakedef.h"
#include <mme/mmsystem.h>
#include <mme/mme_public.h>
#ifdef HAVE_MME_MME_PUBLIC_H
# include <mme/mme_public.h>
#endif
// 64K is > 1 second at 16-bit, 11025 Hz
#define WAV_BUFFERS 64

View file

@ -19,10 +19,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "quakedef.h"
#include "winquake.h"
#ifdef HAVE_MMSYSTEM_H
# include <mmsystem.h>
#endif
#ifdef HAVE_DSOUND
#define iDirectSoundCreate(a,b,c) pDirectSoundCreate(a,b,c)
HRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter);
#endif
// 64K is > 1 second at 16-bit, 22050 Hz
#define WAV_BUFFERS 64
@ -35,8 +40,10 @@ typedef enum {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;
static qboolean wavonly;
static qboolean dsound_init;
static qboolean wav_init;
static qboolean snd_firsttime = true, snd_isdirect, snd_iswave;
static qboolean primary_format_set;
static qboolean snd_firsttime = true, snd_iswave;
#ifdef HAVE_DSOUND
static qboolean primary_format_set, snd_isdirect;
#endif
static int sample16;
static int snd_sent, snd_completed;
@ -61,8 +68,10 @@ DWORD gSndBufSize;
MMTIME mmstarttime;
#ifdef HAVE_DSOUND
LPDIRECTSOUND pDS;
LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;
#endif
HINSTANCE hInstDS;
@ -114,6 +123,7 @@ void FreeSound (void)
{
int i;
#ifdef HAVE_DSOUND
if (pDSBuf)
{
pDSBuf->lpVtbl->Stop(pDSBuf);
@ -131,6 +141,7 @@ void FreeSound (void)
pDS->lpVtbl->SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
pDS->lpVtbl->Release(pDS);
}
#endif
if (hWaveOut)
{
@ -158,9 +169,11 @@ void FreeSound (void)
}
#ifdef HAVE_DSOUND
pDS = NULL;
pDSBuf = NULL;
pDSPBuf = NULL;
#endif
hWaveOut = 0;
hData = 0;
hWaveHdr = 0;
@ -178,6 +191,7 @@ SNDDMA_InitDirect
Direct-Sound support
==================
*/
#ifdef HAVE_DSOUND
sndinitstat SNDDMA_InitDirect (void)
{
DSBUFFERDESC dsbuf;
@ -414,6 +428,7 @@ sndinitstat SNDDMA_InitDirect (void)
return SIS_SUCCESS;
}
#endif /* HAVE_DSOUND */
/*
@ -558,7 +573,7 @@ Returns false if nothing is found.
==================
*/
int SNDDMA_Init(void)
qboolean SNDDMA_Init(void)
{
sndinitstat stat;
@ -569,6 +584,7 @@ int SNDDMA_Init(void)
stat = SIS_FAILURE; // assume DirectSound won't initialize
#ifdef HAVE_DSOUND
/* Init DirectSound */
if (!wavonly)
{
@ -590,6 +606,7 @@ int SNDDMA_Init(void)
}
}
}
#endif
// if DirectSound didn't succeed in initializing, try to initialize
// waveOut sound, unless DirectSound failed because the hardware is
@ -638,8 +655,9 @@ how many sample are required to fill it up.
*/
int SNDDMA_GetDMAPos(void)
{
MMTIME mmtime;
int s;
#ifdef HAVE_DSOUND
MMTIME mmtime;
DWORD dwWrite;
if (dsound_init)
@ -647,9 +665,9 @@ int SNDDMA_GetDMAPos(void)
mmtime.wType = TIME_SAMPLES;
pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &mmtime.u.sample, &dwWrite);
s = mmtime.u.sample - mmstarttime.u.sample;
}
else if (wav_init)
{
} else
#endif /* HAVE_DSOUND */
if (wav_init) {
s = snd_sent * WAV_BUFFER_SIZE;
}

View file

@ -26,9 +26,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVERONLY
#include <ddraw.h>
#include <dsound.h>
#ifdef HAVE_MMSYSTEM_H
# include <mmsystem.h>
#endif
#ifdef HAVE_DSOUND_H
# include <dsound.h>
# define HAVE_DSOUND
#endif
#ifndef GLQUAKE
#include <mgraph.h>
//#include <mgraph.h>
#endif
#endif
@ -47,8 +53,10 @@ extern LPDIRECTDRAWSURFACE lpPrimary;
extern LPDIRECTDRAWSURFACE lpFrontBuffer;
extern LPDIRECTDRAWSURFACE lpBackBuffer;
extern LPDIRECTDRAWPALETTE lpDDPal;
#ifdef HAVE_DSOUND
extern LPDIRECTSOUND pDS;
extern LPDIRECTSOUNDBUFFER pDSBuf;
#endif
extern DWORD gSndBufSize;
//#define SNDBUFSIZE 65536

View file

@ -12,6 +12,11 @@ AC_PROG_CC
AC_PROG_CPP
AC_PROG_MAKE_SET
dnl Checks for header files.
AC_CHECK_HEADERS(unistd.h windows.h sys/ioctl.h sys/mman.h \
sys/soundcard.h linux/soundcard.h machine/soundcard.h sys/audioio.h \
dsound.h mmsystem.h mme/mmsystem.h mme/mme_public.h)
dnl checks for compiler characteristics
AC_C_BIGENDIAN
@ -351,24 +356,73 @@ AC_SUBST(INTEL_ARCH)
#
# Sound available?
#
dnl Check for sound libraries
AC_CHECK_LIB(mme,waveOutOpen,HAVE_LIBMME=yes)
SND_LIBS=""
AC_MSG_CHECKING(for sound support)
case "${target}" in
changequote(,)dnl
i[34567]86-*-linux-gnu*)
SND_STYLE="Linux" ;;
*-solaris*)
SND_STYLE="Solaris" ;;
*-dec-osf[34]*)
SND_STYLE="MME"
SND_LIBS="-lmme"
;;
*)
SND_STYLE="Null" ;;
# XXX - need to add dos, Windows
changequote([,])dnl
esac
if test "x$SND_STYLE" = xNull; then
SND_STYLE=""
if test "x$ac_cv_header_sys_soundcard_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[
#include <sys/soundcard.h>
#ifdef SNDCTL_DSP_SETTRIGGER
QF_maGiC_VALUE
#endif
], SND_STYLE="OSS")
fi
if test -z "$SND_STYLE" -a "x$ac_cv_header_linux_soundcard_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[
#include <linux/soundcard.h>
#ifdef SNDCTL_DSP_SETTRIGGER
QF_maGiC_VALUE
#endif
], SND_STYLE="OSS")
fi
if test -z "$SND_STYLE" -a "x$ac_cv_header_machine_soundcard_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[
#include <machine/soundcard.h>
#ifdef SNDCTL_DSP_SETTRIGGER
QF_maGiC_VALUE
#endif
], SND_STYLE="OSS")
fi
if test -z "$SND_STYLE" -a "x$ac_cv_header_sys_audioio_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[
#include <sys/audioio.h>
#ifdef AUDIO_SETINFO
QF_maGiC_VALUE
#endif
], SND_STYLE="Solaris")
fi
if test -z "$SND_STYLE" -a "x$ac_cv_header_mme_mmsystem_h" = "xyes" -a \
"x$HAVE_LIBMME" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[
#include <mme/mmsystem.h>
#ifdef WAVE_OPEN_SHAREABLE
QF_maGiC_VALUE
#endif
], SND_STYLE="MME"
SND_LIBS="-lmme")
fi
if test -z "$SND_STYLE" -a "x$ac_cv_header_windows_h" = "xyes" -a \
"x$ac_cv_header_mmsystem_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[
#include <windows.h>
#include <mmsystem.h>
#ifdef GMEM_MOVEABLE
#ifdef WAVE_FORMAT_PCM
QF_maGiC_VALUE
#endif
#endif
], SND_STYLE="Windows"
)
fi
if test "x$SND_STYLE" = "x"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes ($SND_STYLE style))

View file

@ -112,8 +112,8 @@ CD_AUDIO_SRC = cd_wrapper.c
SND_STYLE = @SND_STYLE@
SND_SRC = snd_null.c
ifeq ($(SND_STYLE),Linux)
SND_SRC = snd_dma.c snd_linux.c snd_mixa.s
ifeq ($(SND_STYLE),OSS)
SND_SRC = snd_dma.c snd_oss.c
endif
ifeq ($(SND_STYLE),Solaris)
SND_SRC = snd_dma.c snd_sun.c
@ -121,8 +121,11 @@ endif
ifeq ($(SND_STYLE),MME)
SND_SRC = snd_dma.c snd_mme.c
endif
ifeq ($(SND_STYLE),Windows)
SND_SRC = snd_dma.c snd_win.c
endif
SND_SRC += snd_mem.c snd_mix.c
SND_SRC += snd_mem.c snd_mix.c snd_mixa.s
X11_VID_SRC = @X11_VID_SRC@
QW_X11_VID_SRC = vid_x.c

View file

@ -108,8 +108,8 @@ CD_AUDIO_SRC = cd_wrapper.c
SND_STYLE = @SND_STYLE@
SND_SRC = snd_null.c
ifeq ($(SND_STYLE),Linux)
SND_SRC = snd_dma.c snd_linux.c snd_mixa.s
ifeq ($(SND_STYLE),OSS)
SND_SRC = snd_dma.c snd_oss.c
endif
ifeq ($(SND_STYLE),Solaris)
SND_SRC = snd_dma.c snd_sun.c
@ -117,8 +117,11 @@ endif
ifeq ($(SND_STYLE),MME)
SND_SRC = snd_dma.c snd_mme.c
endif
ifeq ($(SND_STYLE),Windows)
SND_SRC = snd_dma.c snd_win.c
endif
SND_SRC += snd_mem.c snd_mix.c
SND_SRC += snd_mem.c snd_mix.c snd_mixa.s
# x11 vid