mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2025-02-22 11:31:31 +00:00
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:
parent
6d9ae5f2ef
commit
8ee8699d16
6 changed files with 120 additions and 32 deletions
|
@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
#include <mme/mmsystem.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
|
// 64K is > 1 second at 16-bit, 11025 Hz
|
||||||
#define WAV_BUFFERS 64
|
#define WAV_BUFFERS 64
|
||||||
|
|
|
@ -19,10 +19,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
#include "winquake.h"
|
#include "winquake.h"
|
||||||
|
#ifdef HAVE_MMSYSTEM_H
|
||||||
|
# include <mmsystem.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
#define iDirectSoundCreate(a,b,c) pDirectSoundCreate(a,b,c)
|
#define iDirectSoundCreate(a,b,c) pDirectSoundCreate(a,b,c)
|
||||||
|
|
||||||
HRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter);
|
HRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 64K is > 1 second at 16-bit, 22050 Hz
|
// 64K is > 1 second at 16-bit, 22050 Hz
|
||||||
#define WAV_BUFFERS 64
|
#define WAV_BUFFERS 64
|
||||||
|
@ -35,8 +40,10 @@ typedef enum {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;
|
||||||
static qboolean wavonly;
|
static qboolean wavonly;
|
||||||
static qboolean dsound_init;
|
static qboolean dsound_init;
|
||||||
static qboolean wav_init;
|
static qboolean wav_init;
|
||||||
static qboolean snd_firsttime = true, snd_isdirect, snd_iswave;
|
static qboolean snd_firsttime = true, snd_iswave;
|
||||||
static qboolean primary_format_set;
|
#ifdef HAVE_DSOUND
|
||||||
|
static qboolean primary_format_set, snd_isdirect;
|
||||||
|
#endif
|
||||||
|
|
||||||
static int sample16;
|
static int sample16;
|
||||||
static int snd_sent, snd_completed;
|
static int snd_sent, snd_completed;
|
||||||
|
@ -61,8 +68,10 @@ DWORD gSndBufSize;
|
||||||
|
|
||||||
MMTIME mmstarttime;
|
MMTIME mmstarttime;
|
||||||
|
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
LPDIRECTSOUND pDS;
|
LPDIRECTSOUND pDS;
|
||||||
LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;
|
LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;
|
||||||
|
#endif
|
||||||
|
|
||||||
HINSTANCE hInstDS;
|
HINSTANCE hInstDS;
|
||||||
|
|
||||||
|
@ -114,6 +123,7 @@ void FreeSound (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
if (pDSBuf)
|
if (pDSBuf)
|
||||||
{
|
{
|
||||||
pDSBuf->lpVtbl->Stop(pDSBuf);
|
pDSBuf->lpVtbl->Stop(pDSBuf);
|
||||||
|
@ -131,6 +141,7 @@ void FreeSound (void)
|
||||||
pDS->lpVtbl->SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
|
pDS->lpVtbl->SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
|
||||||
pDS->lpVtbl->Release(pDS);
|
pDS->lpVtbl->Release(pDS);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hWaveOut)
|
if (hWaveOut)
|
||||||
{
|
{
|
||||||
|
@ -158,9 +169,11 @@ void FreeSound (void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
pDS = NULL;
|
pDS = NULL;
|
||||||
pDSBuf = NULL;
|
pDSBuf = NULL;
|
||||||
pDSPBuf = NULL;
|
pDSPBuf = NULL;
|
||||||
|
#endif
|
||||||
hWaveOut = 0;
|
hWaveOut = 0;
|
||||||
hData = 0;
|
hData = 0;
|
||||||
hWaveHdr = 0;
|
hWaveHdr = 0;
|
||||||
|
@ -178,6 +191,7 @@ SNDDMA_InitDirect
|
||||||
Direct-Sound support
|
Direct-Sound support
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
sndinitstat SNDDMA_InitDirect (void)
|
sndinitstat SNDDMA_InitDirect (void)
|
||||||
{
|
{
|
||||||
DSBUFFERDESC dsbuf;
|
DSBUFFERDESC dsbuf;
|
||||||
|
@ -414,6 +428,7 @@ sndinitstat SNDDMA_InitDirect (void)
|
||||||
|
|
||||||
return SIS_SUCCESS;
|
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;
|
sndinitstat stat;
|
||||||
|
|
||||||
|
@ -569,6 +584,7 @@ int SNDDMA_Init(void)
|
||||||
|
|
||||||
stat = SIS_FAILURE; // assume DirectSound won't initialize
|
stat = SIS_FAILURE; // assume DirectSound won't initialize
|
||||||
|
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
/* Init DirectSound */
|
/* Init DirectSound */
|
||||||
if (!wavonly)
|
if (!wavonly)
|
||||||
{
|
{
|
||||||
|
@ -590,6 +606,7 @@ int SNDDMA_Init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// if DirectSound didn't succeed in initializing, try to initialize
|
// if DirectSound didn't succeed in initializing, try to initialize
|
||||||
// waveOut sound, unless DirectSound failed because the hardware is
|
// 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)
|
int SNDDMA_GetDMAPos(void)
|
||||||
{
|
{
|
||||||
MMTIME mmtime;
|
|
||||||
int s;
|
int s;
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
|
MMTIME mmtime;
|
||||||
DWORD dwWrite;
|
DWORD dwWrite;
|
||||||
|
|
||||||
if (dsound_init)
|
if (dsound_init)
|
||||||
|
@ -647,9 +665,9 @@ int SNDDMA_GetDMAPos(void)
|
||||||
mmtime.wType = TIME_SAMPLES;
|
mmtime.wType = TIME_SAMPLES;
|
||||||
pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &mmtime.u.sample, &dwWrite);
|
pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &mmtime.u.sample, &dwWrite);
|
||||||
s = mmtime.u.sample - mmstarttime.u.sample;
|
s = mmtime.u.sample - mmstarttime.u.sample;
|
||||||
}
|
} else
|
||||||
else if (wav_init)
|
#endif /* HAVE_DSOUND */
|
||||||
{
|
if (wav_init) {
|
||||||
s = snd_sent * WAV_BUFFER_SIZE;
|
s = snd_sent * WAV_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#ifndef SERVERONLY
|
#ifndef SERVERONLY
|
||||||
#include <ddraw.h>
|
#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
|
#ifndef GLQUAKE
|
||||||
#include <mgraph.h>
|
//#include <mgraph.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -47,8 +53,10 @@ extern LPDIRECTDRAWSURFACE lpPrimary;
|
||||||
extern LPDIRECTDRAWSURFACE lpFrontBuffer;
|
extern LPDIRECTDRAWSURFACE lpFrontBuffer;
|
||||||
extern LPDIRECTDRAWSURFACE lpBackBuffer;
|
extern LPDIRECTDRAWSURFACE lpBackBuffer;
|
||||||
extern LPDIRECTDRAWPALETTE lpDDPal;
|
extern LPDIRECTDRAWPALETTE lpDDPal;
|
||||||
|
#ifdef HAVE_DSOUND
|
||||||
extern LPDIRECTSOUND pDS;
|
extern LPDIRECTSOUND pDS;
|
||||||
extern LPDIRECTSOUNDBUFFER pDSBuf;
|
extern LPDIRECTSOUNDBUFFER pDSBuf;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern DWORD gSndBufSize;
|
extern DWORD gSndBufSize;
|
||||||
//#define SNDBUFSIZE 65536
|
//#define SNDBUFSIZE 65536
|
||||||
|
|
86
configure.in
86
configure.in
|
@ -12,6 +12,11 @@ AC_PROG_CC
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
AC_PROG_MAKE_SET
|
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
|
dnl checks for compiler characteristics
|
||||||
AC_C_BIGENDIAN
|
AC_C_BIGENDIAN
|
||||||
|
|
||||||
|
@ -351,24 +356,73 @@ AC_SUBST(INTEL_ARCH)
|
||||||
#
|
#
|
||||||
# Sound available?
|
# Sound available?
|
||||||
#
|
#
|
||||||
|
|
||||||
|
dnl Check for sound libraries
|
||||||
|
AC_CHECK_LIB(mme,waveOutOpen,HAVE_LIBMME=yes)
|
||||||
|
|
||||||
SND_LIBS=""
|
SND_LIBS=""
|
||||||
AC_MSG_CHECKING(for sound support)
|
AC_MSG_CHECKING(for sound support)
|
||||||
case "${target}" in
|
|
||||||
changequote(,)dnl
|
SND_STYLE=""
|
||||||
i[34567]86-*-linux-gnu*)
|
if test "x$ac_cv_header_sys_soundcard_h" = "xyes"; then
|
||||||
SND_STYLE="Linux" ;;
|
AC_EGREP_CPP([QF_maGiC_VALUE],[
|
||||||
*-solaris*)
|
#include <sys/soundcard.h>
|
||||||
SND_STYLE="Solaris" ;;
|
#ifdef SNDCTL_DSP_SETTRIGGER
|
||||||
*-dec-osf[34]*)
|
QF_maGiC_VALUE
|
||||||
SND_STYLE="MME"
|
#endif
|
||||||
SND_LIBS="-lmme"
|
], SND_STYLE="OSS")
|
||||||
;;
|
fi
|
||||||
*)
|
if test -z "$SND_STYLE" -a "x$ac_cv_header_linux_soundcard_h" = "xyes"; then
|
||||||
SND_STYLE="Null" ;;
|
AC_EGREP_CPP([QF_maGiC_VALUE],[
|
||||||
# XXX - need to add dos, Windows
|
#include <linux/soundcard.h>
|
||||||
changequote([,])dnl
|
#ifdef SNDCTL_DSP_SETTRIGGER
|
||||||
esac
|
QF_maGiC_VALUE
|
||||||
if test "x$SND_STYLE" = xNull; then
|
#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)
|
AC_MSG_RESULT(no)
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(yes ($SND_STYLE style))
|
AC_MSG_RESULT(yes ($SND_STYLE style))
|
||||||
|
|
|
@ -112,8 +112,8 @@ CD_AUDIO_SRC = cd_wrapper.c
|
||||||
SND_STYLE = @SND_STYLE@
|
SND_STYLE = @SND_STYLE@
|
||||||
SND_SRC = snd_null.c
|
SND_SRC = snd_null.c
|
||||||
|
|
||||||
ifeq ($(SND_STYLE),Linux)
|
ifeq ($(SND_STYLE),OSS)
|
||||||
SND_SRC = snd_dma.c snd_linux.c snd_mixa.s
|
SND_SRC = snd_dma.c snd_oss.c
|
||||||
endif
|
endif
|
||||||
ifeq ($(SND_STYLE),Solaris)
|
ifeq ($(SND_STYLE),Solaris)
|
||||||
SND_SRC = snd_dma.c snd_sun.c
|
SND_SRC = snd_dma.c snd_sun.c
|
||||||
|
@ -121,8 +121,11 @@ endif
|
||||||
ifeq ($(SND_STYLE),MME)
|
ifeq ($(SND_STYLE),MME)
|
||||||
SND_SRC = snd_dma.c snd_mme.c
|
SND_SRC = snd_dma.c snd_mme.c
|
||||||
endif
|
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@
|
X11_VID_SRC = @X11_VID_SRC@
|
||||||
QW_X11_VID_SRC = vid_x.c
|
QW_X11_VID_SRC = vid_x.c
|
||||||
|
|
|
@ -108,8 +108,8 @@ CD_AUDIO_SRC = cd_wrapper.c
|
||||||
SND_STYLE = @SND_STYLE@
|
SND_STYLE = @SND_STYLE@
|
||||||
SND_SRC = snd_null.c
|
SND_SRC = snd_null.c
|
||||||
|
|
||||||
ifeq ($(SND_STYLE),Linux)
|
ifeq ($(SND_STYLE),OSS)
|
||||||
SND_SRC = snd_dma.c snd_linux.c snd_mixa.s
|
SND_SRC = snd_dma.c snd_oss.c
|
||||||
endif
|
endif
|
||||||
ifeq ($(SND_STYLE),Solaris)
|
ifeq ($(SND_STYLE),Solaris)
|
||||||
SND_SRC = snd_dma.c snd_sun.c
|
SND_SRC = snd_dma.c snd_sun.c
|
||||||
|
@ -117,8 +117,11 @@ endif
|
||||||
ifeq ($(SND_STYLE),MME)
|
ifeq ($(SND_STYLE),MME)
|
||||||
SND_SRC = snd_dma.c snd_mme.c
|
SND_SRC = snd_dma.c snd_mme.c
|
||||||
endif
|
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
|
# x11 vid
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue