Put the sound renderer in it's proper place: as a full-fledged plugin.

Bugs expected.  Please report them :)
This commit is contained in:
Adam Olsen 2001-08-23 04:01:46 +00:00
parent 6797f556cf
commit cad42cbc78
32 changed files with 883 additions and 491 deletions

View File

@ -1269,7 +1269,7 @@ NQ_TARGETS=""
CD_TARGETS=""
SND_TARGETS=""
SND_PLUGIN_TARGETS="libsound_null.la libsound_disk.la"
SND_PLUGIN_TARGETS="libsnd_output_disk.la"
VID_TARGETS=""
BUILD_SND_RENDERER=no
BUILD_GL=no
@ -1391,35 +1391,30 @@ if test -n "$CL_TARGETS"; then
CD_TARGETS="libQFcd.la"
SND_TARGETS="libQFsound.la"
if test "`echo $SOUND_TYPES | grep ALSA0.5`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_alsa0_5.la"
BUILD_SND_RENDERER=yes
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_alsa0_5.la"
fi
if test "`echo $SOUND_TYPES | grep ALSA0.9`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_alsa0_9.la"
BUILD_SND_RENDERER=yes
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_alsa0_9.la"
fi
if test "`echo $SOUND_TYPES | grep MME`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_mme.la"
BUILD_SND_RENDERER=yes
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_mme.la"
fi
if test "`echo $SOUND_TYPES | grep OSS`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_oss.la"
BUILD_SND_RENDERER=yes
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_oss.la"
fi
if test "`echo $SOUND_TYPES | grep SDL`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_sdl.la"
BUILD_SND_RENDERER=yes
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_sdl.la"
fi
if test "`echo $SOUND_TYPES | grep SGI`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_sgi.la"
BUILD_SND_RENDERER=yes
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_sgi.la"
fi
if test "`echo $SOUND_TYPES | grep SUN`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_sun.la"
BUILD_SND_RENDERER=yes
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_sun.la"
fi
if test "`echo $SOUND_TYPES | grep Win32`"; then
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsound_win.la"
SND_PLUGIN_TARGETS="$SND_PLUGIN_TARGETS libsnd_output_win.la"
fi
if test "$SOUND_TYPES"; then
BUILD_SND_RENDERER=yes
fi
VID_TARGETS="libQFjs.la $VID_TARGETS"
@ -1458,6 +1453,7 @@ AC_OUTPUT(
libs/audio/Makefile
libs/audio/cd/Makefile
libs/audio/targets/Makefile
libs/audio/renderer/Makefile
libs/console/Makefile
libs/gamecode/Makefile
libs/gamecode/engine/Makefile

View File

@ -38,30 +38,34 @@
#include <QF/plugin/console.h>
#include <QF/plugin/general.h>
#include <QF/plugin/input.h>
#include <QF/plugin/sound.h>
#include <QF/plugin/snd_output.h>
#include <QF/plugin/snd_render.h>
typedef enum {
qfp_null = 0, // Not real
qfp_input, // Input (pointing devices, joysticks, etc)
qfp_cd, // CD Audio
qfp_sound, // Wave output (OSS, ALSA, Win32)
qfp_console, // Console `driver'
qfp_snd_output, // Sound output (OSS, ALSA, Win32)
qfp_snd_render, // Sound mixing
} plugin_type_t;
typedef struct plugin_funcs_s {
general_funcs_t *general;
input_funcs_t *input;
cd_funcs_t *cd;
sound_funcs_t *sound;
console_funcs_t *console;
snd_output_funcs_t *snd_output;
snd_render_funcs_t *snd_render;
} plugin_funcs_t;
typedef struct plugin_data_s {
general_data_t *general;
input_data_t *input;
cd_data_t *cd;
sound_data_t *sound;
console_data_t *console;
snd_output_data_t *snd_output;
snd_render_data_t *snd_render;
} plugin_data_t;
typedef struct plugin_s {
@ -93,4 +97,6 @@ qboolean PI_UnloadPlugin (plugin_t *);
void PI_Init (void);
void PI_Shutdown (void);
// FIXME: we need a generic function to initialize unused fields
#endif // __QF_plugin_h_

View File

@ -1,3 +1,3 @@
AUTOMAKE_OPTIONS = foreign
includedir = $(prefix)/include/QF/plugin
include_HEADERS = cd.h console.h general.h input.h sound.h
include_HEADERS = cd.h console.h general.h input.h snd_output.h snd_render.h

View File

@ -0,0 +1,59 @@
/*
QF/plugin/sound.h
Sound Output plugin data types
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
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$
*/
#ifndef __QF_plugin_snd_output_h_
#define __QF_plugin_snd_output_h_
#include <QF/qtypes.h>
#include <QF/sound.h>
#include <QF/plugin.h>
/*
All sound plugins must export these functions
*/
typedef qboolean (QFPLUGIN *P_S_O_Init) (void);
typedef void (QFPLUGIN *P_S_O_Shutdown) (void);
typedef int (QFPLUGIN *P_S_O_GetDMAPos) (void);
typedef void (QFPLUGIN *P_S_O_Submit) (void);
typedef void (QFPLUGIN *P_S_O_BlockSound) (void);
typedef void (QFPLUGIN *P_S_O_UnblockSound) (void);
typedef struct snd_output_funcs_s {
P_S_O_Init pS_O_Init;
P_S_O_Shutdown pS_O_Shutdown;
P_S_O_GetDMAPos pS_O_GetDMAPos;
P_S_O_Submit pS_O_Submit;
P_S_O_BlockSound pS_O_BlockSound;
P_S_O_UnblockSound pS_O_UnblockSound;
} snd_output_funcs_t;
typedef struct snd_output_data_s {
int *soundtime;
int *paintedtime;
} snd_output_data_t;
#endif // __QF_plugin_snd_output_h_

View File

@ -1,7 +1,7 @@
/*
QF/plugin/sound.h
QF/plugin/snd_render.h
Sound plugin data types
Sound Renderer plugin data types
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
@ -25,8 +25,8 @@
$Id$
*/
#ifndef __QF_plugin_sound_h_
#define __QF_plugin_sound_h_
#ifndef __QF_plugin_snd_render_h_
#define __QF_plugin_snd_render_h_
#include <QF/qtypes.h>
#include <QF/sound.h>
@ -55,7 +55,7 @@ typedef void (QFPLUGIN *P_S_LocalSound) (const char *s);
typedef void (QFPLUGIN *P_S_BlockSound) (void);
typedef void (QFPLUGIN *P_S_UnblockSound) (void);
typedef struct sound_funcs_s {
typedef struct snd_render_funcs_s {
P_S_AmbientOff pS_AmbientOff;
P_S_AmbientOn pS_AmbientOn;
P_S_TouchSound pS_TouchSound;
@ -73,12 +73,15 @@ typedef struct sound_funcs_s {
P_S_LocalSound pS_LocalSound;
P_S_BlockSound pS_BlockSound;
P_S_UnblockSound pS_UnblockSound;
} sound_funcs_t;
} snd_render_funcs_t;
typedef struct sound_data_s {
typedef struct snd_render_data_s {
struct model_s ***worldmodel;
double *host_frametime;
int *viewentity;
} sound_data_t;
#endif // __QF_plugin_sound_h_
int *soundtime;
int *paintedtime;
} snd_render_data_t;
#endif // __QF_plugin_snd_render_h_

View File

@ -156,13 +156,13 @@ channel_t *SND_PickChannel(int entnum, int entchannel);
void SND_Spatialize(channel_t *ch);
// initializes cycling through a DMA buffer and returns information on it
qboolean SNDDMA_Init(void);
qboolean S_O_Init(void);
// gets the current DMA position
int SNDDMA_GetDMAPos(void);
int S_O_GetDMAPos(void);
// shutdown the DMA xfer.
void SNDDMA_Shutdown(void);
void S_O_Shutdown(void);
// ====================================================================
// User-setable variables
@ -216,9 +216,9 @@ sfxcache_t *S_LoadSound (sfx_t *s);
wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength);
void SNDDMA_Submit(void);
void SNDDMA_BlockSound (void);
void SNDDMA_UnblockSound (void);
void S_O_Submit(void);
void S_O_BlockSound (void);
void S_O_UnblockSound (void);
void S_AmbientOff (void);
void S_AmbientOn (void);

View File

@ -1,4 +1,4 @@
SUBDIRS= cd targets
SUBDIRS= cd targets renderer
clean-local:
rm -f *.a

View File

@ -472,12 +472,10 @@ PluginInfo (void)
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;

View File

@ -99,12 +99,10 @@ PluginInfo (void)
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;

View File

@ -302,12 +302,10 @@ PluginInfo (void)
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;

View File

@ -518,12 +518,10 @@ PluginInfo (void)
plugin_info_data.general = &plugin_info_general_data;
// plugin_info_data.cd = &plugin_info_cd_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = NULL;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.cd = &plugin_info_cd_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = NULL;
plugin_info_general_funcs.p_Init = I_CDAudio_Init;
plugin_info_general_funcs.p_Shutdown = I_CDAudio_Shutdown;

7
libs/audio/renderer/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
*.la
*.lo
.deps
.libs
.vimrc
Makefile
Makefile.in

View File

@ -0,0 +1,30 @@
INCLUDES= -I$(top_srcdir)/include
libdir = @PLUGINDIR@
if BUILD_SND_RENDERER
SND_RENDERER = libsnd_render_default.la
else
SND_RENDERER =
endif
lib_LTLIBRARIES = $(SND_RENDERER)
EXTRA_LTLIBRARIES =
if ASM_ARCH
ASM = libasm.la
else
ASM =
endif
noinst_LTLIBRARIES = $(ASM)
libasm_la_SOURCES = snd_mixa.S
libsnd_render_default_la_LDFLAGS= -version-info 1:0:0
libsnd_render_default_la_LIBADD = $(ASM)
libsnd_render_default_la_SOURCES= snd_dma.c snd_mem.c snd_mix.c
libsnd_render_default.la: $(libsnd_render_default_la_OBJECTS) $(libsnd_render_default_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_render_default_la_LDFLAGS) $(libsnd_render_default_la_OBJECTS) $(libsnd_render_default_la_LIBADD) $(LIBS)
LIBLIST = $(pkglib_LTLIBRARIES) libsnd_default_render.la @LIBRARY_SEARCH_PATH@

View File

@ -21,7 +21,7 @@
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
Boston, MA 02111-1307, USA
$Id$
*/
@ -51,12 +51,12 @@
#include "QF/sound.h"
#include "QF/plugin.h"
void SND_Play (void);
void SND_PlayVol (void);
void SND_SoundList (void);
void SND_Update_ (void);
void SND_StopAllSounds (qboolean clear);
void SND_StopAllSoundsC (void);
void SND_Play (void);
void SND_PlayVol (void);
void SND_SoundList (void);
void SND_Update_ (void);
void SND_StopAllSounds (qboolean clear);
void SND_StopAllSoundsC (void);
sfx_t *SND_PrecacheSound (const char *name);
sfxcache_t *SND_LoadSound (sfx_t *s);
@ -71,55 +71,59 @@ void SND_Init_Cvars ();
// Internal sound data & structures ===========================================
extern channel_t channels[MAX_CHANNELS];
extern int total_channels;
extern int total_channels;
//extern double host_frametime; // From host.h
int snd_blocked = 0;
int snd_blocked = 0;
static qboolean snd_ambient = 1;
extern qboolean snd_initialized;
// pointer should go away
extern volatile dma_t *shm;
volatile dma_t sn;
vec3_t listener_origin;
vec3_t listener_forward;
vec3_t listener_right;
vec3_t listener_up;
vec_t sound_nominal_clip_dist = 1000.0;
vec3_t listener_origin;
vec3_t listener_forward;
vec3_t listener_right;
vec3_t listener_up;
vec_t sound_nominal_clip_dist = 1000.0;
int soundtime; // sample PAIRS
extern int paintedtime; // sample PAIRS
int soundtime; // sample PAIRS
extern int paintedtime; // sample PAIRS
#define MAX_SFX 512
sfx_t *known_sfx; // hunk allocated [MAX_SFX]
int num_sfx;
sfx_t *known_sfx; // hunk allocated [MAX_SFX]
int num_sfx;
sfx_t *ambient_sfx[NUM_AMBIENTS];
sfx_t *ambient_sfx[NUM_AMBIENTS];
int desired_speed = 11025;
int desired_bits = 16;
int desired_speed = 11025;
int desired_bits = 16;
int sound_started = 0;
int sound_started = 0;
extern cvar_t *snd_loadas8bit;
extern cvar_t *snd_interp;
extern cvar_t *bgmvolume;
extern cvar_t *volume;
extern cvar_t *snd_loadas8bit;
extern cvar_t *snd_interp;
extern cvar_t *bgmvolume;
extern cvar_t *volume;
cvar_t *ambient_fade;
cvar_t *ambient_level;
cvar_t *nosound;
cvar_t *precache;
cvar_t *snd_bits;
cvar_t *snd_device;
cvar_t *snd_mixahead;
cvar_t *snd_noextraupdate;
cvar_t *snd_phasesep;
cvar_t *snd_rate;
cvar_t *snd_show;
cvar_t *snd_stereo;
cvar_t *snd_volumesep;
cvar_t *ambient_fade;
cvar_t *ambient_level;
cvar_t *nosound;
cvar_t *precache;
cvar_t *snd_mixahead;
cvar_t *snd_noextraupdate;
cvar_t *snd_phasesep;
cvar_t *snd_show;
cvar_t *snd_volumesep;
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;
snd_render_data_t plugin_info_snd_render_data;
snd_render_funcs_t plugin_info_snd_render_funcs;
// User-setable variables =====================================================
@ -128,13 +132,8 @@ cvar_t *snd_volumesep;
// isolating performance in the renderer. The fakedma_updates is
// number of times SND_Update() is called per second.
qboolean fakedma = false;
int fakedma_updates = 15;
// FIXME: Evil hack that doesn't deserve to see the light of day.
// (pending merge of nq and qw client_stat_t's)
extern sound_data_t plugin_info_sound_data;
qboolean fakedma = false;
int fakedma_updates = 15;
void
SND_AmbientOff (void)
@ -169,17 +168,17 @@ SND_SoundInfo_f (void)
void
SND_Startup (void)
{
int rc;
int rc;
if (!snd_initialized)
return;
if (!fakedma) {
rc = SNDDMA_Init ();
rc = S_O_Init ();
if (!rc) {
#ifndef _WIN32
Con_Printf ("S_Startup: SNDDMA_Init failed.\n");
Con_Printf ("S_Startup: S_O_Init failed.\n");
#endif
sound_started = 0;
return;
@ -275,10 +274,6 @@ SND_Init_Cvars (void)
"Volume of CD music");
volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, NULL,
"Set the volume for sound playback");
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL,
"sound sample depth. 0 is system default");
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL,
"sound device. \"\" is system default");
snd_interp = Cvar_Get ("snd_interp", "1", CVAR_ARCHIVE, NULL,
"control sample interpolation");
snd_loadas8bit = Cvar_Get ("snd_loadas8bit", "0", CVAR_NONE, NULL,
@ -292,12 +287,8 @@ SND_Init_Cvars (void)
snd_phasesep = Cvar_Get ("snd_phasesep", "0.0", CVAR_ARCHIVE, NULL,
"max stereo phase separation in ms. 0.6 is for "
"20cm head");
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL,
"sound playback rate. 0 is system default");
snd_show = Cvar_Get ("snd_show", "0", CVAR_NONE, NULL,
"Toggles display of sounds currently being played");
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
"sound stereo output");
snd_volumesep = Cvar_Get ("snd_volumesep", "1.0", CVAR_ARCHIVE, NULL,
"max stereo volume separation. 1.0 is max");
}
@ -316,7 +307,7 @@ SND_Shutdown (void)
sound_started = 0;
if (!fakedma) {
SNDDMA_Shutdown ();
S_O_Shutdown ();
}
shm = 0;
@ -326,8 +317,8 @@ SND_Shutdown (void)
sfx_t *
SND_FindName (const char *name)
{
int i;
sfx_t *sfx;
int i;
sfx_t *sfx;
if (!name)
Sys_Error ("S_FindName: NULL\n");
@ -355,7 +346,7 @@ SND_FindName (const char *name)
void
SND_TouchSound (const char *name)
{
sfx_t *sfx;
sfx_t *sfx;
if (!sound_started)
return;
@ -367,7 +358,7 @@ SND_TouchSound (const char *name)
sfx_t *
SND_PrecacheSound (const char *name)
{
sfx_t *sfx;
sfx_t *sfx;
if (!sound_started || nosound->int_val)
return NULL;
@ -386,9 +377,9 @@ SND_PrecacheSound (const char *name)
channel_t *
SND_PickChannel (int entnum, int entchannel)
{
int ch_idx;
int first_to_die;
int life_left;
int ch_idx;
int first_to_die;
int life_left;
// Check for replacement sound, or find the best one to replace
first_to_die = -1;
@ -404,8 +395,8 @@ SND_PickChannel (int entnum, int entchannel)
break;
}
// don't let monster sounds override player sounds
if (channels[ch_idx].entnum == *plugin_info_sound_data.viewentity
&& entnum != *plugin_info_sound_data.viewentity
if (channels[ch_idx].entnum == *plugin_info_snd_render_data.viewentity
&& entnum != *plugin_info_snd_render_data.viewentity
&& channels[ch_idx].sfx)
continue;
@ -427,15 +418,15 @@ SND_PickChannel (int entnum, int entchannel)
void
SND_Spatialize (channel_t *ch)
{
vec_t dot;
vec_t dist;
int phase; // in samples
vec_t lscale, rscale, scale;
vec3_t source_vec;
sfx_t *snd;
vec_t dot;
vec_t dist;
int phase; // in samples
vec_t lscale, rscale, scale;
vec3_t source_vec;
sfx_t *snd;
// anything coming from the view entity will always be full volume
if (ch->entnum == *plugin_info_sound_data.viewentity) {
if (ch->entnum == *plugin_info_snd_render_data.viewentity) {
ch->leftvol = ch->master_vol;
ch->rightvol = ch->master_vol;
ch->phase = 0;
@ -481,9 +472,9 @@ SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin,
{
channel_t *target_chan, *check;
sfxcache_t *sc;
int vol;
int ch_idx;
int skip;
int vol;
int ch_idx;
int skip;
if (!sound_started)
return;
@ -546,7 +537,7 @@ SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin,
void
SND_StopSound (int entnum, int entchannel)
{
int i;
int i;
for (i = 0; i < MAX_DYNAMIC_CHANNELS; i++) {
if (channels[i].entnum == entnum
@ -561,7 +552,7 @@ SND_StopSound (int entnum, int entchannel)
void
SND_StopAllSounds (qboolean clear)
{
int i;
int i;
if (!sound_started)
return;
@ -587,7 +578,7 @@ SND_StopAllSoundsC (void)
void
SND_ClearBuffer (void)
{
int clear;
int clear;
#ifdef _WIN32
if (!sound_started || !shm || (!shm->buffer && !pDSBuf))
@ -653,18 +644,18 @@ void
SND_UpdateAmbientSounds (void)
{
mleaf_t *l;
float vol;
int ambient_channel;
float vol;
int ambient_channel;
channel_t *chan;
if (!snd_ambient)
return;
// calc ambient sound levels
if (!**plugin_info_sound_data.worldmodel) // FIXME: eww
if (!**plugin_info_snd_render_data.worldmodel) // FIXME: eww
return;
l = Mod_PointInLeaf (listener_origin, **plugin_info_sound_data.worldmodel);
l = Mod_PointInLeaf (listener_origin, **plugin_info_snd_render_data.worldmodel);
if (!l || !ambient_level->value) {
for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS;
ambient_channel++)
@ -683,12 +674,12 @@ SND_UpdateAmbientSounds (void)
// don't adjust volume too fast
if (chan->master_vol < vol) {
chan->master_vol += *plugin_info_sound_data.host_frametime
chan->master_vol += *plugin_info_snd_render_data.host_frametime
* ambient_fade->value;
if (chan->master_vol > vol)
chan->master_vol = vol;
} else if (chan->master_vol > vol) {
chan->master_vol -= *plugin_info_sound_data.host_frametime
chan->master_vol -= *plugin_info_snd_render_data.host_frametime
* ambient_fade->value;
if (chan->master_vol < vol)
chan->master_vol = vol;
@ -706,8 +697,8 @@ SND_UpdateAmbientSounds (void)
void
SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
{
int i, j;
int total;
int i, j;
int total;
channel_t *ch;
channel_t *combine;
@ -724,7 +715,7 @@ SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
combine = NULL;
// update spatialization for static and dynamic sounds
// update spatialization for static and dynamic sounds
ch = channels + NUM_AMBIENTS;
for (i = NUM_AMBIENTS; i < total_channels; i++, ch++) {
if (!ch->sfx)
@ -786,16 +777,16 @@ SND_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
void
SND_GetSoundtime (void)
{
int samplepos;
static int buffers;
static int oldsamplepos;
int fullsamples;
int samplepos;
static int buffers;
static int oldsamplepos;
int fullsamples;
fullsamples = shm->samples / shm->channels;
// it is possible to miscount buffers if it has wrapped twice between
// calls to SND_Update. Oh well.
samplepos = SNDDMA_GetDMAPos ();
samplepos = S_O_GetDMAPos ();
if (samplepos < oldsamplepos) {
buffers++; // buffer wrapped
@ -824,7 +815,7 @@ void
SND_Update_ (void)
{
unsigned int endtime;
int samps;
int samps;
if (!sound_started || (snd_blocked > 0))
return;
@ -850,7 +841,7 @@ SND_Update_ (void)
SND_PaintChannels (endtime);
SNDDMA_Submit ();
S_O_Submit ();
}
/*
@ -860,10 +851,10 @@ SND_Update_ (void)
void
SND_Play (void)
{
static int hash = 345;
int i;
char name[256];
sfx_t *sfx;
static int hash = 345;
int i;
char name[256];
sfx_t *sfx;
i = 1;
while (i < Cmd_Argc ()) {
@ -881,11 +872,11 @@ SND_Play (void)
void
SND_PlayVol (void)
{
static int hash = 543;
int i;
float vol;
char name[256];
sfx_t *sfx;
static int hash = 543;
int i;
float vol;
char name[256];
sfx_t *sfx;
i = 1;
while (i < Cmd_Argc ()) {
@ -904,10 +895,10 @@ SND_PlayVol (void)
void
SND_SoundList (void)
{
int i;
sfx_t *sfx;
int i;
sfx_t *sfx;
sfxcache_t *sc;
int size, total;
int size, total;
total = 0;
for (sfx = known_sfx, i = 0; i < num_sfx; i++, sfx++) {
@ -928,7 +919,7 @@ SND_SoundList (void)
void
SND_LocalSound (const char *sound)
{
sfx_t *sfx;
sfx_t *sfx;
if (nosound->int_val)
return;
@ -940,7 +931,7 @@ SND_LocalSound (const char *sound)
Con_Printf ("S_LocalSound: can't cache %s\n", sound);
return;
}
SND_StartSound (*plugin_info_sound_data.viewentity, -1, sfx, vec3_origin,
SND_StartSound (*plugin_info_snd_render_data.viewentity, -1, sfx, vec3_origin,
1, 1);
}
@ -963,7 +954,7 @@ void
SND_BlockSound (void)
{
if (++snd_blocked == 1)
SNDDMA_BlockSound ();
S_O_BlockSound ();
}
void
@ -972,5 +963,53 @@ SND_UnblockSound (void)
if (!snd_blocked)
return;
if (!--snd_blocked)
SNDDMA_UnblockSound ();
S_O_UnblockSound ();
}
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_snd_render;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "Sound Renderer";
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.snd_render = &plugin_info_snd_render_data;
plugin_info_snd_render_data.soundtime = &soundtime;
plugin_info_snd_render_data.paintedtime = &paintedtime;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_render = &plugin_info_snd_render_funcs;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_snd_render_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_snd_render_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_snd_render_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_snd_render_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_snd_render_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_snd_render_funcs.pS_StartSound = SND_StartSound;
plugin_info_snd_render_funcs.pS_StopSound = SND_StopSound;
plugin_info_snd_render_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_snd_render_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_snd_render_funcs.pS_Update = SND_Update;
plugin_info_snd_render_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_snd_render_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_snd_render_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_snd_render_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_snd_render_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_snd_render_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_snd_render_funcs.pS_UnblockSound = SND_UnblockSound;
return &plugin_info;
}

View File

@ -0,0 +1,217 @@
/*
snd_null.c
include this instead of all the other snd_* files to have no sound
code whatsoever
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/cvar.h"
#include "QF/sound.h"
#include "QF/plugin.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 *snd_loadas8bit;
extern int paintedtime; // sample PAIRS
extern qboolean snd_initialized;
extern cvar_t *bgmvolume;
extern cvar_t *volume;
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 SND_Init_Cvars (void);
void
SND_Init (void)
{
SND_Init_Cvars ();
}
void
SND_Init_Cvars (void)
{
bgmvolume = Cvar_Get ("bgmvolume", "1", CVAR_ARCHIVE, NULL,
"CD music volume");
volume = Cvar_Get ("volume", "0.7", CVAR_ARCHIVE, NULL,
"Volume level of sounds");
snd_loadas8bit = Cvar_Get ("snd_loadas8bit", "0", CVAR_NONE, NULL,
"Toggles loading sounds as 8-bit samples");
snd_interp = Cvar_Get ("snd_interp", "1", CVAR_ARCHIVE, NULL,
"control sample interpolation");
}
void
SND_AmbientOff (void)
{
}
void
SND_AmbientOn (void)
{
}
void
SND_Shutdown (void)
{
}
void
SND_TouchSound (const char *sample)
{
}
void
SND_ClearBuffer (void)
{
}
void
SND_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
{
}
void
SND_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,
float attenuation)
{
}
void
SND_StopSound (int entnum, int entchannel)
{
}
sfx_t *
SND_PrecacheSound (const char *sample)
{
return NULL;
}
void
SND_ClearPrecache (void)
{
}
void
SND_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up)
{
}
void
SND_StopAllSounds (qboolean clear)
{
}
void
SND_BeginPrecaching (void)
{
}
void
SND_EndPrecaching (void)
{
}
void
SND_ExtraUpdate (void)
{
}
void
SND_LocalSound (const char *s)
{
}
void
SND_BlockSound (void)
{
}
void
SND_UnblockSound (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 = "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 = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
return &plugin_info;
}

View File

@ -49,8 +49,10 @@ cvar_t *bgmvolume;
cvar_t *volume;
cvar_t *snd_interp;
cvar_t *snd_plugin;
plugin_t *sndmodule = NULL;
cvar_t *snd_output;
cvar_t *snd_render;
plugin_t *snd_render_module = NULL;
plugin_t *snd_output_module = NULL;
// FIXME: ewwwies
extern double host_frametime; // From host.h
@ -62,15 +64,30 @@ 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 ();
snd_output_module = PI_LoadPlugin ("snd_output", snd_output->string);
if (!snd_output_module) {
Con_Printf ("Loading of sound output module: %s failed!\n",
snd_output->string);
} else {
snd_render_module = PI_LoadPlugin ("snd_render", snd_render->string);
if (!snd_render_module) {
Con_Printf ("Loading of sound render module: %s failed!\n",
snd_render->string);
PI_UnloadPlugin (snd_output_module);
snd_output_module = NULL;
} else {
snd_render_module->data->snd_render->worldmodel = &snd_worldmodel;
snd_render_module->data->snd_render->viewentity = &snd_viewentity;
snd_render_module->data->snd_render->host_frametime = &host_frametime;
snd_output_module->data->snd_output->soundtime
= snd_render_module->data->snd_render->soundtime;
snd_output_module->data->snd_output->paintedtime
= snd_render_module->data->snd_render->paintedtime;
snd_output_module->functions->general->p_Init ();
snd_render_module->functions->general->p_Init ();
}
}
}
@ -85,75 +102,80 @@ S_Init_Cvars (void)
"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");
snd_output = Cvar_Get ("snd_output", "null", CVAR_ARCHIVE, NULL,
"Sound Output Plugin to use");
snd_render = Cvar_Get ("snd_render", "default", CVAR_ARCHIVE, NULL,
"Sound Renderer Plugin to use");
}
void
S_AmbientOff (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_AmbientOff ();
if (snd_render_module)
snd_render_module->functions->snd_render->pS_AmbientOff ();
}
void
S_AmbientOn (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_AmbientOn ();
if (snd_render_module)
snd_render_module->functions->snd_render->pS_AmbientOn ();
}
void
S_Shutdown (void)
{
if (sndmodule) {
sndmodule->functions->general->p_Shutdown ();
PI_UnloadPlugin (sndmodule);
sndmodule = NULL;
if (snd_render_module) {
PI_UnloadPlugin (snd_render_module);
snd_render_module = NULL;
}
if (snd_output_module) {
PI_UnloadPlugin (snd_output_module);
snd_output_module = NULL;
}
}
void
S_TouchSound (const char *sample)
{
if (sndmodule)
sndmodule->functions->sound->pS_TouchSound (sample);
if (snd_render_module)
snd_render_module->functions->snd_render->pS_TouchSound (sample);
}
void
S_ClearBuffer (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_ClearBuffer ();
if (snd_render_module)
snd_render_module->functions->snd_render->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);
if (snd_render_module)
snd_render_module->functions->snd_render->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);
if (snd_render_module)
snd_render_module->functions->snd_render->pS_StartSound (entnum, entchannel, sfx, origin, fvol, attenuation);
}
void
S_StopSound (int entnum, int entchannel)
{
if (sndmodule)
sndmodule->functions->sound->pS_StopSound (entnum, entchannel);
if (snd_render_module)
snd_render_module->functions->snd_render->pS_StopSound (entnum, entchannel);
}
sfx_t *
S_PrecacheSound (const char *sample)
{
if (sndmodule)
return sndmodule->functions->sound->pS_PrecacheSound (sample);
if (snd_render_module)
return snd_render_module->functions->snd_render->pS_PrecacheSound (sample);
else
return NULL;
}
@ -161,62 +183,110 @@ S_PrecacheSound (const char *sample)
void
S_ClearPrecache (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_ClearPrecache ();
if (snd_render_module)
snd_render_module->functions->snd_render->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);
if (snd_render_module)
snd_render_module->functions->snd_render->pS_Update (origin, v_forward, v_right, v_up);
}
void
S_StopAllSounds (qboolean clear)
{
if (sndmodule)
sndmodule->functions->sound->pS_StopAllSounds (clear);
if (snd_render_module)
snd_render_module->functions->snd_render->pS_StopAllSounds (clear);
}
void
S_BeginPrecaching (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_BeginPrecaching ();
if (snd_render_module)
snd_render_module->functions->snd_render->pS_BeginPrecaching ();
}
void
S_EndPrecaching (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_EndPrecaching ();
if (snd_render_module)
snd_render_module->functions->snd_render->pS_EndPrecaching ();
}
void
S_ExtraUpdate (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_ExtraUpdate ();
if (snd_render_module)
snd_render_module->functions->snd_render->pS_ExtraUpdate ();
}
void
S_LocalSound (const char *s)
{
if (sndmodule)
sndmodule->functions->sound->pS_LocalSound (s);
if (snd_render_module)
snd_render_module->functions->snd_render->pS_LocalSound (s);
}
void
S_BlockSound (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_BlockSound ();
if (snd_render_module)
snd_render_module->functions->snd_render->pS_BlockSound ();
}
void
S_UnblockSound (void)
{
if (sndmodule)
sndmodule->functions->sound->pS_UnblockSound ();
if (snd_render_module)
snd_render_module->functions->snd_render->pS_UnblockSound ();
}
qboolean
S_O_Init (void)
{
if (snd_output_module)
return snd_output_module->functions->snd_output->pS_O_Init ();
else
return false;
}
void
S_O_Shutdown (void)
{
if (snd_output_module)
return snd_output_module->functions->snd_output->pS_O_Shutdown ();
}
int
S_O_GetDMAPos (void)
{
if (snd_output_module)
return snd_output_module->functions->snd_output->pS_O_GetDMAPos ();
else
return 0; // FIXME: good value for this?
}
void
S_O_Submit (void)
{
if (snd_output_module)
snd_output_module->functions->snd_output->pS_O_Submit ();
}
void
S_O_BlockSound (void)
{
if (snd_output_module)
snd_output_module->functions->snd_output->pS_O_BlockSound ();
}
void
S_O_UnblockSound (void)
{
if (snd_output_module)
snd_output_module->functions->snd_output->pS_O_UnblockSound ();
}

View File

@ -2,91 +2,52 @@ INCLUDES= -I$(top_srcdir)/include $(ALSA_CFLAGS) $(MME_CFLAGS) $(OSS_CFLAGS) $(S
libdir = @PLUGINDIR@
if BUILD_SND_RENDERER
SND_RENDERER = libQFsoundrenderer.la
else
SND_RENDERER =
endif
lib_LTLIBRARIES = @SND_PLUGIN_TARGETS@
EXTRA_LTLIBRARIES = libsnd_output_sdl.la libsnd_output_alsa0_5.la libsnd_output_alsa0_9.la libsnd_output_oss.la libsnd_output_sgi.la libsnd_output_sun.la libsnd_output_win.la libsnd_output_null.la libsnd_output_disk.la
lib_LTLIBRARIES = $(SND_RENDERER) @SND_PLUGIN_TARGETS@
EXTRA_LTLIBRARIES = libsound_sdl.la libsound_alsa0_5.la libsound_alsa0_9.la libsound_oss.la libsound_sgi.la libsound_sun.la libsound_win.la libsound_null.la libsound_disk.la
libsnd_output_sdl_la_LDFLAGS= -version-info 1:0:0 $(SDL_LIBS)
libsnd_output_sdl_la_SOURCES= snd_sdl.c
libsnd_output_sdl.la: $(libsnd_output_sdl_la_OBJECTS) $(libsnd_output_sdl_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_sdl_la_LDFLAGS) $(libsnd_output_sdl_la_OBJECTS) $(libsnd_output_sdl_la_LIBADD) $(LIBS)
if ASM_ARCH
ASM = libasm.la
else
ASM =
endif
libsnd_output_alsa0_5_la_LDFLAGS= -version-info 1:0:0 $(ALSA_LIBS)
libsnd_output_alsa0_5_la_SOURCES= snd_alsa_0_5.c
libsnd_output_alsa0_5.la: $(libsnd_output_alsa0_5_la_OBJECTS) $(libsnd_output_alsa0_5_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_alsa0_5_la_LDFLAGS) $(libsnd_output_alsa0_5_la_OBJECTS) $(libsnd_output_alsa0_5_la_LIBADD) $(LIBS)
noinst_LTLIBRARIES = $(ASM)
libsnd_output_alsa0_9_la_LDFLAGS= -version-info 1:0:0 $(ALSA_LIBS)
libsnd_output_alsa0_9_la_SOURCES= snd_alsa_0_9.c
libsnd_output_alsa0_9.la: $(libsnd_output_alsa0_9_la_OBJECTS) $(libsnd_output_alsa0_9_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_alsa0_9_la_LDFLAGS) $(libsnd_output_alsa0_9_la_OBJECTS) $(libsnd_output_alsa0_9_la_LIBADD) $(LIBS)
libasm_la_SOURCES = snd_mixa.S
libsnd_output_oss_la_LDFLAGS= -version-info 1:0:0 $(OSS_LIBS)
libsnd_output_oss_la_SOURCES= snd_oss.c
libsnd_output_oss.la: $(libsnd_output_oss_la_OBJECTS) $(libsnd_output_oss_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_oss_la_LDFLAGS) $(libsnd_output_oss_la_OBJECTS) $(libsnd_output_oss_la_LIBADD) $(LIBS)
libQFsoundrenderer_la_LDFLAGS= -version-info 1:0:0
libQFsoundrenderer_la_LIBADD = $(ASM)
libQFsoundrenderer_la_SOURCES= snd_dma.c snd_mem.c snd_mix.c
libQFsoundrenderer.la: $(libQFsoundrenderer_la_OBJECTS) $(libQFsoundrenderer_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libQFsoundrenderer_la_LDFLAGS) $(libQFsoundrenderer_la_OBJECTS) $(libQFsoundrenderer_la_LIBADD) $(LIBS)
libsnd_output_sgi_la_LDFLAGS= -version-info 1:0:0 $(SGISND_LIBS)
libsnd_output_sgi_la_SOURCES= snd_sgi.c
libsnd_output_sgi.la: $(libsnd_output_sgi_la_OBJECTS) $(libsnd_output_sgi_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_sgi_la_LDFLAGS) $(libsnd_output_sgi_la_OBJECTS) $(libsnd_output_sgi_la_LIBADD) $(LIBS)
libsnd_output_sun_la_LDFLAGS= -version-info 1:0:0 $(SUN_LIBS)
libsnd_output_sun_la_SOURCES= snd_sun.c
libsnd_output_sun.la: $(libsnd_output_sun_la_OBJECTS) $(libsnd_output_sun_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_sun_la_LDFLAGS) $(libsnd_output_sun_la_OBJECTS) $(libsnd_output_sun_la_LIBADD) $(LIBS)
libsound_sdl_la_LDFLAGS= -version-info 1:0:0 $(SDL_LIBS)
libsound_sdl_la_LIBADD= libQFsoundrenderer
libsound_sdl_la_SOURCES= snd_sdl.c
libsound_sdl_la_DEPENDENCIES= $(SND_RENDERER)
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)
libsnd_output_win_la_LDFLAGS= -version-info 1:0:0 $(WIN_LIBS)
libsnd_output_win_la_SOURCES= snd_win.c
libsnd_output_win.la: $(libsnd_output_win_la_OBJECTS) $(libsnd_output_win_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_win_la_LDFLAGS) $(libsnd_output_win_la_OBJECTS) $(libsnd_output_win_la_LIBADD) $(LIBS)
libsound_alsa0_5_la_LDFLAGS= -version-info 1:0:0 $(ALSA_LIBS)
libsound_alsa0_5_la_LIBADD= libQFsoundrenderer
libsound_alsa0_5_la_SOURCES= snd_alsa_0_5.c
libsound_alsa0_5_la_DEPENDENCIES= $(SND_RENDERER)
libsound_alsa0_5.la: $(libsound_alsa0_5_la_OBJECTS) $(libsound_alsa0_5_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_alsa0_5_la_LDFLAGS) $(libsound_alsa0_5_la_OBJECTS) $(libsound_alsa0_5_la_LIBADD) $(LIBS)
libsnd_output_disk_la_LDFLAGS= -version-info 1:0:0
libsnd_output_disk_la_SOURCES= snd_disk.c
libsnd_output_disk.la: $(libsnd_output_disk_la_OBJECTS) $(libsnd_output_disk_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_disk_la_LDFLAGS) $(libsnd_output_disk_la_OBJECTS) $(libsnd_output_disk_la_LIBADD) $(LIBS)
libsound_alsa0_9_la_LDFLAGS= -version-info 1:0:0 $(ALSA_LIBS)
libsound_alsa0_9_la_LIBADD= libQFsoundrenderer
libsound_alsa0_9_la_SOURCES= snd_alsa_0_9.c
libsound_alsa0_9_la_DEPENDENCIES= $(SND_RENDERER)
libsound_alsa0_9.la: $(libsound_alsa0_9_la_OBJECTS) $(libsound_alsa0_9_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsound_alsa0_9_la_LDFLAGS) $(libsound_alsa0_9_la_OBJECTS) $(libsound_alsa0_9_la_LIBADD) $(LIBS)
libsnd_output_null_la_LDFLAGS= -version-info 1:0:0
libsnd_output_null_la_SOURCES= snd_null.c
libsnd_output_null.la: $(libsnd_output_null_la_OBJECTS) $(libsnd_output_null_la_DEPENDENCIES)
$(LINK) -rpath $(pluginpath) $(libsnd_output_null_la_LDFLAGS) $(libsnd_output_null_la_OBJECTS) $(libsnd_output_null_la_LIBADD) $(LIBS)
libsound_oss_la_LDFLAGS= -version-info 1:0:0 $(OSS_LIBS)
libsound_oss_la_LIBADD= libQFsoundrenderer
libsound_oss_la_SOURCES= snd_oss.c
libsound_oss_la_DEPENDENCIES= $(SND_RENDERER)
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_LDFLAGS= -version-info 1:0:0 $(SGISND_LIBS)
libsound_sgi_la_LIBADD= libQFsoundrenderer
libsound_sgi_la_SOURCES= snd_sgi.c
libsound_sgi_la_DEPENDENCIES= $(SND_RENDERER)
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_LDFLAGS= -version-info 1:0:0 $(SUN_LIBS)
libsound_sun_la_LIBADD= libQFsoundrenderer
libsound_sun_la_SOURCES= snd_sun.c
libsound_sun_la_DEPENDENCIES= $(SND_RENDERER)
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_LDFLAGS= -version-info 1:0:0 $(WIN_LIBS)
libsound_win_la_LIBADD= libQFsoundrenderer
libsound_win_la_SOURCES= snd_win.c
libsound_win_la_DEPENDENCIES= $(SND_RENDERER)
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_LDFLAGS= -version-info 1:0:0
libsound_disk_la_LIBADD= libQFsoundrenderer
libsound_disk_la_SOURCES= snd_disk.c
libsound_disk_la_DEPENDENCIES= $(SND_RENDERER)
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_LDFLAGS= -version-info 1:0:0
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 = $(pkglib_LTLIBRARIES) libQFsoundrenderer.la @LIBRARY_SEARCH_PATH@
LIBLIST = $(pkglib_LTLIBRARIES) @LIBRARY_SEARCH_PATH@

View File

@ -74,14 +74,34 @@ static struct snd_pcm_channel_setup setup;
static snd_pcm_mmap_control_t *mmap_control = NULL;
static char *mmap_data = NULL;
static int card = -1, dev = -1;
int snd_blocked = 0;
volatile dma_t sn;
cvar_t *snd_stereo;
cvar_t *snd_rate;
cvar_t *snd_device;
cvar_t *snd_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;
snd_output_data_t plugin_info_snd_output_data;
snd_output_funcs_t plugin_info_snd_output_funcs;
void
SNDDMA_Init_Cvars (void)
{
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
"sound stereo output");
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL,
"sound playback rate. 0 is system default");
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL,
"sound device. \"\" is system default");
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL,
"sound sample depth. 0 is system default");
}
int
check_card (int card)
@ -129,6 +149,8 @@ SNDDMA_Init (void)
int rate = -1, format = -1, bps, stereo = -1, frag_size;
unsigned int mask;
SNDDMA_Init_Cvars ();
mask = snd_cards_mask ();
if (!mask) {
Con_Printf ("No sound cards detected\n");
@ -331,7 +353,8 @@ SNDDMA_Shutdown (void)
void
SNDDMA_Submit (void)
{
int count = paintedtime - soundtime;
int count = *plugin_info_snd_output_data.paintedtime
- *plugin_info_snd_output_data.soundtime;
int i, s, e;
int rc;
@ -339,7 +362,7 @@ SNDDMA_Submit (void)
return;
count += setup.buf.block.frag_size - 1;
count /= setup.buf.block.frag_size;
s = soundtime / setup.buf.block.frag_size;
s = *plugin_info_snd_output_data.soundtime / setup.buf.block.frag_size;
e = s + count;
for (i = s; i < e; i++)
mmap_control->fragments[i % setup.buf.block.frags].data = 1;
@ -366,9 +389,25 @@ SNDDMA_Submit (void)
}
}
void
SNDDMA_BlockSound (void)
{
if (++snd_blocked == 1)
snd_pcm_playback_pause (pcm_handle, 1);
}
void
SNDDMA_UnblockSound (void)
{
if (!snd_blocked)
return;
if (!--snd_blocked)
snd_pcm_playback_pause (pcm_handle, 0);
}
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "ALSA 0.5.x digital output";
@ -379,44 +418,20 @@ PluginInfo (void) {
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
}
void
SNDDMA_BlockSound (void)
{
snd_pcm_playback_pause (pcm_handle, 1);
}
void
SNDDMA_UnblockSound (void)
{
snd_pcm_playback_pause (pcm_handle, 0);
}

View File

@ -45,15 +45,34 @@ static int snd_inited;
static snd_pcm_t *pcm;
static const char *pcmname = NULL;
size_t buffer_size;
int snd_blocked = 0;
volatile dma_t sn;
cvar_t *snd_stereo;
cvar_t *snd_rate;
cvar_t *snd_device;
cvar_t *snd_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;
snd_output_data_t plugin_info_snd_output_data;
snd_output_funcs_t plugin_info_snd_output_funcs;
void
SNDDMA_Init_Cvars (void)
{
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
"sound stereo output");
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL,
"sound playback rate. 0 is system default");
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL,
"sound device. \"\" is system default");
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL,
"sound sample depth. 0 is system default");
}
qboolean
SNDDMA_Init (void)
@ -63,6 +82,8 @@ SNDDMA_Init (void)
snd_pcm_hw_params_t *hw;
snd_pcm_sw_params_t *sw;
SNDDMA_Init_Cvars ();
snd_pcm_hw_params_alloca (&hw);
snd_pcm_sw_params_alloca (&sw);
@ -265,7 +286,8 @@ SNDDMA_Submit (void)
snd_pcm_uframes_t nframes;
const snd_pcm_channel_area_t *areas;
int state;
int count = paintedtime - soundtime;
int count = *plugin_info_snd_output_data.paintedtime
- *plugin_info_snd_output_data.soundtime;
if (snd_blocked)
return;
@ -289,10 +311,26 @@ SNDDMA_Submit (void)
}
}
void
SNDDMA_BlockSound (void)
{
if (++snd_blocked == 1)
snd_pcm_pause (pcm, 1);
}
void
SNDDMA_UnblockSound (void)
{
if (!snd_blocked)
return;
if (!--snd_blocked)
snd_pcm_pause (pcm, 0);
}
plugin_t *
PluginInfo (void)
{
plugin_info.type = qfp_sound;
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "ALSA 0.9.x digital output";
@ -311,38 +349,14 @@ PluginInfo (void)
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
}
void
SNDDMA_BlockSound (void)
{
snd_pcm_pause (pcm, 1);
}
void
SNDDMA_UnblockSound (void)
{
snd_pcm_pause (pcm, 0);
}

View File

@ -53,14 +53,15 @@
static int snd_inited;
VFile *snd_file;
volatile dma_t sn;
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;
snd_output_data_t plugin_info_snd_output_data;
snd_output_funcs_t plugin_info_snd_output_funcs;
qboolean
@ -119,7 +120,8 @@ SNDDMA_Shutdown (void)
void
SNDDMA_Submit (void)
{
int count = (paintedtime - soundtime) * shm->samplebits / 8;
int count = (*plugin_info_snd_output_data.paintedtime
- *plugin_info_snd_output_data.soundtime) * shm->samplebits / 8;
if (snd_blocked)
return;
@ -127,9 +129,19 @@ SNDDMA_Submit (void)
Qwrite (snd_file, shm->buffer, count);
}
void
SNDDMA_BlockSound (void)
{
}
void
SNDDMA_UnblockSound (void)
{
}
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "disk output";
@ -142,42 +154,18 @@ PluginInfo (void) {
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
// plugin_info_general_funcs.p_Init = SNDDMA_Init; // FIXME
plugin_info_general_funcs.p_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
}
void
SNDDMA_BlockSound (void)
{
}
void
SNDDMA_UnblockSound (void)
{
}

View File

@ -56,6 +56,7 @@ static HPSTR lpData;
static LPWAVEHDR lpWaveHdr;
static HWAVEOUT hWaveOut;
static DWORD gSndBufSize;
volatile dma_t sn;
/* MME Callback function

View File

@ -1,7 +1,7 @@
/*
snd_oss.c
OSS sound plugin.
OSS sound output plugin.
Copyright (C) 1996-1997 Id Software, Inc.
@ -66,6 +66,11 @@
static int audio_fd;
static int snd_inited;
static const char *snd_dev = "/dev/dsp";
volatile dma_t sn;
cvar_t *snd_stereo;
cvar_t *snd_rate;
cvar_t *snd_device;
cvar_t *snd_bits;
static int tryrates[] = { 11025, 22050, 22051, 44100, 8000 };
@ -74,8 +79,21 @@ 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;
snd_output_data_t plugin_info_snd_output_data;
snd_output_funcs_t plugin_info_snd_output_funcs;
void
SNDDMA_Init_Cvars (void)
{
snd_stereo = Cvar_Get ("snd_stereo", "1", CVAR_ROM, NULL,
"sound stereo output");
snd_rate = Cvar_Get ("snd_rate", "0", CVAR_ROM, NULL,
"sound playback rate. 0 is system default");
snd_device = Cvar_Get ("snd_device", "", CVAR_ROM, NULL,
"sound device. \"\" is system default");
snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL,
"sound sample depth. 0 is system default");
}
qboolean
SNDDMA_Init (void)
@ -90,6 +108,8 @@ SNDDMA_Init (void)
snd_inited = 0;
SNDDMA_Init_Cvars ();
// open snd_dev, confirm capability to mmap, and get size of dma buffer
if (snd_device->string[0])
snd_dev = snd_device->string;
@ -302,48 +322,6 @@ 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 = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
return &plugin_info;
}
void
SNDDMA_BlockSound (void)
@ -354,3 +332,34 @@ void
SNDDMA_UnblockSound (void)
{
}
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_snd_output;
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.snd_output = &plugin_info_snd_output_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
plugin_info_general_funcs.p_Shutdown = NULL;
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
}

View File

@ -58,8 +58,8 @@ 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;
snd_output_data_t plugin_info_snd_output_data;
snd_output_funcs_t plugin_info_snd_output_funcs;
static void
@ -77,7 +77,7 @@ paint_audio (void *unused, Uint8 * stream, int len)
shm->samplepos += streamsamples;
while (shm->samplepos >= shm->samples)
shm->samplepos -= shm->samples;
SND_PaintChannels (soundtime + streamsamples);
SND_PaintChannels (*plugin_info_snd_output_data.soundtime + streamsamples);
if (shm->samplepos + streamsamples <= shm->samples)
memcpy (stream, shm->buffer + sampleposbytes, len);
@ -87,7 +87,7 @@ paint_audio (void *unused, Uint8 * stream, int len)
memcpy (stream + samplesbytes - sampleposbytes, shm->buffer, len -
(samplesbytes - sampleposbytes));
}
soundtime += streamsamples;
*plugin_info_snd_output_data.soundtime += streamsamples;
}
}
@ -204,9 +204,19 @@ SNDDMA_Submit (void)
SDL_LockAudio();
}
void
SNDDMA_BlockSound (void)
{
}
void
SNDDMA_UnblockSound (void)
{
}
plugin_t *
PluginInfo (void) {
plugin_info.type = qfp_sound;
plugin_info.type = qfp_snd_output;
plugin_info.api_version = QFPLUGIN_VERSION;
plugin_info.plugin_version = "0.1";
plugin_info.description = "SDL digital output";
@ -219,42 +229,18 @@ PluginInfo (void) {
plugin_info_data.general = &plugin_info_general_data;
plugin_info_data.input = NULL;
plugin_info_data.sound = &plugin_info_sound_data;
plugin_info_data.snd_output = &plugin_info_snd_output_data;
plugin_info_funcs.general = &plugin_info_general_funcs;
plugin_info_funcs.input = NULL;
plugin_info_funcs.sound = &plugin_info_sound_funcs;
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
plugin_info_general_funcs.p_Init = SND_Init;
plugin_info_general_funcs.p_Shutdown = SND_Shutdown;
plugin_info_sound_funcs.pS_AmbientOff = SND_AmbientOff;
plugin_info_sound_funcs.pS_AmbientOn = SND_AmbientOn;
plugin_info_sound_funcs.pS_TouchSound = SND_TouchSound;
plugin_info_sound_funcs.pS_ClearBuffer = SND_ClearBuffer;
plugin_info_sound_funcs.pS_StaticSound = SND_StaticSound;
plugin_info_sound_funcs.pS_StartSound = SND_StartSound;
plugin_info_sound_funcs.pS_StopSound = SND_StopSound;
plugin_info_sound_funcs.pS_PrecacheSound = SND_PrecacheSound;
plugin_info_sound_funcs.pS_ClearPrecache = SND_ClearPrecache;
plugin_info_sound_funcs.pS_Update = SND_Update;
plugin_info_sound_funcs.pS_StopAllSounds = SND_StopAllSounds;
plugin_info_sound_funcs.pS_BeginPrecaching = SND_BeginPrecaching;
plugin_info_sound_funcs.pS_EndPrecaching = SND_EndPrecaching;
plugin_info_sound_funcs.pS_ExtraUpdate = SND_ExtraUpdate;
plugin_info_sound_funcs.pS_LocalSound = SND_LocalSound;
plugin_info_sound_funcs.pS_BlockSound = SND_BlockSound;
plugin_info_sound_funcs.pS_UnblockSound = SND_UnblockSound;
// plugin_info_general_funcs.p_Init = SNDDMA_Init; // FIXME
plugin_info_general_funcs.p_Shutdown = SNDDMA_Shutdown;
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
return &plugin_info;
}
void
SNDDMA_BlockSound (void)
{
}
void
SNDDMA_UnblockSound (void)
{
}

View File

@ -49,6 +49,7 @@ static unsigned char *dma_buffer, *write_buffer;
static int bufsize;
static int wbufp;
static int framecount;
volatile dma_t sn;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
@ -291,16 +292,16 @@ SNDDMA_Submit (void)
int bytes, b;
unsigned char *p;
int idx;
int stop = paintedtime;
int stop = *plugin_info_snd_output_data.paintedtime;
if (snd_blocked)
return;
if (paintedtime < wbufp)
if (*plugin_info_snd_output_data.paintedtime < wbufp)
wbufp = 0; // reset
bsize = shm->channels * (shm->samplebits / 8);
bytes = (paintedtime - wbufp) * bsize;
bytes = (*plugin_info_snd_output_data.paintedtime - wbufp) * bsize;
if (!bytes)
return;

View File

@ -63,6 +63,7 @@ static audio_info_t info;
unsigned char dma_buffer[BUFFER_SIZE];
unsigned char pend_buffer[BUFFER_SIZE];
int pending;
volatile dma_t sn;
plugin_t plugin_info;
plugin_data_t plugin_info_data;
@ -205,16 +206,16 @@ SNDDMA_Submit (void)
static unsigned char writebuf[1024];
unsigned char *p;
int idx;
int stop = paintedtime;
int stop = *plugin_info_snd_output_data.paintedtime;
if (snd_blocked)
return;
if (paintedtime < wbufp)
if (*plugin_info_snd_output_data.paintedtime < wbufp)
wbufp = 0; // reset
bsize = shm->channels * (shm->samplebits / 8);
bytes = (paintedtime - wbufp) * bsize;
bytes = (*plugin_info_snd_output_data.paintedtime - wbufp) * bsize;
if (!bytes)
return;

View File

@ -59,6 +59,7 @@ static qboolean primary_format_set;
static int sample16;
static int snd_sent, snd_completed;
volatile dma_t sn;
/*
* Global variables. Must be visible to window-procedure function

View File

@ -615,7 +615,6 @@ static plugin_funcs_t plugin_info_funcs = {
&plugin_info_general_funcs,
0,
0,
0,
&plugin_info_console_funcs,
};
@ -623,7 +622,6 @@ static plugin_data_t plugin_info_data = {
&plugin_info_general_data,
0,
0,
0,
&plugin_info_console_data,
};

View File

@ -194,7 +194,6 @@ static plugin_funcs_t plugin_info_funcs = {
&plugin_info_general_funcs,
0,
0,
0,
&plugin_info_console_funcs,
};
@ -202,7 +201,6 @@ static plugin_data_t plugin_info_data = {
&plugin_info_general_data,
0,
0,
0,
&plugin_info_console_data,
};

View File

@ -165,7 +165,7 @@ PI_UnloadPlugin (plugin_t *plugin)
&& plugin->functions->general->p_Shutdown) {
plugin->functions->general->p_Shutdown ();
} else {
Con_Printf ("Warning: No shutdown function for plugin!");
Con_Printf ("Warning: No shutdown function for type %d plugin!\n", plugin->type);
}
#if defined(HAVE_DLOPEN)
return (dlclose (plugin->handle) == 0);