mirror of
https://git.code.sf.net/p/quake/quake2forge
synced 2024-11-10 07:12:01 +00:00
- Added alsa driver from icculus's tree.
- Updated configure.in and src/Makefile.am with magical bits for alsa, oss, and some misc cleanups. - Added magic bootstrapping makefile.
This commit is contained in:
parent
dfe1f0859e
commit
e4385048dc
4 changed files with 379 additions and 32 deletions
28
GNUmakefile
Normal file
28
GNUmakefile
Normal file
|
@ -0,0 +1,28 @@
|
|||
include Makefile
|
||||
|
||||
ifeq ($(ACLOCAL),)
|
||||
|
||||
all: Makefile
|
||||
$(MAKE) -f Makefile $(MAKECMDGOALS)
|
||||
|
||||
.FORCED: all
|
||||
|
||||
Makefile: configure
|
||||
./configure --enable-maintainer-mode --prefix=$(HOME)/quake2 --disable-joystick
|
||||
|
||||
configure: Makefile.in configure.in config.h.in
|
||||
autoconf
|
||||
|
||||
Makefile.in: ltmain.sh configure.in Makefile.am config.h.in
|
||||
automake --foreign --add-missing --copy
|
||||
|
||||
ltmain.sh: config.h.in configure.in Makefile.am
|
||||
libtoolize --copy --automake
|
||||
|
||||
config.h.in: configure.in aclocal.m4
|
||||
autoheader
|
||||
|
||||
aclocal.m4: configure.in
|
||||
aclocal
|
||||
|
||||
endif
|
149
configure.in
149
configure.in
|
@ -1,4 +1,3 @@
|
|||
dnl $Id$
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
dnl stick the revision info into the resulting configure script
|
||||
|
@ -71,10 +70,12 @@ else
|
|||
AC_SUBST(SYSTEM_LIBS)
|
||||
fi
|
||||
|
||||
dnl Check for ossaudio on NetBSD
|
||||
OSS_LIBS=""
|
||||
AC_CHECK_LIB([ossaudio], [_oss_ioctl], [OSS_LIBS="-lossaudio"])
|
||||
AC_SUBST(OSS_LIBS)
|
||||
dnl -----------------------------
|
||||
dnl checks for graphics libraries
|
||||
dnl -----------------------------
|
||||
|
||||
AC_MSG_CHECKING([available graphics options])
|
||||
AC_MSG_RESULT([])
|
||||
|
||||
dnl -----------------
|
||||
dnl Check for SVGAlib
|
||||
|
@ -103,7 +104,7 @@ if test "x${ac_with_svgalib}" != xno ; then
|
|||
SVGALIB_LIBS="$SVGALIB_LIBS -L$withval/lib"
|
||||
fi
|
||||
|
||||
# set CPPFLAGS for the coming tests
|
||||
# save and set CPPFLAGS for the coming tests
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $SVGALIB_CFLAGS"
|
||||
|
||||
|
@ -135,7 +136,7 @@ if test "x${ac_with_svgalib}" != xno ; then
|
|||
AC_MSG_WARN([
|
||||
*** You have explicitly asked for SVGAlib support, but the required libraries
|
||||
*** and development files could not be found.
|
||||
*** SVGAlib based refreshers will NOT be built])
|
||||
*** SVGAlib based refreshers will NOT be built.])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -224,7 +225,7 @@ if test "x${ac_with_opengl}" != xno ; then
|
|||
OPENGL_CFLAGS="$OPENGL_CFLAGS -I$withval/include"
|
||||
OPENGL_LIBS="$OPENGL_CFLAGS -L$withval/lib"
|
||||
fi
|
||||
# set CPPFLAGS for coming tests
|
||||
# save and set CPPFLAGS for coming tests
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $OPENGL_CFLAGS"
|
||||
|
||||
|
@ -273,7 +274,7 @@ if test "x${ac_with_opengl}" != xno ; then
|
|||
AC_MSG_WARN([
|
||||
*** You have explicitly asked for OpenGL support, but the required libraries
|
||||
*** and development files could not be found.
|
||||
*** OpenGL based refreshers will NOT be built])
|
||||
*** OpenGL based refreshers will NOT be built.])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -308,6 +309,23 @@ dnl ---------------------
|
|||
|
||||
HAVE_ZIP=disabled
|
||||
|
||||
dnl --------------------------
|
||||
dnl Checks for sound libraries
|
||||
dnl --------------------------
|
||||
|
||||
AC_MSG_CHECKING([available sound options])
|
||||
AC_MSG_RESULT([])
|
||||
|
||||
dnl ------------------
|
||||
dnl Check for ossaudio
|
||||
dnl ------------------
|
||||
|
||||
OSS_CFLAGS=""
|
||||
OSS_LIBS=""
|
||||
AC_CHECK_LIB([ossaudio], [_oss_ioctl], [OSS_LIBS="-lossaudio"])
|
||||
AC_SUBST(OSS_CFLAGS)
|
||||
AC_SUBST(OSS_LIBS)
|
||||
|
||||
dnl ---------------
|
||||
dnl Check for libao
|
||||
dnl ---------------
|
||||
|
@ -330,7 +348,7 @@ if test "x${ac_with_ao}" != xno ; then
|
|||
AO_CFLAGS="$AO_CFLAGS -I$withval/include"
|
||||
AO_LIBS="$AO_LIBS -L$withval/lib"
|
||||
fi
|
||||
dnl set CPPFLAGS for coming tests
|
||||
dnl save and set CPPFLAGS for coming tests
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $AO_CFLAGS"
|
||||
dnl test for installed library first, for people who may have
|
||||
|
@ -357,7 +375,8 @@ if test "x${ac_with_ao}" != xno ; then
|
|||
if test "x${ac_with_ao}" = xyes ; then
|
||||
AC_MSG_WARN([
|
||||
*** You have explicitly asked for libao support, but the required libraries
|
||||
*** and development files could not be found.])
|
||||
*** and development files could not be found.
|
||||
*** libao audio driver will NOT be built.])
|
||||
fi
|
||||
fi
|
||||
dnl clean up
|
||||
|
@ -365,6 +384,68 @@ if test "x${ac_with_ao}" != xno ; then
|
|||
else
|
||||
HAVE_AO=disabled
|
||||
fi
|
||||
AM_CONDITIONAL(USE_AO, test "x$HAVE_AO" = xyes)
|
||||
|
||||
dnl --------------
|
||||
dnl Check for ALSA
|
||||
dnl --------------
|
||||
|
||||
HAVE_ALSA=no
|
||||
AC_ARG_WITH(alsa,
|
||||
AC_HELP_STRING([--with-alsa(=DIR)],
|
||||
[use alsa (optionally, found in DIR)]),
|
||||
dnl argument was given, check for --without
|
||||
if test "x${with_alsa}" != xno ; then
|
||||
ac_with_alsa=yes
|
||||
else
|
||||
ac_with_alsa=no
|
||||
fi,
|
||||
ac_with_alsa=auto
|
||||
)
|
||||
if test "x${ac_with_alsa}" != xno ; then
|
||||
dnl --with-alsa was explicitly given, so look in the given dir
|
||||
if test "x${ac_with_alsa}" != xauto ; then
|
||||
ALSA_CFLAGS="$ALSA_CFLAGS -I$withval/include"
|
||||
ALSA_LIBS="$ALSA_LIBS -L$withval/lib"
|
||||
fi
|
||||
dnl save and set CPPFLAGS for coming tests
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $ALSA_CFLAGS"
|
||||
dnl test for installed library first, for people who may have
|
||||
dnl the libs installed but no headers
|
||||
AC_CHECK_LIB(asound, snd_pcm_open,
|
||||
ALSA_LIBS="$ALSA_LIBS -lasound"
|
||||
HAVE_ALSA=maybe,
|
||||
HAVE_ALSA=no,
|
||||
[$ALSA_LIBS])
|
||||
dnl check the header
|
||||
if test "x$HAVE_ALSA" = xmaybe ; then
|
||||
AC_CHECK_HEADER(sys/asoundlib.h,
|
||||
HAVE_ALSA=yes,
|
||||
HAVE_ALSA=no
|
||||
)
|
||||
fi
|
||||
dnl sum up
|
||||
if test "x$HAVE_ALSA" = xyes ; then
|
||||
AC_DEFINE(HAVE_ALSA, 1, [Define this if you have ALSA])
|
||||
AC_SUBST(ALSA_CFLAGS)
|
||||
AC_SUBST(ALSA_LIBS)
|
||||
else
|
||||
dnl if we were explicitly told to use alsa and it's not there
|
||||
if test "x${ac_with_alsa}" = xyes ; then
|
||||
AC_MSG_WARN([
|
||||
*** You have explicitly asked for ALSA support, but the required libraries
|
||||
*** and development files could not be found.
|
||||
*** ALSA audio driver will NOT be built.])
|
||||
fi
|
||||
fi
|
||||
dnl clean up
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
else
|
||||
HAVE_ALSA=disabled
|
||||
fi
|
||||
AM_CONDITIONAL(USE_ALSA, test "x$HAVE_ALSA" = xyes)
|
||||
|
||||
|
||||
dnl -----------------------
|
||||
dnl Checks for header files
|
||||
|
@ -686,17 +767,11 @@ dnl -----------------------------------------------------------
|
|||
|
||||
if test $quake2_config_ok = no ; then
|
||||
|
||||
dnl AC_MSG_RESULT([
|
||||
dnl Quake2Forge $VERSION: Automatic configuration FAILED.
|
||||
dnl
|
||||
dnl The file config.log has full details.
|
||||
dnl
|
||||
dnl The following required libraries are missing or misconfigured
|
||||
dnl on your system:
|
||||
dnl ])
|
||||
|
||||
dnl if test "x$HAVE_OPENGL" != xyes
|
||||
echo "nothing yet"
|
||||
AC_MSG_RESULT([
|
||||
Quake2Forge $VERSION: Automatic configuration FAILED.
|
||||
|
||||
The file config.log has full details.
|
||||
])
|
||||
|
||||
else
|
||||
|
||||
|
@ -745,8 +820,8 @@ if test "x${ac_with_opengl}" = xyes ; then
|
|||
*** OpenGL was specifically requested but the development files
|
||||
*** and libraries could not be found.
|
||||
])
|
||||
if test "x${with_svgalib}" != xyes ; then
|
||||
AC_MSG_RESULT([*** The path given was `$with_svgalib'.])
|
||||
if test "x${with_opengl}" != xyes ; then
|
||||
AC_MSG_RESULT([*** The path given was `$with_opengl'.])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -755,7 +830,31 @@ AC_MSG_RESULT([ SDL: ............. $HAVE_SDL])
|
|||
dnl AC_MSG_RESULT([ Framebuffer: ..... $HAVE_FB])
|
||||
dnl AC_MSG_RESULT([ AAlib: ........... $HAVE_AA])
|
||||
|
||||
AC_MSG_RESULT([ libao .............. $HAVE_AO])
|
||||
AC_MSG_RESULT([ Audio drivers:])
|
||||
AC_MSG_RESULT([ ALSA ............. $HAVE_ALSA])
|
||||
if test "x${ac_with_alsa}" = xyes ; then
|
||||
if test "x${HAVE_ALSA}" != xyes ; then
|
||||
AC_MSG_RESULT([
|
||||
*** ALSA was specifically requested but the development files
|
||||
*** and libraries could not be found.
|
||||
])
|
||||
if test "x${with_alsa}" != xyes ; then
|
||||
AC_MSG_RESULT([*** The path given was `$with_alsa'.])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT([ libao ............ $HAVE_AO])
|
||||
if test "x${ac_with_ao}" = xyes ; then
|
||||
if test "x${HAVE_AO}" != xyes ; then
|
||||
AC_MSG_RESULT([
|
||||
*** libao was specifically requested but the development files
|
||||
*** and libraries could not be found.
|
||||
])
|
||||
if test "x${with_ao}" != xyes ; then
|
||||
AC_MSG_RESULT([*** The path given was `$with_ao'.])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([
|
||||
Installation directories:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# $Id$
|
||||
|
||||
SUBDIRS = . baseq2 ctf xatrix rogue
|
||||
|
||||
std_cflags = -pipe @WARN_CFLAGS@ @OPT_CFLAGS@
|
||||
|
@ -44,10 +42,18 @@ else
|
|||
QUAKE2_ASM=
|
||||
endif
|
||||
|
||||
if USE_ALSA
|
||||
SOUND = cd.c snd_alsa.c snd_dma.c snd_mix.c snd_mem.c
|
||||
else
|
||||
if USE_AO
|
||||
SOUND = cd.c snd_ao.c snd_dma.c snd_mix.c snd_mem.c
|
||||
else
|
||||
if BUILD_SDLQUAKE2
|
||||
SOUND = cd_sdl.c snd_sdl.c snd_dma.c snd_mix.c snd_mem.c
|
||||
else
|
||||
SOUND = cd.c snd_ao.c snd_dma.c snd_mix.c snd_mem.c
|
||||
SOUND = cd.c snd_oss.c snd_dma.c snd_mix.c snd_mem.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
quake2_SOURCES = main.c q_sh.c vid_menu.c vid_so.c q_glob.c net_udp.c \
|
||||
|
@ -83,17 +89,35 @@ EXTRA_ref_tdfx_la_SOURCES = rw_in_svgalib.c gl_fxmesa.c
|
|||
EXTRA_ref_softx_la_SOURCES = rw_x11.c
|
||||
|
||||
EXTRA_quake2_SOURCES = snd_mixa.S cd_sdl.c snd_sdl.c snd_dma.c \
|
||||
snd_mix.c snd_mem.c cd.c snd_ao.c
|
||||
snd_mix.c snd_mem.c cd.c \
|
||||
snd_oss.c snd_ao.c snd_alsa.c
|
||||
|
||||
if USE_ALSA
|
||||
quake2_CFLAGS = $(std_cflags) @ALSA_CFLAGS@
|
||||
else
|
||||
if USE_AO
|
||||
quake2_CFLAGS = $(std_cflags) @AO_CFLAGS@
|
||||
else
|
||||
if BUILD_SDLQUAKE2
|
||||
quake2_CFLAGS = $(std_cflags) @SDL_CFLAGS@
|
||||
else
|
||||
quake2_CFLAGS = $(std_cflags)
|
||||
quake2_CFLAGS = $(std_cflags) @OSS_CFLAGS@
|
||||
endif
|
||||
if BUILD_SDLQUAKE2
|
||||
quake2_LDADD = @DL_LIBS@ @AO_LIBS@ @SDL_LIBS@ @SYSTEM_LIBS@ -lm
|
||||
endif
|
||||
endif
|
||||
|
||||
if USE_ALSA
|
||||
quake2_LDADD = @DL_LIBS@ @ALSA_LIBS@ @SYSTEM_LIBS@ -lm
|
||||
else
|
||||
if USE_AO
|
||||
quake2_LDADD = @DL_LIBS@ @AO_LIBS@ @SYSTEM_LIBS@ -lm
|
||||
else
|
||||
if BUILD_SDLQUAKE2
|
||||
quake2_LDADD = @DL_LIBS@ @SDL_LIBS@ @SYSTEM_LIBS@ -lm
|
||||
else
|
||||
quake2_LDADD = @DL_LIBS@ @OSS_LIBS@ @SYSTEM_LIBS@ -lm
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# ref_glx
|
||||
|
|
196
src/snd_alsa.c
Normal file
196
src/snd_alsa.c
Normal file
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
snd_alsa.c
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include "client.h"
|
||||
#include "snd_loc.h"
|
||||
#define snd_buf (dma.samples * 2)
|
||||
|
||||
static int snd_inited;
|
||||
static char *buffer;
|
||||
|
||||
static snd_pcm_t *playback_handle;
|
||||
static snd_pcm_hw_params_t *hw_params;
|
||||
|
||||
cvar_t *sndbits;
|
||||
cvar_t *sndspeed;
|
||||
cvar_t *sndchannels;
|
||||
cvar_t *snddevice;
|
||||
|
||||
static int tryrates[] = { 44100, 22051, 11025, 8000 };
|
||||
|
||||
qboolean SNDDMA_Init (void)
|
||||
{
|
||||
int i;
|
||||
int err;
|
||||
|
||||
if (!snddevice) {
|
||||
sndbits = Cvar_Get("sndbits", "16", CVAR_ARCHIVE);
|
||||
sndspeed = Cvar_Get("sndspeed", "0", CVAR_ARCHIVE);
|
||||
sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
|
||||
snddevice = Cvar_Get("snddevice", "default", CVAR_ARCHIVE);
|
||||
}
|
||||
|
||||
err = snd_pcm_open(&playback_handle, snddevice->string,
|
||||
SND_PCM_STREAM_PLAYBACK, 0);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error, cannot open device %s (%s)\n",
|
||||
snddevice->string,
|
||||
snd_strerror(err));
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_malloc(&hw_params);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error, cannot allocate hw params (%s)\n",
|
||||
snd_strerror(err));
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_any (playback_handle, hw_params);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error, cannot init hw params (%s)\n",
|
||||
snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_access(playback_handle, hw_params,
|
||||
SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error, cannot set access (%s)\n",
|
||||
snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dma.samplebits = sndbits->value;
|
||||
if (dma.samplebits == 16 || dma.samplebits != 8) {
|
||||
err = snd_pcm_hw_params_set_format(playback_handle, hw_params,
|
||||
SND_PCM_FORMAT_S16_LE);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error, 16 bit sound not supported, trying 8\n");
|
||||
dma.samplebits = 8;
|
||||
}
|
||||
}
|
||||
if (dma.samplebits == 8) {
|
||||
err = snd_pcm_hw_params_set_format(playback_handle, hw_params,
|
||||
SND_PCM_FORMAT_U8);
|
||||
}
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error, cannot set sample format (%s)\n",
|
||||
snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dma.speed = (int)sndspeed->value;
|
||||
if (!dma.speed) {
|
||||
for (i=0 ; i<sizeof(tryrates)/4 ; i++) {
|
||||
int test = tryrates[i];
|
||||
err = snd_pcm_hw_params_set_rate_near(playback_handle, hw_params,
|
||||
&test, 0);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error, cannot set sample rate %d (%s)\n",
|
||||
tryrates[i], snd_strerror(err));
|
||||
}
|
||||
else {
|
||||
dma.speed = test;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dma.speed) {
|
||||
Com_Printf("ALSA snd error couldn't set rate.\n");
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dma.channels = (int)sndchannels->value;
|
||||
if (dma.channels < 1 || dma.channels > 2)
|
||||
dma.channels = 2;
|
||||
err = snd_pcm_hw_params_set_channels(playback_handle,hw_params,dma.channels);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error couldn't set channels %d (%s).\n",
|
||||
dma.channels, snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params(playback_handle, hw_params);
|
||||
if (err < 0) {
|
||||
Com_Printf("ALSA snd error couldn't set params (%s).\n",snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dma.samplepos = 0;
|
||||
dma.submission_chunk = 1;
|
||||
dma.buffer = buffer;
|
||||
|
||||
snd_inited = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
SNDDMA_GetDMAPos (void)
|
||||
{
|
||||
if(snd_inited)
|
||||
return dma.samplepos;
|
||||
else
|
||||
Com_Printf ("Sound not inizialized\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SNDDMA_Shutdown (void)
|
||||
{
|
||||
if (snd_inited) {
|
||||
snd_pcm_close(playback_handle);
|
||||
snd_inited = 0;
|
||||
}
|
||||
free(dma.buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
SNDDMA_Submit
|
||||
Send sound to device if buffer isn't really the dma buffer
|
||||
*/
|
||||
void
|
||||
SNDDMA_Submit (void)
|
||||
{
|
||||
int written;
|
||||
|
||||
if(!snd_inited)
|
||||
return;
|
||||
|
||||
written = snd_pcm_writei(playback_handle, dma.buffer, snd_buf);
|
||||
dma.samplepos+=(written / (dma.samplebits / 8));
|
||||
}
|
||||
|
||||
|
||||
void SNDDMA_BeginPainting(void)
|
||||
{
|
||||
}
|
Loading…
Reference in a new issue