Sound now uses runtime plugins. Much thanks to Deek for doing all the

thinking :)
set fs_pluginpath to point to the right dir, and set snd_plugin to pick a sound
plugin.

Current issues:
- alsa 0.5 won't build properly, dunno why
- segfault on exit.  I think I know the cause of this, and how to fix it
- alsa 0.9, gus, sgi, sun, and win32 havn't been tested
This commit is contained in:
Adam Olsen 2001-05-19 00:05:35 +00:00
parent 378adbf8f6
commit 9cc30959e4
21 changed files with 1074 additions and 239 deletions

View file

@ -754,59 +754,47 @@ dnl ==================================================================
AC_CHECK_LIB(mme, waveOutOpen, HAVE_LIBMME=yes) AC_CHECK_LIB(mme, waveOutOpen, HAVE_LIBMME=yes)
AC_ARG_ENABLE(alsa, AC_ARG_ENABLE(alsa,
[ --enable-alsa enable checks for ALSA support], [ --disable-alsa disable checks for ALSA support])
)
AC_ARG_ENABLE(sound, AC_ARG_ENABLE(sound,
[ --disable-sound disable sound outright], [ --disable-sound disable sound outright]
) )
SNDTYPE="" SOUND_TYPES=
SOUND_LIBS=""
SOUND_CFLAGS=""
AC_MSG_CHECKING(for sound support) AC_MSG_CHECKING(for sound support)
dnl SDL digital audio if test "x$enable_alsa" != "xno" -a \
AC_ARG_ENABLE(sdl-audio, "x$ac_cv_header_sys_asoundlib_h" = "xyes"; then
[ --enable-sdl-audio use SDL for audio output], AC_EGREP_CPP([QF_maGiC_VALUE],
if test -z "$SNDTYPE" -a "x$HAVE_SDL" = "xyes"; then [
SNDTYPE="SDL" #include <sys/asoundlib.h>
SOUND_LIBS="$SDL_LIBS" #if defined(SND_LIB_MAJOR) && defined(SND_LIB_MINOR)
SOUND_CFLAGS="$SDL_CFLAGS" #if SND_LIB_MAJOR > 0 || (SND_LIB_MAJOR == 0 && SND_LIB_MINOR == 5)
fi QF_maGiC_VALUE
) #endif
#endif
if test "x$enable_alsa" = "xyes"; then ],
if test -z "$SNDTYPE" -a "x$ac_cv_header_sys_asoundlib_h" = "xyes"; then SOUND_TYPES="$SOUND_TYPES ALSA0.5"
ALSA_LIBS="-lasound",
AC_EGREP_CPP([QF_maGiC_VALUE], AC_EGREP_CPP([QF_maGiC_VALUE],
[ [
#include <sys/asoundlib.h> #include <sys/asoundlib.h>
#if defined(SND_LIB_MAJOR) && defined(SND_LIB_MINOR) #if defined(SND_LIB_MAJOR) && defined(SND_LIB_MINOR)
#if SND_LIB_MAJOR>0 || (SND_LIB_MAJOR==0 && SND_LIB_MINOR==5) #if SND_LIB_MAJOR > 0 || (SND_LIB_MAJOR == 0 && SND_LIB_MINOR >= 9)
QF_maGiC_VALUE QF_maGiC_VALUE
#endif #endif
#endif #endif
], ],
SNDTYPE="ALSA_0_5" SOUND_TYPES="$SOUND_TYPES ALSA0.9"
SOUND_LIBS="-lasound", ALSA_LIBS="-lasound"
AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <sys/asoundlib.h>
#if defined(SND_LIB_MAJOR) && defined(SND_LIB_MINOR)
#if SND_LIB_MAJOR>0 || (SND_LIB_MAJOR==0 && SND_LIB_MINOR>=9)
QF_maGiC_VALUE
#endif
#endif
],
SNDTYPE="ALSA_0_9"
SOUND_LIBS="-lasound"
)
) )
fi )
fi fi
AC_SUBST(ALSA_LIBS)
dnl MME dnl MME
if test -z "$SNDTYPE" -a "x$ac_cv_header_mme_mmsystem_h" = "xyes" -a "x$HAVE_LIBMME" = "xyes"; then if test "x$ac_cv_header_mme_mmsystem_h" = "xyes" -a \
"x$HAVE_LIBMME" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE], AC_EGREP_CPP([QF_maGiC_VALUE],
[ [
#include <mme/mmsystem.h> #include <mme/mmsystem.h>
@ -814,96 +802,119 @@ if test -z "$SNDTYPE" -a "x$ac_cv_header_mme_mmsystem_h" = "xyes" -a "x$HAVE_LIB
QF_maGiC_VALUE QF_maGiC_VALUE
#endif #endif
], ],
SNDTYPE="MME" SOUND_TYPES="$SOUND_TYPES MME"
SOUND_LIBS="-lmme" MME_LIBS="-lmme"
) )
fi fi
AC_SUBST(MME_LIBS)
dnl OSS dnl OSS
if test -z "$SNDTYPE" -a "x$ac_cv_header_sys_soundcard_h" = "xyes"; then if test "x$ac_cv_header_sys_soundcard_h" = "xyes" -o \
AC_EGREP_CPP([QF_maGiC_VALUE],[ "x$ac_cv_header_machine_soundcard_h" = "xyes" -o \
"x$ac_cv_header_linux_soundcard_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <sys/soundcard.h> #include <sys/soundcard.h>
#ifdef SNDCTL_DSP_SETTRIGGER #ifdef SNDCTL_DSP_SETTRIGGER
QF_maGiC_VALUE QF_maGiC_VALUE
#endif #endif
], SNDTYPE="OSS") ],
fi SOUND_TYPES="$SOUND_TYPES OSS",
if test -z "$SNDTYPE" -a "x$ac_cv_header_linux_soundcard_h" = "xyes"; then AC_EGREP_CPP([QF_maGiC_VALUE],
AC_EGREP_CPP([QF_maGiC_VALUE],[ [
#include <linux/soundcard.h> #include <linux/soundcard.h>
#ifdef SNDCTL_DSP_SETTRIGGER #ifdef SNDCTL_DSP_SETTRIGGER
QF_maGiC_VALUE QF_maGiC_VALUE
#endif #endif
], SNDTYPE="OSS") ],
fi SOUND_TYPES="$SOUND_TYPES OSS",
if test -z "$SNDTYPE" -a "x$ac_cv_header_machine_soundcard_h" = "xyes"; then AC_EGREP_CPP([QF_maGiC_VALUE],
AC_EGREP_CPP([QF_maGiC_VALUE],[ [
#include <machine/soundcard.h> #include <machine/soundcard.h>
#ifdef SNDCTL_DSP_SETTRIGGER #ifdef SNDCTL_DSP_SETTRIGGER
QF_maGiC_VALUE QF_maGiC_VALUE
#endif #endif
], SNDTYPE="OSS") ],
SOUND_TYPES="$SOUND_TYPES OSS"
)
)
)
fi fi
dnl SDL digital audio
AC_ARG_ENABLE(sdl-audio,
[ --enable-sdl-audio use SDL for audio output],
if test "x$HAVE_SDL" = "xyes"; then
SOUND_TYPES="$SOUND_TYPES SDL"
fi
)
dnl SGI dnl SGI
if test -z "$SNDTYPE" -a "x$ac_cv_header_dmedia_audio_h" = "xyes"; then if test "x$ac_cv_header_dmedia_audio_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[ AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <dmedia/audio.h> #include <dmedia/audio.h>
#ifdef AL_SAMPLE_16 #ifdef AL_SAMPLE_16
#ifdef AL_RATE # ifdef AL_RATE
QF_maGiC_VALUE QF_maGiC_VALUE
# endif
#endif #endif
#endif ],
], SNDTYPE="SGI" SOUND_LIBS="-laudio") SOUND_TYPES="$SOUND_TYPES SGI"
SGISND_LIBS="-laudio")
fi fi
AC_SUBST(SGISND_LIBS)
dnl Sun dnl Sun
if test -z "$SNDTYPE" -a "x$ac_cv_header_sys_audioio_h" = "xyes"; then if test "x$ac_cv_header_sys_audioio_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[ AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <sys/audioio.h> #include <sys/audioio.h>
#ifdef AUDIO_SETINFO #ifdef AUDIO_SETINFO
QF_maGiC_VALUE QF_maGiC_VALUE
#endif #endif
], SNDTYPE="SUN") ],
SOUND_TYPES="$SOUND_TYPES SUN"
)
fi fi
dnl Win32 dnl Win32
if test -z "$SNDTYPE" -a "x$ac_cv_header_windows_h" = "xyes" -a \ if test "x$ac_cv_header_windows_h" = "xyes" -a \
"x$ac_cv_header_dsound_h" = "xyes"; then "x$ac_cv_header_dsound_h" = "xyes"; then
AC_EGREP_CPP([QF_maGiC_VALUE],[ AC_EGREP_CPP([QF_maGiC_VALUE],
[
#include <windows.h> #include <windows.h>
#include <dsound.h> #include <dsound.h>
#ifdef GMEM_MOVEABLE #ifdef GMEM_MOVEABLE
#ifdef DirectSoundEnumerate # ifdef DirectSoundEnumerate
QF_maGiC_VALUE QF_maGiC_VALUE
# endif
#endif #endif
#endif ],
], SNDTYPE="WIN32" SOUND_TYPES="$SOUND_TYPES Win32"
SOUND_LIBS="-lwinmm") WINSND_LIBS="-lwinmm"
)
fi fi
AC_SUBST(WINSND_LIBS)
if test "x$enable_sound" = "xno"; then if test "x$enable_sound" = "xno"; then
SNDTYPE="" SOUND_TYPES=""
SOUND_LIBS=""
fi fi
if test "$SNDTYPE"; then AM_CONDITIONAL(HAVE_SND_ALSA_0_5, test "`echo $SOUND_TYPES | grep ALSA0.5`")
AC_MSG_RESULT([yes ($SNDTYPE)]) AM_CONDITIONAL(HAVE_SND_ALSA_0_9, test "`echo $SOUND_TYPES | grep ALSA0.9`")
AM_CONDITIONAL(HAVE_SND_MME, test "`echo $SOUND_TYPES | grep MME`")
AM_CONDITIONAL(HAVE_SND_OSS, test "`echo $SOUND_TYPES | grep OSS`")
AM_CONDITIONAL(HAVE_SND_SDL, test "`echo $SOUND_TYPES | grep SDL`")
AM_CONDITIONAL(HAVE_SND_SGI, test "`echo $SOUND_TYPES | grep SGI`")
AM_CONDITIONAL(HAVE_SND_SUN, test "`echo $SOUND_TYPES | grep SUN`")
AM_CONDITIONAL(HAVE_SND_WIN32, test "`echo $SOUND_TYPES | grep Win32`")
if test "$SOUND_TYPES"; then
AC_MSG_RESULT([$SOUND_TYPES])
else else
AC_MSG_RESULT([no, using null sound driver]) AC_MSG_RESULT([no, using null sound driver])
fi fi
AC_SUBST(SOUND_LIBS)
AC_SUBST(SOUND_CFLAGS)
AM_CONDITIONAL(SNDTYPE_ALSA_0_5, test "$SNDTYPE" = "ALSA_0_5")
AM_CONDITIONAL(SNDTYPE_ALSA_0_9, test "$SNDTYPE" = "ALSA_0_9")
AM_CONDITIONAL(SNDTYPE_MME, test "$SNDTYPE" = "MME")
AM_CONDITIONAL(SNDTYPE_OSS, test "$SNDTYPE" = "OSS")
AM_CONDITIONAL(SNDTYPE_SDL, test "$SNDTYPE" = "SDL")
AM_CONDITIONAL(SNDTYPE_SGI, test "$SNDTYPE" = "SGI")
AM_CONDITIONAL(SNDTYPE_SUN, test "$SNDTYPE" = "SUN")
AM_CONDITIONAL(SNDTYPE_WIN32, test "$SNDTYPE" = "WIN32")
AM_CONDITIONAL(SNDTYPE_NULL, test "$SNDTYPE" != "ALSA_0_5" -a "$SNDTYPE" != "ALSA_0_9" -a "$SNDTYPE" != "MME" -a "$SNDTYPE" != "OSS" -a "$SNDTYPE" != "SDL" -a "$SNDTYPE" != "SGI" -a "$SNDTYPE" != "SUN" -a "$SNDTYPE" != "WIN32")
dnl Tests for joystick support dnl Tests for joystick support
AC_MSG_CHECKING(for joystick support) AC_MSG_CHECKING(for joystick support)
@ -1142,6 +1153,7 @@ elif test "x$pluginpath" = xno; then
pluginpath="." pluginpath="."
fi fi
AC_DEFINE_UNQUOTED(FS_PLUGINPATH, "$pluginpath") AC_DEFINE_UNQUOTED(FS_PLUGINPATH, "$pluginpath")
AC_SUBST(pluginpath)
dnl CFLAGS for release and devel versions dnl CFLAGS for release and devel versions
CFLAGS="" CFLAGS=""
@ -1180,14 +1192,14 @@ if test "x$optimize" = xyes; then
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
BUILD_TYPE="$BUILD_TYPE Optimize" BUILD_TYPE="$BUILD_TYPE Optimize"
if test "x$GCC" = xyes; then if test "x$GCC" = xyes; then
CFLAGS="$CFLAGS -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations" CFLAGS="$CFLAGS -O3 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations"
AC_MSG_CHECKING(for special compiler settings) AC_MSG_CHECKING(for special compiler settings)
case "${host_cpu}" in case "${host_cpu}" in
i?86) i?86)
if test "x$HAVE_AMD" = "xyes"; then if test "x$HAVE_AMD" = "xyes"; then
MORE_CFLAGS="-march=k6 -malign-loops=2 -malign-jumps=2 -malign-functions=2" MORE_CFLAGS="-march=k6"
else else
MORE_CFLAGS="-march=${host_cpu} -malign-loops=2 -malign-jumps=2 -malign-functions=2" MORE_CFLAGS="-march=${host_cpu}"
fi fi
;; ;;
*) *)
@ -1224,7 +1236,7 @@ AC_ARG_ENABLE(profile,
if test "x$profile" = xyes; then if test "x$profile" = xyes; then
BUILD_TYPE="$BUILD_TYPE Profile" BUILD_TYPE="$BUILD_TYPE Profile"
if test "x$GCC" = xyes; then if test "x$GCC" = xyes; then
CFLAGS="$(echo $CFLAGS | sed -e 's/-fomit-frame-pointer//g') -pg" CFLAGS="`echo $CFLAGS | sed -e 's/-fomit-frame-pointer//g'` -pg"
LDFLAGS="$LDFLAGS -pg" LDFLAGS="$LDFLAGS -pg"
else else
CFLAGS="$CFLAGS -p" CFLAGS="$CFLAGS -p"
@ -1402,6 +1414,7 @@ QW_TARGETS=""
NQ_TARGETS="" NQ_TARGETS=""
CD_TARGETS="" CD_TARGETS=""
SND_TARGETS="" SND_TARGETS=""
SND_PLUGIN_TARGETS=""
VID_TARGETS="" VID_TARGETS=""
BUILD_GL=no BUILD_GL=no
BUILD_SW=no BUILD_SW=no
@ -1479,12 +1492,37 @@ fi
if test -n "$VID_TARGETS"; then if test -n "$VID_TARGETS"; then
CD_TARGETS="libQFcd.la" CD_TARGETS="libQFcd.la"
SND_TARGETS="libQFsound.la" SND_TARGETS="libQFsound.la"
if test "`echo $SOUND_TYPES | grep ALSA0.5`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_alsa0_5.la"
fi
if test "`echo $SOUND_TYPES | grep ALSA0.9`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_alsa0_9.la"
fi
if test "`echo $SOUND_TYPES | grep MME`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_mme.la"
fi
if test "`echo $SOUND_TYPES | grep OSS`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_oss.la"
fi
if test "`echo $SOUND_TYPES | grep SDL`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_sdl.la"
fi
if test "`echo $SOUND_TYPES | grep SGI`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_sgi.la"
fi
if test "`echo $SOUND_TYPES | grep SUN`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_sun.la"
fi
if test "`echo $SOUND_TYPES | grep Win32`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_win.la"
fi
VID_TARGETS="libQFjs.la $VID_TARGETS" VID_TARGETS="libQFjs.la $VID_TARGETS"
fi fi
AC_SUBST(NQ_TARGETS) AC_SUBST(NQ_TARGETS)
AC_SUBST(QW_TARGETS) AC_SUBST(QW_TARGETS)
AC_SUBST(CD_TARGETS) AC_SUBST(CD_TARGETS)
AC_SUBST(SND_TARGETS) AC_SUBST(SND_TARGETS)
AC_SUBST(SND_PLUGIN_TARGETS)
AC_SUBST(VID_TARGETS) AC_SUBST(VID_TARGETS)
AM_CONDITIONAL(BUILD_GL, test "$BUILD_GL" = "yes") AM_CONDITIONAL(BUILD_GL, test "$BUILD_GL" = "yes")
@ -1540,7 +1578,7 @@ AC_MSG_RESULT([
Build type:$BUILD_TYPE Build type:$BUILD_TYPE
Server support: $SV_TARGETS Server support: $SV_TARGETS
Client support:$CL_TARGETS Client support:$CL_TARGETS
Sound system: $SNDTYPE Sound support:$SOUND_TYPES
CD Audio system: $CDTYPE CD Audio system: $CDTYPE
IPv6 networking: $NETTYPE_IPV6 IPv6 networking: $NETTYPE_IPV6
Compression support: $HAVE_ZLIB Compression support: $HAVE_ZLIB
@ -1556,4 +1594,3 @@ if test -d $srcdir/CVS; then
echo "(This is from a development CVS tree. Expect problems)" echo "(This is from a development CVS tree. Expect problems)"
echo echo
fi fi

View file

@ -72,6 +72,9 @@ typedef struct sound_funcs_s {
} sound_funcs_t; } sound_funcs_t;
typedef struct sound_data_s { typedef struct sound_data_s {
struct model_s ***worldmodel;
double *host_frametime;
int *viewentity;
} sound_data_t; } sound_data_t;
#endif // __QF_plugin_sound_h_ #endif // __QF_plugin_sound_h_

View file

@ -2,3 +2,14 @@ SUBDIRS= cd targets
clean-local: clean-local:
rm -f *.a rm -f *.a
INCLUDES= -I$(top_srcdir)/include
lib_LTLIBRARIES = libQFsound.la
libQFsound_la_SOURCES= snd_common.c snd.c
libQFsound_la_LDFLAGS = -version-info 1:0:0
libQFsound.la: $(libQFsound_la_OBJECTS) $(libQFsound_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libQFsound_la_LDFLAGS) $(libQFsound_la_OBJECTS) $(libQFsound_la_LIBADD) $(LIBS)
LIBLIST = libQFsound.la @LIBRARY_SEARCH_PATH@

208
libs/audio/snd.c Normal file
View file

@ -0,0 +1,208 @@
/*
snd_plugin.c
sound plugin wrapper
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 1999,2000 contributors of the QuakeForge project
Please see the file "AUTHORS" for a list of contributors
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 "QF/qtypes.h"
#include "QF/sound.h"
#include "QF/plugin.h"
#include "QF/console.h"
#include "QF/model.h"
// =======================================================================
// Various variables also defined in snd_dma.c
// FIXME - should be put in one place
// =======================================================================
extern channel_t channels[MAX_CHANNELS];
extern int total_channels;
extern volatile dma_t *shm;
extern cvar_t *loadas8bit;
extern int paintedtime; // sample PAIRS
extern qboolean snd_initialized;
extern cvar_t *bgmvolume;
extern cvar_t *volume;
extern cvar_t *snd_interp;
cvar_t *snd_plugin;
plugin_t *sndmodule = NULL;
// FIXME: ewwwies
extern double host_frametime; // From host.h
extern struct model_s **snd_worldmodel;
extern int snd_viewentity;
void
S_Init (void)
{
S_Init_Cvars ();
sndmodule = PI_LoadPlugin ("sound", snd_plugin->string);
if (!sndmodule) {
Con_Printf ("Loading of sound module: %s failed!\n", snd_plugin->string);
}
else {
sndmodule->data->sound->worldmodel = &snd_worldmodel;
sndmodule->data->sound->viewentity = &snd_viewentity;
sndmodule->data->sound->host_frametime = &host_frametime;
sndmodule->functions->general->p_Init ();
}
}
void
S_Init_Cvars (void)
{
volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, NULL,
"Volume level of sounds");
loadas8bit =
Cvar_Get ("loadas8bit", "0", CVAR_NONE, NULL, "Load samples as 8-bit");
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, NULL,
"CD music volume");
snd_interp = Cvar_Get ("snd_interp", "1", CVAR_ARCHIVE, NULL,
"control sample interpolation");
snd_plugin = Cvar_Get ("snd_plugin", "null", CVAR_ARCHIVE, NULL,
"Sound Plugin to use");
}
void
S_AmbientOff (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_AmbientOff ();
}
void
S_AmbientOn (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_AmbientOn ();
}
void
S_Shutdown (void)
{
if (sndmodule) {
sndmodule->functions->general->p_Shutdown ();
PI_UnloadPlugin (sndmodule);
sndmodule = NULL;
}
}
void
S_TouchSound (char *sample)
{
if (sndmodule)
sndmodule->functions->sound->pS_TouchSound (sample);
}
void
S_ClearBuffer (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_ClearBuffer ();
}
void
S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
{
if (sndmodule)
sndmodule->functions->sound->pS_StaticSound (sfx, origin, vol, attenuation);
}
void
S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,
float attenuation)
{
if (sndmodule)
sndmodule->functions->sound->pS_StartSound (entnum, entchannel, sfx, origin, fvol, attenuation);
}
void
S_StopSound (int entnum, int entchannel)
{
if (sndmodule)
sndmodule->functions->sound->pS_StopSound (entnum, entchannel);
}
sfx_t *
S_PrecacheSound (char *sample)
{
if (sndmodule)
return sndmodule->functions->sound->pS_PrecacheSound (sample);
else
return NULL;
}
void
S_ClearPrecache (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_ClearPrecache ();
}
void
S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up)
{
if (sndmodule)
sndmodule->functions->sound->pS_Update (origin, v_forward, v_right, v_up);
}
void
S_StopAllSounds (qboolean clear)
{
if (sndmodule)
sndmodule->functions->sound->pS_StopAllSounds (clear);
}
void
S_BeginPrecaching (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_BeginPrecaching ();
}
void
S_EndPrecaching (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_EndPrecaching ();
}
void
S_ExtraUpdate (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_ExtraUpdate ();
}
void
S_LocalSound (char *s)
{
if (sndmodule)
sndmodule->functions->sound->pS_LocalSound (s);
}

View file

@ -1,44 +1,59 @@
INCLUDES= -I$(top_srcdir)/include $(SOUND_CFLAGS) INCLUDES= -I$(top_srcdir)/include $(ALSA_CFLAGS) $(MME_CFLAGS) $(OSS_CFLAGS) $(SGISND_CFLAGS) $(SUNSND_CFLAGS) $(WIN32SND_CFLAGS) $(SDL_CFLAGS)
lib_LTLIBRARIES = @SND_TARGETS@ lib_LTLIBRARIES = @SND_PLUGIN_TARGETS@ libsound_null.la libsound_disk.la
EXTRA_LTLIBRARIES = libQFsound.la EXTRA_LTLIBRARIES = libsound_sdl.la libsound_alsa0_5.la libsound_alsa0_9.la libsound_mme.la libsound_oss.la libsound_sgi.la libsound_sun.la libsound_win.la
libQFsound_la_LDFLAGS = -version-info 1:0:0 $(CD_LIBS) common_sound_files= snd_dma.c snd_mem.c snd_mix.c snd_mixa.S
# libsound_sdl_la_LDFLAGS= -version-info 1:0:0 $(SDL_LIBS)
# ... Audio targets libsound_alsa0_5_la_LDFLAGS= -version-info 1:0:0 $(ALSA_LIBS)
# libsound_alsa0_9_la_LDFLAGS= -version-info 1:0:0 $(ALSA_LIBS)
common_sound_files= snd_common.c snd_dma.c snd_mem.c snd_mix.c snd_mixa.S libsound_mme_la_LDFLAGS= -version-info 1:0:0 $(MME_LIBS)
if SNDTYPE_SDL libsound_oss_la_LDFLAGS= -version-info 1:0:0 $(OSS_LIBS)
libQFsound_la_SOURCES= $(common_sound_files) snd_sdl.c libsound_sgi_la_LDFLAGS= -version-info 1:0:0 $(SGISND_LIBS)
endif libsound_sun_la_LDFLAGS= -version-info 1:0:0 $(SUN_LIBS)
if SNDTYPE_ALSA_0_5 libsound_win_la_LDFLAGS= -version-info 1:0:0 $(WIN_LIBS)
libQFsound_la_SOURCES= $(common_sound_files) snd_alsa_0_5.c libsound_disk_la_LDFLAGS= -version-info 1:0:0
endif libsound_null_la_LDFLAGS= -version-info 1:0:0
if SNDTYPE_ALSA_0_9
libQFsound_la_SOURCES= $(common_sound_files) snd_alsa_0_9.c
endif
# No idea what this is. it's in configure.in though...
#if SNDTYPE_MME
#libQFsound_la_SOURCES= $(common_sound_files) snd_mme.c
#endif
if SNDTYPE_OSS
libQFsound_la_SOURCES= $(common_sound_files) snd_oss.c
endif
if SNDTYPE_SGI
libQFsound_la_SOURCES= $(common_sound_files) snd_sgi.c
endif
if SNDTYPE_SUN
libQFsound_la_SOURCES= $(common_sound_files) snd_sun.c
endif
if SNDTYPE_WIN32
libQFsound_la_SOURCES= $(common_sound_files) snd_win.c
endif
if SNDTYPE_NULL
libQFsound_la_SOURCES= snd_common.c snd_null.c
endif
libQFsound.la: $(libQFsound_la_OBJECTS) $(libQFsound_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libQFsound_la_LDFLAGS) $(libQFsound_la_OBJECTS) $(libQFsound_la_LIBADD) $(LIBS)
libsound_sdl_la_SOURCES= $(common_sound_files) snd_sdl.c
libsound_sdl.la: $(libsound_sdl_la_OBJECTS) $(libsound_sdl_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_sdl_la_LDFLAGS) $(libsound_sdl_la_OBJECTS) $(libsound_sdl_la_LIBADD) $(LIBS)
LIBLIST = libQFsound.la @LIBRARY_SEARCH_PATH@ libsound_alsa0_5_la_SOURCES= $(common_sound_files) snd_alsa_0_5.c
libsound_alsa0_5.la: $(libsound_alsa0_5_la_OBJECTS) $(libsound_alsa0_5_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_alsa0_5_la_LDFLAGS) $(libsound_ALSA_0_5_la_OBJECTS) $(libsound_alsa0_5_la_LIBADD) $(LIBS)
libsound_alsa0_9_la_SOURCES= $(common_sound_files) snd_alsa_0_9.c
libsound_alsa0_9.la: $(libsound_alsa0_9_la_OBJECTS) $(libsound_alsa0_9_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_alsa0_9_la_LDFLAGS) $(libsound_ALSA_0_5_la_OBJECTS) $(libsound_alsa0_9_la_LIBADD) $(LIBS)
libsound_mme_la_SOURCES= $(common_sound_files) snd_mme.c
libsound_mme.la: $(libsound_mme_la_OBJECTS) $(libsound_mme_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_mme_la_LDFLAGS) $(libsound_mme_la_OBJECTS) $(libsound_mme_la_LIBADD) $(LIBS)
libsound_oss_la_SOURCES= $(common_sound_files) snd_oss.c
libsound_oss.la: $(libsound_oss_la_OBJECTS) $(libsound_oss_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_oss_la_LDFLAGS) $(libsound_oss_la_OBJECTS) $(libsound_oss_la_LIBADD) $(LIBS)
libsound_sgi_la_SOURCES= $(common_sound_files) snd_sgi.c
libsound_sgi.la: $(libsound_sgi_la_OBJECTS) $(libsound_sgi_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_sgi_la_LDFLAGS) $(libsound_sgi_la_OBJECTS) $(libsound_sgi_la_LIBADD) $(LIBS)
libsound_sun_la_SOURCES= $(common_sound_files) snd_sun.c
libsound_sun.la: $(libsound_sun_la_OBJECTS) $(libsound_sun_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_sun_la_LDFLAGS) $(libsound_sun_la_OBJECTS) $(libsound_sun_la_LIBADD) $(LIBS)
libsound_win_la_SOURCES= $(common_sound_files) snd_win.c
libsound_win.la: $(libsound_win_la_OBJECTS) $(libsound_win_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_win_la_LDFLAGS) $(libsound_win_la_OBJECTS) $(libsound_win_la_LIBADD) $(LIBS)
libsound_disk_la_SOURCES= $(common_sound_files) snd_disk.c
libsound_disk.la: $(libsound_disk_la_OBJECTS) $(libsound_disk_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_disk_la_LDFLAGS) $(libsound_disk_la_OBJECTS) $(libsound_disk_la_LIBADD) $(LIBS)
libsound_null_la_SOURCES= snd_null.c
libsound_null.la: $(libsound_null_la_OBJECTS) $(libsound_null_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_null_la_LDFLAGS) $(libsound_null_la_OBJECTS) $(libsound_null_la_LIBADD) $(LIBS)
LIBLIST = $(lib_LTLIBRARIES) @LIBRARY_SEARCH_PATH@

View file

@ -57,6 +57,7 @@
#include "QF/console.h" #include "QF/console.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/plugin.h"
#ifndef MAP_FAILED #ifndef MAP_FAILED
# define MAP_FAILED ((void*)-1) # define MAP_FAILED ((void*)-1)
@ -72,6 +73,32 @@ static snd_pcm_mmap_control_t *mmap_control = NULL;
static char *mmap_data = NULL; static char *mmap_data = NULL;
static int card = -1, dev = -1; static int card = -1, dev = -1;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
int int
check_card (int card) check_card (int card)
{ {
@ -356,3 +383,44 @@ SNDDMA_Submit (void)
break; break;
} }
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "ALSA 0.5.x digital output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}

View file

@ -39,6 +39,7 @@
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/plugin.h"
static int snd_inited; static int snd_inited;
@ -47,6 +48,32 @@ static snd_pcm_t *pcm;
static char *pcmname = NULL; static char *pcmname = NULL;
size_t buffer_size; size_t buffer_size;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
qboolean qboolean
SNDDMA_Init (void) SNDDMA_Init (void)
{ {
@ -283,3 +310,43 @@ SNDDMA_Submit (void)
break; break;
} }
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "ALSA 0.9.x digital output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}

View file

@ -42,10 +42,37 @@
#include "QF/console.h" #include "QF/console.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/plugin.h"
static int snd_inited; static int snd_inited;
QFile *snd_file; QFile *snd_file;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
qboolean qboolean
SNDDMA_Init (void) SNDDMA_Init (void)
{ {
@ -106,3 +133,44 @@ SNDDMA_Submit (void)
Qwrite (snd_file, shm->buffer, count); Qwrite (snd_file, shm->buffer, count);
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "disk output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}

View file

@ -48,13 +48,21 @@
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/plugin.h"
void S_Play (void); void I_S_Play (void);
void S_PlayVol (void); void I_S_PlayVol (void);
void S_SoundList (void); void I_S_SoundList (void);
void S_Update_ (void); void I_S_Update_ (void);
void S_StopAllSounds (qboolean clear); void I_S_StopAllSounds (qboolean clear);
void S_StopAllSoundsC (void); void I_S_StopAllSoundsC (void);
sfx_t *I_S_PrecacheSound (char *name);
sfxcache_t *I_S_LoadSound (sfx_t *s);
void I_S_ClearBuffer (void);
void I_S_PaintChannels (int endtime);
void I_S_Init_Cvars ();
// QuakeWorld hack... // QuakeWorld hack...
//#define viewentity playernum+1 //#define viewentity playernum+1
@ -65,7 +73,7 @@ void S_StopAllSoundsC (void);
extern channel_t channels[MAX_CHANNELS]; extern channel_t channels[MAX_CHANNELS];
extern int total_channels; extern int total_channels;
extern double host_frametime; // From host.h //extern double host_frametime; // From host.h
int snd_blocked = 0; int snd_blocked = 0;
static qboolean snd_ambient = 1; static qboolean snd_ambient = 1;
@ -125,7 +133,7 @@ cvar_t *_snd_mixahead;
// //
// Fake dma is a synchronous faking of the DMA progress used for // Fake dma is a synchronous faking of the DMA progress used for
// isolating performance in the renderer. The fakedma_updates is // isolating performance in the renderer. The fakedma_updates is
// number of times S_Update() is called per second. // number of times I_S_Update() is called per second.
// //
qboolean fakedma = false; qboolean fakedma = false;
@ -133,25 +141,24 @@ int fakedma_updates = 15;
// FIXME: Evil hack that doesn't deserve to see the light of day. // FIXME: Evil hack that doesn't deserve to see the light of day.
// (pending merge of nq and qw client_stat_t's) // (pending merge of nq and qw client_stat_t's)
extern int snd_viewentity; extern sound_data_t plugin_info_sound_data;
extern struct model_s **snd_worldmodel;
void void
S_AmbientOff (void) I_S_AmbientOff (void)
{ {
snd_ambient = false; snd_ambient = false;
} }
void void
S_AmbientOn (void) I_S_AmbientOn (void)
{ {
snd_ambient = true; snd_ambient = true;
} }
void void
S_SoundInfo_f (void) I_S_SoundInfo_f (void)
{ {
if (!sound_started || !shm) { if (!sound_started || !shm) {
Con_Printf ("sound system not started\n"); Con_Printf ("sound system not started\n");
@ -170,11 +177,11 @@ S_SoundInfo_f (void)
/* /*
S_Startup I_S_Startup
*/ */
void void
S_Startup (void) I_S_Startup (void)
{ {
int rc; int rc;
@ -198,25 +205,27 @@ S_Startup (void)
/* /*
S_Init I_S_Init
*/ */
void void
S_Init (void) I_S_Init (void)
{ {
Con_Printf ("\nSound Initialization\n"); Con_Printf ("\nSound Initialization\n");
Cmd_AddCommand ("play", S_Play, Cmd_AddCommand ("play", I_S_Play,
"Play selected sound effect (play pathto/sound.wav)"); "Play selected sound effect (play pathto/sound.wav)");
Cmd_AddCommand ("playvol", S_PlayVol, Cmd_AddCommand ("playvol", I_S_PlayVol,
"Play selected sound effect at selected volume (playvol pathto/sound.wav num"); "Play selected sound effect at selected volume (playvol pathto/sound.wav num");
Cmd_AddCommand ("stopsound", S_StopAllSoundsC, Cmd_AddCommand ("stopsound", I_S_StopAllSoundsC,
"Stops all sounds currently being played"); "Stops all sounds currently being played");
Cmd_AddCommand ("soundlist", S_SoundList, Cmd_AddCommand ("soundlist", I_S_SoundList,
"Reports a list of sounds in the cache"); "Reports a list of sounds in the cache");
Cmd_AddCommand ("soundinfo", S_SoundInfo_f, Cmd_AddCommand ("soundinfo", I_S_SoundInfo_f,
"Report information on the sound system"); "Report information on the sound system");
I_S_Init_Cvars ();
if (COM_CheckParm ("-nosound")) if (COM_CheckParm ("-nosound"))
return; return;
@ -232,7 +241,7 @@ S_Init (void)
snd_initialized = true; snd_initialized = true;
S_Startup (); I_S_Startup ();
if (sound_started == 0) // sound startup failed? Bail out. if (sound_started == 0) // sound startup failed? Bail out.
return; return;
@ -265,14 +274,14 @@ S_Init (void)
// if (shm->buffer) // if (shm->buffer)
// shm->buffer[4] = shm->buffer[5] = 0x7f; // force a pop for debugging // shm->buffer[4] = shm->buffer[5] = 0x7f; // force a pop for debugging
ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav"); ambient_sfx[AMBIENT_WATER] = I_S_PrecacheSound ("ambience/water1.wav");
ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav"); ambient_sfx[AMBIENT_SKY] = I_S_PrecacheSound ("ambience/wind2.wav");
S_StopAllSounds (true); I_S_StopAllSounds (true);
} }
void void
S_Init_Cvars (void) I_S_Init_Cvars (void)
{ {
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL, snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL,
"sound device. \"\" is system default"); "sound device. \"\" is system default");
@ -330,7 +339,7 @@ S_Init_Cvars (void)
// ======================================================================= // =======================================================================
void void
S_Shutdown (void) I_S_Shutdown (void)
{ {
if (!sound_started) if (!sound_started)
@ -353,10 +362,10 @@ S_Shutdown (void)
// ======================================================================= // =======================================================================
/* /*
S_FindName I_S_FindName
*/ */
sfx_t * sfx_t *
S_FindName (char *name) I_S_FindName (char *name)
{ {
int i; int i;
sfx_t *sfx; sfx_t *sfx;
@ -386,36 +395,36 @@ S_FindName (char *name)
/* /*
S_TouchSound I_S_TouchSound
*/ */
void void
S_TouchSound (char *name) I_S_TouchSound (char *name)
{ {
sfx_t *sfx; sfx_t *sfx;
if (!sound_started) if (!sound_started)
return; return;
sfx = S_FindName (name); sfx = I_S_FindName (name);
Cache_Check (&sfx->cache); Cache_Check (&sfx->cache);
} }
/* /*
S_PrecacheSound I_S_PrecacheSound
*/ */
sfx_t * sfx_t *
S_PrecacheSound (char *name) I_S_PrecacheSound (char *name)
{ {
sfx_t *sfx; sfx_t *sfx;
if (!sound_started || nosound->int_val) if (!sound_started || nosound->int_val)
return NULL; return NULL;
sfx = S_FindName (name); sfx = I_S_FindName (name);
// cache it in // cache it in
if (precache->int_val) if (precache->int_val)
S_LoadSound (sfx); I_S_LoadSound (sfx);
return sfx; return sfx;
} }
@ -446,7 +455,7 @@ SND_PickChannel (int entnum, int entchannel)
break; break;
} }
// don't let monster sounds override player sounds // don't let monster sounds override player sounds
if (channels[ch_idx].entnum == snd_viewentity && entnum != snd_viewentity if (channels[ch_idx].entnum == *plugin_info_sound_data.viewentity && entnum != *plugin_info_sound_data.viewentity
&& channels[ch_idx].sfx) && channels[ch_idx].sfx)
continue; continue;
@ -479,7 +488,7 @@ SND_Spatialize (channel_t *ch)
sfx_t *snd; sfx_t *snd;
// anything coming from the view entity will always be full volume // anything coming from the view entity will always be full volume
if (ch->entnum == snd_viewentity) { if (ch->entnum == *plugin_info_sound_data.viewentity) {
ch->leftvol = ch->master_vol; ch->leftvol = ch->master_vol;
ch->rightvol = ch->master_vol; ch->rightvol = ch->master_vol;
ch->phase = 0; ch->phase = 0;
@ -524,7 +533,7 @@ SND_Spatialize (channel_t *ch)
// ======================================================================= // =======================================================================
void void
S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,
float attenuation) float attenuation)
{ {
channel_t *target_chan, *check; channel_t *target_chan, *check;
@ -562,7 +571,7 @@ S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,
return; // not audible at all return; // not audible at all
// new channel // new channel
sc = S_LoadSound (sfx); sc = I_S_LoadSound (sfx);
if (!sc) { if (!sc) {
target_chan->sfx = NULL; target_chan->sfx = NULL;
return; // couldn't load the sound's data return; // couldn't load the sound's data
@ -592,7 +601,7 @@ S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,
} }
void void
S_StopSound (int entnum, int entchannel) I_S_StopSound (int entnum, int entchannel)
{ {
int i; int i;
@ -607,7 +616,7 @@ S_StopSound (int entnum, int entchannel)
} }
void void
S_StopAllSounds (qboolean clear) I_S_StopAllSounds (qboolean clear)
{ {
int i; int i;
@ -623,17 +632,17 @@ S_StopAllSounds (qboolean clear)
memset (channels, 0, MAX_CHANNELS * sizeof (channel_t)); memset (channels, 0, MAX_CHANNELS * sizeof (channel_t));
if (clear) if (clear)
S_ClearBuffer (); I_S_ClearBuffer ();
} }
void void
S_StopAllSoundsC (void) I_S_StopAllSoundsC (void)
{ {
S_StopAllSounds (true); I_S_StopAllSounds (true);
} }
void void
S_ClearBuffer (void) I_S_ClearBuffer (void)
{ {
int clear; int clear;
@ -661,10 +670,10 @@ S_ClearBuffer (void)
/* /*
S_StaticSound I_S_StaticSound
*/ */
void void
S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
{ {
channel_t *ss; channel_t *ss;
sfxcache_t *sc; sfxcache_t *sc;
@ -680,7 +689,7 @@ S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
ss = &channels[total_channels]; ss = &channels[total_channels];
total_channels++; total_channels++;
sc = S_LoadSound (sfx); sc = I_S_LoadSound (sfx);
if (!sc) if (!sc)
return; return;
@ -703,10 +712,10 @@ S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
//============================================================================= //=============================================================================
/* /*
S_UpdateAmbientSounds I_S_UpdateAmbientSounds
*/ */
void void
S_UpdateAmbientSounds (void) I_S_UpdateAmbientSounds (void)
{ {
mleaf_t *l; mleaf_t *l;
float vol; float vol;
@ -717,10 +726,10 @@ S_UpdateAmbientSounds (void)
return; return;
// calc ambient sound levels // calc ambient sound levels
if (!*snd_worldmodel) if (!**plugin_info_sound_data.worldmodel) // FIXME: eww
return; return;
l = Mod_PointInLeaf (listener_origin, *snd_worldmodel); l = Mod_PointInLeaf (listener_origin, **plugin_info_sound_data.worldmodel);
if (!l || !ambient_level->value) { if (!l || !ambient_level->value) {
for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS;
ambient_channel++) ambient_channel++)
@ -738,11 +747,11 @@ S_UpdateAmbientSounds (void)
// don't adjust volume too fast // don't adjust volume too fast
if (chan->master_vol < vol) { if (chan->master_vol < vol) {
chan->master_vol += host_frametime * ambient_fade->value; chan->master_vol += *plugin_info_sound_data.host_frametime * ambient_fade->value;
if (chan->master_vol > vol) if (chan->master_vol > vol)
chan->master_vol = vol; chan->master_vol = vol;
} else if (chan->master_vol > vol) { } else if (chan->master_vol > vol) {
chan->master_vol -= host_frametime * ambient_fade->value; chan->master_vol -= *plugin_info_sound_data.host_frametime * ambient_fade->value;
if (chan->master_vol < vol) if (chan->master_vol < vol)
chan->master_vol = vol; chan->master_vol = vol;
} }
@ -753,12 +762,12 @@ S_UpdateAmbientSounds (void)
/* /*
S_Update I_S_Update
Called once each time through the main loop Called once each time through the main loop
*/ */
void void
S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) I_S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
{ {
int i, j; int i, j;
int total; int total;
@ -774,7 +783,7 @@ S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
VectorCopy (up, listener_up); VectorCopy (up, listener_up);
// update general area ambient sound sources // update general area ambient sound sources
S_UpdateAmbientSounds (); I_S_UpdateAmbientSounds ();
combine = NULL; combine = NULL;
@ -837,7 +846,7 @@ S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
Con_Printf ("----(%i)----\n", total); Con_Printf ("----(%i)----\n", total);
} }
// mix some sound // mix some sound
S_Update_ (); I_S_Update_ ();
} }
void void
@ -851,7 +860,7 @@ GetSoundtime (void)
fullsamples = shm->samples / shm->channels; fullsamples = shm->samples / shm->channels;
// it is possible to miscount buffers if it has wrapped twice between // it is possible to miscount buffers if it has wrapped twice between
// calls to S_Update. Oh well. // calls to I_S_Update. Oh well.
samplepos = SNDDMA_GetDMAPos (); samplepos = SNDDMA_GetDMAPos ();
if (samplepos < oldsamplepos) { if (samplepos < oldsamplepos) {
@ -861,7 +870,7 @@ GetSoundtime (void)
// 32 bit limits // 32 bit limits
buffers = 0; buffers = 0;
paintedtime = fullsamples; paintedtime = fullsamples;
S_StopAllSounds (true); I_S_StopAllSounds (true);
} }
} }
oldsamplepos = samplepos; oldsamplepos = samplepos;
@ -870,17 +879,17 @@ GetSoundtime (void)
} }
void void
S_ExtraUpdate (void) I_S_ExtraUpdate (void)
{ {
if (snd_noextraupdate->int_val) if (snd_noextraupdate->int_val)
return; // don't pollute timings return; // don't pollute timings
S_Update_ (); I_S_Update_ ();
} }
void void
S_Update_ (void) I_S_Update_ (void)
{ {
unsigned int endtime; unsigned int endtime;
int samps; int samps;
@ -907,7 +916,7 @@ S_Update_ (void)
DSOUND_Restore (); DSOUND_Restore ();
#endif #endif
S_PaintChannels (endtime); I_S_PaintChannels (endtime);
SNDDMA_Submit (); SNDDMA_Submit ();
} }
@ -917,7 +926,7 @@ S_Update_ (void)
*/ */
void void
S_Play (void) I_S_Play (void)
{ {
static int hash = 345; static int hash = 345;
int i; int i;
@ -931,14 +940,14 @@ S_Play (void)
strncat (name, ".wav", sizeof (name) - strlen (name)); strncat (name, ".wav", sizeof (name) - strlen (name));
} else } else
strcpy (name, Cmd_Argv (i)); strcpy (name, Cmd_Argv (i));
sfx = S_PrecacheSound (name); sfx = I_S_PrecacheSound (name);
S_StartSound (hash++, 0, sfx, listener_origin, 1.0, 1.0); I_S_StartSound (hash++, 0, sfx, listener_origin, 1.0, 1.0);
i++; i++;
} }
} }
void void
S_PlayVol (void) I_S_PlayVol (void)
{ {
static int hash = 543; static int hash = 543;
int i; int i;
@ -953,15 +962,15 @@ S_PlayVol (void)
strncat (name, ".wav", sizeof (name) - strlen (name)); strncat (name, ".wav", sizeof (name) - strlen (name));
} else } else
strcpy (name, Cmd_Argv (i)); strcpy (name, Cmd_Argv (i));
sfx = S_PrecacheSound (name); sfx = I_S_PrecacheSound (name);
vol = atof (Cmd_Argv (i + 1)); vol = atof (Cmd_Argv (i + 1));
S_StartSound (hash++, 0, sfx, listener_origin, vol, 1.0); I_S_StartSound (hash++, 0, sfx, listener_origin, vol, 1.0);
i += 2; i += 2;
} }
} }
void void
S_SoundList (void) I_S_SoundList (void)
{ {
int i; int i;
sfx_t *sfx; sfx_t *sfx;
@ -986,7 +995,7 @@ S_SoundList (void)
void void
S_LocalSound (char *sound) I_S_LocalSound (char *sound)
{ {
sfx_t *sfx; sfx_t *sfx;
@ -995,28 +1004,28 @@ S_LocalSound (char *sound)
if (!sound_started) if (!sound_started)
return; return;
sfx = S_PrecacheSound (sound); sfx = I_S_PrecacheSound (sound);
if (!sfx) { if (!sfx) {
Con_Printf ("S_LocalSound: can't cache %s\n", sound); Con_Printf ("S_LocalSound: can't cache %s\n", sound);
return; return;
} }
S_StartSound (snd_viewentity, -1, sfx, vec3_origin, 1, 1); I_S_StartSound (*plugin_info_sound_data.viewentity, -1, sfx, vec3_origin, 1, 1);
} }
void void
S_ClearPrecache (void) I_S_ClearPrecache (void)
{ {
} }
void void
S_BeginPrecaching (void) I_S_BeginPrecaching (void)
{ {
} }
void void
S_EndPrecaching (void) I_S_EndPrecaching (void)
{ {
} }

View file

@ -44,7 +44,7 @@
int cache_full_cycle; int cache_full_cycle;
byte *S_Alloc (int size); byte *I_S_Alloc (int size);
/* /*
ResampleSfx ResampleSfx
@ -163,10 +163,10 @@ ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte * data)
//============================================================================= //=============================================================================
/* /*
S_LoadSound I_S_LoadSound
*/ */
sfxcache_t * sfxcache_t *
S_LoadSound (sfx_t *s) I_S_LoadSound (sfx_t *s)
{ {
char namebuffer[256]; char namebuffer[256];
byte *data; byte *data;

View file

@ -56,6 +56,7 @@ int *snd_p, snd_linear_count, snd_vol;
short *snd_out; short *snd_out;
void Snd_WriteLinearBlastStereo16 (void); void Snd_WriteLinearBlastStereo16 (void);
sfxcache_t *I_S_LoadSound (sfx_t *s);
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
void void
@ -85,7 +86,7 @@ Snd_WriteLinearBlastStereo16 (void)
#endif #endif
void void
S_TransferStereo16 (int endtime) I_S_TransferStereo16 (int endtime)
{ {
int lpos; int lpos;
int lpaintedtime; int lpaintedtime;
@ -135,7 +136,7 @@ S_TransferStereo16 (int endtime)
} }
void void
S_TransferPaintBuffer (int endtime) I_S_TransferPaintBuffer (int endtime)
{ {
int out_idx; int out_idx;
int count; int count;
@ -147,7 +148,7 @@ S_TransferPaintBuffer (int endtime)
DWORD *pbuf; DWORD *pbuf;
if (shm->samplebits == 16 && shm->channels == 2) { if (shm->samplebits == 16 && shm->channels == 2) {
S_TransferStereo16 (endtime); I_S_TransferStereo16 (endtime);
return; return;
} }
@ -213,7 +214,7 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime);
void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime); void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime);
void void
S_PaintChannels (int endtime) I_S_PaintChannels (int endtime)
{ {
int i; int i;
int end; int end;
@ -239,7 +240,7 @@ S_PaintChannels (int endtime)
continue; continue;
if (!ch->leftvol && !ch->rightvol) if (!ch->leftvol && !ch->rightvol)
continue; continue;
sc = S_LoadSound (ch->sfx); sc = I_S_LoadSound (ch->sfx);
if (!sc) if (!sc)
continue; continue;
@ -274,7 +275,7 @@ S_PaintChannels (int endtime)
} }
// transfer out according to DMA format // transfer out according to DMA format
S_TransferPaintBuffer (end); I_S_TransferPaintBuffer (end);
memmove (paintbuffer, paintbuffer + end - paintedtime, memmove (paintbuffer, paintbuffer + end - paintedtime,
max_overpaint * sizeof (paintbuffer[0])); max_overpaint * sizeof (paintbuffer[0]));

View file

@ -31,6 +31,7 @@
#include "QF/qtypes.h" #include "QF/qtypes.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/plugin.h"
// ======================================================================= // =======================================================================
// Various variables also defined in snd_dma.c // Various variables also defined in snd_dma.c
@ -47,15 +48,42 @@ extern cvar_t *bgmvolume;
extern cvar_t *volume; extern cvar_t *volume;
extern cvar_t *snd_interp; extern cvar_t *snd_interp;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
void I_S_Init_Cvars (void);
void void
S_Init (void) I_S_Init (void)
{ {
S_Init_Cvars (); I_S_Init_Cvars ();
} }
void void
S_Init_Cvars (void) I_S_Init_Cvars (void)
{ {
volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, NULL, volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, NULL,
"Volume level of sounds"); "Volume level of sounds");
@ -68,83 +96,125 @@ S_Init_Cvars (void)
} }
void void
S_AmbientOff (void) I_S_AmbientOff (void)
{ {
} }
void void
S_AmbientOn (void) I_S_AmbientOn (void)
{ {
} }
void void
S_Shutdown (void) I_S_Shutdown (void)
{ {
} }
void void
S_TouchSound (char *sample) I_S_TouchSound (char *sample)
{ {
} }
void void
S_ClearBuffer (void) I_S_ClearBuffer (void)
{ {
} }
void void
S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
{ {
} }
void void
S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,
float attenuation) float attenuation)
{ {
} }
void void
S_StopSound (int entnum, int entchannel) I_S_StopSound (int entnum, int entchannel)
{ {
} }
sfx_t * sfx_t *
S_PrecacheSound (char *sample) I_S_PrecacheSound (char *sample)
{ {
return NULL; return NULL;
} }
void void
S_ClearPrecache (void) I_S_ClearPrecache (void)
{ {
} }
void void
S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up) I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up)
{ {
} }
void void
S_StopAllSounds (qboolean clear) I_S_StopAllSounds (qboolean clear)
{ {
} }
void void
S_BeginPrecaching (void) I_S_BeginPrecaching (void)
{ {
} }
void void
S_EndPrecaching (void) I_S_EndPrecaching (void)
{ {
} }
void void
S_ExtraUpdate (void) I_S_ExtraUpdate (void)
{ {
} }
void void
S_LocalSound (char *s) I_S_LocalSound (char *s)
{ {
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "ALSA 0.5.x digital output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n"
"Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}

View file

@ -59,6 +59,7 @@
#include "QF/console.h" #include "QF/console.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/plugin.h"
#ifndef MAP_FAILED #ifndef MAP_FAILED
# define MAP_FAILED ((void *) -1) # define MAP_FAILED ((void *) -1)
@ -70,6 +71,32 @@ static char *snd_dev = "/dev/dsp";
static int tryrates[] = { 11025, 22050, 22051, 44100, 8000 }; static int tryrates[] = { 11025, 22050, 22051, 44100, 8000 };
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
qboolean qboolean
SNDDMA_Init (void) SNDDMA_Init (void)
{ {
@ -299,3 +326,43 @@ void
SNDDMA_Submit (void) SNDDMA_Submit (void)
{ {
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "OSS digital output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}

View file

@ -39,6 +39,7 @@
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/plugin.h"
static dma_t the_shm; static dma_t the_shm;
static int snd_inited; static int snd_inited;
@ -46,6 +47,34 @@ static int snd_inited;
extern int desired_speed; extern int desired_speed;
extern int desired_bits; extern int desired_bits;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
void I_S_PaintChannels (int endtime);
static void static void
paint_audio (void *unused, Uint8 * stream, int len) paint_audio (void *unused, Uint8 * stream, int len)
{ {
@ -61,7 +90,7 @@ paint_audio (void *unused, Uint8 * stream, int len)
shm->samplepos += streamsamples; shm->samplepos += streamsamples;
while (shm->samplepos >= shm->samples) while (shm->samplepos >= shm->samples)
shm->samplepos -= shm->samples; shm->samplepos -= shm->samples;
S_PaintChannels (soundtime + streamsamples); I_S_PaintChannels (soundtime + streamsamples);
if (shm->samplepos + streamsamples <= shm->samples) if (shm->samplepos + streamsamples <= shm->samples)
memcpy (stream, shm->buffer + sampleposbytes, len); memcpy (stream, shm->buffer + sampleposbytes, len);
@ -184,3 +213,44 @@ SNDDMA_Submit (void)
SDL_UnlockAudio(); SDL_UnlockAudio();
SDL_LockAudio(); SDL_LockAudio();
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SDL digital output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}

View file

@ -37,6 +37,7 @@
#include "QF/qtypes.h" #include "QF/qtypes.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/plugin.h"
static int snd_inited = 0; static int snd_inited = 0;
static ALconfig alc; static ALconfig alc;
@ -49,6 +50,32 @@ static int bufsize;
static int wbufp; static int wbufp;
static int framecount; static int framecount;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
qboolean qboolean
SNDDMA_Init (void) SNDDMA_Init (void)
{ {
@ -308,4 +335,44 @@ SNDDMA_Submit (void)
framecount += bytes / bsize; framecount += bytes / bsize;
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SGI digital output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}
/* end of file */ /* end of file */

View file

@ -50,6 +50,7 @@
#include "QF/qtypes.h" #include "QF/qtypes.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/sound.h" #include "QF/sound.h"
#include "QF/plugin.h"
int audio_fd; int audio_fd;
int snd_inited; int snd_inited;
@ -63,6 +64,32 @@ unsigned char dma_buffer[BUFFER_SIZE];
unsigned char pend_buffer[BUFFER_SIZE]; unsigned char pend_buffer[BUFFER_SIZE];
int pending; int pending;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
plugin_funcs_t plugin_info_funcs;
general_data_t plugin_info_general_data;
general_funcs_t plugin_info_general_funcs;
sound_data_t plugin_info_sound_data;
sound_funcs_t plugin_info_sound_funcs;
void I_S_Init (void);
void I_S_Shutdown (void);
void I_S_AmbientOff (void);
void I_S_AmbientOn (void);
void I_S_TouchSound (char *sample);
void I_S_ClearBuffer (void);
void I_S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void I_S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void I_S_StopSound (int entnum, int entchannel);
sfx_t *I_S_PrecacheSound (char *sample);
void I_S_ClearPrecache (void);
void I_S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
void I_S_StopAllSounds (qboolean clear);
void I_S_BeginPrecaching (void);
void I_S_EndPrecaching (void);
void I_S_ExtraUpdate (void);
void I_S_LocalSound (char *s);
qboolean qboolean
SNDDMA_Init (void) SNDDMA_Init (void)
{ {
@ -226,3 +253,44 @@ SNDDMA_Submit (void)
printf ("audio can't keep up!\n"); printf ("audio can't keep up!\n");
} }
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SUN digital output";
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge project\n" "Please see the file \"AUTHORS\" for a list of contributors";
plugin_info.functions = &plugin_info_funcs;
plugin_info.data = &plugin_info_data;
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = I_S_Init;
plugin_info_general_funcs.p_Shutdown = I_S_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = I_S_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = I_S_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = I_S_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = I_S_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = I_S_StaticSound;
plugin_info_sound_funcs.pS_StartSound = I_S_StartSound;
plugin_info_sound_funcs.pS_StopSound = I_S_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = I_S_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = I_S_ClearPrecache;
plugin_info_sound_funcs.pS_Update = I_S_Update;
plugin_info_sound_funcs.pS_StopAllSounds = I_S_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = I_S_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = I_S_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = I_S_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = I_S_LocalSound;
return &plugin_info;
}

View file

@ -98,19 +98,23 @@ PI_LoadPlugin (char *type, char *name)
tmpname = strrchr (name, '/'); // Get the base name, don't allow paths tmpname = strrchr (name, '/'); // Get the base name, don't allow paths
// Build the path to the file to load // Build the path to the file to load
snprintf (realname, sizeof (realname), "%s/%s_%s.o", snprintf (realname, sizeof (realname), "%s/lib%s_%s.so",
fs_pluginpath->string, type, (tmpname ? tmpname + 1 : name)); fs_pluginpath->string, type, (tmpname ? tmpname + 1 : name));
if (!(dlhand = dlopen (realname, RTLD_LAZY))) // lib not found if (!(dlhand = dlopen (realname, RTLD_LAZY))) { // lib not found
Con_Printf ("%s\n", dlerror());
return NULL; return NULL;
}
if (!(plugin_info = dlsym (dlhand, "PluginInfo"))) { // info function not found if (!(plugin_info = dlsym (dlhand, "PluginInfo"))) { // info function not found
dlclose (dlhand); dlclose (dlhand);
Con_Printf ("info function not found\n");
return NULL; return NULL;
} }
if (!(plugin = plugin_info ())) { // Something went badly wrong if (!(plugin = plugin_info ())) { // Something went badly wrong
dlclose (dlhand); dlclose (dlhand);
Con_Printf ("soemthing went badly wrong\n");
return NULL; return NULL;
} }

View file

@ -66,10 +66,10 @@ qf_client_LIBS= $(top_builddir)/libs/video/targets/libQFjs.la \
$(top_builddir)/libs/gamecode/libQFgamecode.la \ $(top_builddir)/libs/gamecode/libQFgamecode.la \
$(top_builddir)/libs/gib/libQFgib.la \ $(top_builddir)/libs/gib/libQFgib.la \
$(top_builddir)/libs/audio/cd/libQFcd.la \ $(top_builddir)/libs/audio/cd/libQFcd.la \
$(top_builddir)/libs/audio/targets/libQFsound.la \ $(top_builddir)/libs/audio/libQFsound.la \
$(top_builddir)/libs/util/libQFutil.la $(top_builddir)/libs/util/libQFutil.la
client_LIBS= -L. -lqfnet $(qf_client_LIBS) $(SOUND_LIBS) $(NET_LIBS) client_LIBS= -L. -lqfnet $(qf_client_LIBS) $(NET_LIBS)
client_LIB_DEPS= libqfnet.a $(qf_client_LIBS) client_LIB_DEPS= libqfnet.a $(qf_client_LIBS)
client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \ client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \

View file

@ -88,10 +88,10 @@ endif
qf_client_LIBS= $(top_builddir)/libs/video/targets/libQFjs.la \ qf_client_LIBS= $(top_builddir)/libs/video/targets/libQFjs.la \
$(top_builddir)/libs/gamecode/libQFgamecode.la \ $(top_builddir)/libs/gamecode/libQFgamecode.la \
$(top_builddir)/libs/audio/cd/libQFcd.la \ $(top_builddir)/libs/audio/cd/libQFcd.la \
$(top_builddir)/libs/audio/targets/libQFsound.la \ $(top_builddir)/libs/audio/libQFsound.la \
$(top_builddir)/libs/util/libQFutil.la $(top_builddir)/libs/util/libQFutil.la
client_LIBS= -L. -lqfnet $(qf_client_LIBS) $(SOUND_LIBS) $(NET_LIBS) client_LIBS= -L. -lqfnet $(qf_client_LIBS) $(NET_LIBS)
client_LIB_DEPS= libqfnet.a $(qf_client_LIBS) client_LIB_DEPS= libqfnet.a $(qf_client_LIBS)
# libQFjs is seperate because it needs to be linked after when building statically # libQFjs is seperate because it needs to be linked after when building statically

View file

@ -1133,8 +1133,10 @@ CL_Init (void)
Info_SetValueForStarKey (cls.userinfo, "*ver", st, MAX_INFO_STRING); Info_SetValueForStarKey (cls.userinfo, "*ver", st, MAX_INFO_STRING);
Info_SetValueForStarKey (cls.userinfo, "stdver", QW_QSG_VERSION, Info_SetValueForStarKey (cls.userinfo, "stdver", QW_QSG_VERSION,
MAX_INFO_STRING); MAX_INFO_STRING);
PI_Init ();
#ifdef PACKET_LOGGING #ifdef PACKET_LOGGING
Net_Log_Init(); Net_Log_Init ();
#endif #endif
CL_Input_Init (); CL_Input_Init ();
CL_Ents_Init (); CL_Ents_Init ();