Can now compile OpenAL and MixSDL into the same binary. use '-a' to

enable OpenAL at runtime


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@655 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
ghaushe
2003-02-03 16:25:46 +00:00
parent 60d6d6bbab
commit f91e06d2e2
17 changed files with 515 additions and 55 deletions
+12 -12
View File
@@ -107,26 +107,26 @@ graphics_opengl_action() {
} }
CHOICE_graphics_DEFAULT=opengl CHOICE_graphics_DEFAULT=opengl
CHOICE_sound_OPTIONS="openal mixsdl" CHOICE_sound_OPTIONS="mixsdl openal"
CHOICE_sound_TITLE="Sound backend" CHOICE_sound_TITLE="Sound backend"
CHOICE_sound_OPTION_openal_TITLE="Use OpenAL for sound (experimental)"
CHOICE_sound_OPTION_openal_PRECOND="have_library openal"
CHOICE_sound_OPTION_openal_ACTION=sound_openal_action
sound_openal_action() {
CFLAGS="$CFLAGS -DSOUNDMODULE_OPENAL"
SOUNDMODULE=openal
use_library openal
use_library vorbisfile
# use_library vorbis
}
CHOICE_sound_OPTION_mixsdl_TITLE="Use MixSDL for sound" CHOICE_sound_OPTION_mixsdl_TITLE="Use MixSDL for sound"
CHOICE_sound_OPTION_mixsdl_ACTION=sound_mixsdl_action CHOICE_sound_OPTION_mixsdl_ACTION=sound_mixsdl_action
sound_mixsdl_action() { sound_mixsdl_action() {
CFLAGS="$CFLAGS -DSOUNDMODULE_MIXSDL" CFLAGS="$CFLAGS -DSOUNDMODULE_SDL"
SOUNDMODULE=mixsdl SOUNDMODULE=mixsdl
use_library vorbisfile use_library vorbisfile
# use_library vorbis # use_library vorbis
} }
CHOICE_sound_OPTION_openal_TITLE="Include OpenAL support (experimental)"
CHOICE_sound_OPTION_openal_PRECOND="have_library openal"
CHOICE_sound_OPTION_openal_ACTION=sound_openal_action
sound_openal_action() {
CFLAGS="$CFLAGS -DHAVE_OPENAL -DSOUNDMODULE_SDL"
SOUNDMODULE=openal
use_library openal
use_library vorbisfile
# use_library vorbis
}
CHOICE_sound_DEFAULT=mixsdl CHOICE_sound_DEFAULT=mixsdl
CHOICE_link_OPTIONS="static dynamic" CHOICE_link_OPTIONS="static dynamic"
+3 -3
View File
@@ -1,10 +1,10 @@
if [ "$uqm_SOUNDMODULE" = openal ]; then if [ "$uqm_SOUNDMODULE" = openal ]; then
uqm_SUBDIRS="openal decoders" uqm_SUBDIRS="openal mixsdl decoders"
uqm_CFLAGS="$uqm_CFLAGS -DSOUNDMODULE_OPENAL" uqm_CFLAGS="$uqm_CFLAGS -DHAVE_OPENAL"
else # mixsdl else # mixsdl
uqm_SUBDIRS="mixsdl decoders" uqm_SUBDIRS="mixsdl decoders"
uqm_CFLAGS="$uqm_CFLAGS -DSOUNDMODULE_MIXSDL" uqm_CFLAGS="$uqm_CFLAGS -DSOUNDMODULE_MIXSDL"
fi fi
uqm_CFILES="fileinst.c resinst.c sound_common.c sound.c sfx.c music.c stream.c trackplayer.c" uqm_CFILES="fileinst.c resinst.c sound_common.c sound.c sfx.c music.c stream.c trackplayer.c sound_chooser.c"
@@ -19,8 +19,6 @@
* from SDL_mixer * from SDL_mixer
*/ */
#ifdef SOUNDMODULE_MIXSDL
#include "starcon.h" #include "starcon.h"
#include "mixer.h" #include "mixer.h"
#include "libs/misc.h" #include "libs/misc.h"
@@ -1933,4 +1931,3 @@ void mixSDL_mix_channels (void *userdata, uint8 *stream, sint32 len)
(void)userdata; // satisfying compiler (void)userdata; // satisfying compiler
} }
#endif
@@ -16,13 +16,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifdef SOUNDMODULE_MIXSDL
#include "libs/graphics/sdl/sdl_common.h" #include "libs/graphics/sdl/sdl_common.h"
#include "libs/sound/sound.h" #include "libs/sound/sound.h"
static Task StreamDecoderTask; static Task StreamDecoderTask;
int int
TFB_InitSound (int driver, int flags) TFB_mixSDL_InitSound (int driver, int flags)
{ {
int i; int i;
char SoundcardName[256]; char SoundcardName[256];
@@ -103,7 +102,7 @@ TFB_InitSound (int driver, int flags)
} }
void void
TFB_UninitSound (void) TFB_mixSDL_UninitSound (void)
{ {
int i; int i;
@@ -129,5 +128,3 @@ TFB_UninitSound (void)
SoundDecoder_Uninit (); SoundDecoder_Uninit ();
mixSDL_CloseAudio (); mixSDL_CloseAudio ();
} }
#endif
-3
View File
@@ -14,8 +14,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#if defined SOUNDMODULE_MIXSDL || defined SOUNDMODULE_OPENAL
#include "sound.h" #include "sound.h"
#include "options.h" #include "options.h"
#include "file.h" #include "file.h"
@@ -216,4 +214,3 @@ _ReleaseMusicData (MEM_HANDLE handle)
return (TRUE); return (TRUE);
} }
#endif
@@ -14,7 +14,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifdef SOUNDMODULE_OPENAL #ifdef HAVE_OPENAL
#include "libs/sound/sound.h" #include "libs/sound/sound.h"
@@ -27,7 +27,7 @@ static Task StreamDecoderTask;
int int
TFB_InitSound (int driver, int flags) TFB_alInitSound (int driver, int flags)
{ {
int i; int i;
TFB_DecoderFormats formats = TFB_DecoderFormats formats =
@@ -109,7 +109,7 @@ TFB_InitSound (int driver, int flags)
} }
void void
TFB_UninitSound (void) TFB_alUninitSound (void)
{ {
int i; int i;
-4
View File
@@ -14,8 +14,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#if defined SOUNDMODULE_MIXSDL || defined SOUNDMODULE_OPENAL
#ifdef WIN32 #ifdef WIN32
#include <io.h> #include <io.h>
#endif #endif
@@ -262,5 +260,3 @@ DestroySound(SOUND_REF target)
{ {
return _ReleaseSoundBankData ((MEM_HANDLE) target); return _ReleaseSoundBankData ((MEM_HANDLE) target);
} }
#endif
-4
View File
@@ -16,13 +16,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#if defined SOUNDMODULE_MIXSDL || defined SOUNDMODULE_OPENAL
#include "libs/sound/sound_common.h" #include "libs/sound/sound_common.h"
#include "sound.h" #include "sound.h"
TFB_SoundSource soundSource[NUM_SOUNDSOURCES]; TFB_SoundSource soundSource[NUM_SOUNDSOURCES];
static Task StreamDecoderTask;
void void
@@ -137,4 +134,3 @@ void SetSpeechVolume (float volume)
TFBSound_Sourcef (soundSource[SPEECH_SOURCE].handle, TFBSOUND_GAIN, volume); TFBSound_Sourcef (soundSource[SPEECH_SOURCE].handle, TFBSOUND_GAIN, volume);
} }
#endif
+3 -3
View File
@@ -19,10 +19,10 @@
#include "libs/strings/strintrn.h" #include "libs/strings/strintrn.h"
#include "libs/sound/sndintrn.h" #include "libs/sound/sndintrn.h"
#include "libs/sound/sound_common.h" #include "libs/sound/sound_common.h"
#if defined SOUNDMODULE_MIXSDL #ifdef HAVE_OPENAL
#include "libs/sound/sound_chooser.h"
#else
#include "mixsdl/sound_mixsdl.h" #include "mixsdl/sound_mixsdl.h"
#elif defined SOUNDMODULE_OPENAL
#include "openal/sound_openal.h"
#endif #endif
#include "decoders/decoder.h" #include "decoders/decoder.h"
+317
View File
@@ -0,0 +1,317 @@
/*
* 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Mixer abstraction layer for MixSDL
*/
#ifdef HAVE_OPENAL
#include "libs/sound/sound_common.h"
#include "libs/sound/sound_chooser.h"
#include <stdio.h>
static unsigned int tfb_enum_lookup[TFBSOUND_ENUMSIZE];
unsigned int TFBSOUND_NO_ERROR;
int TFBSOUND_PAUSED;
int TFBSOUND_PLAYING;
unsigned int TFBSOUND_FORMAT_MONO16;
unsigned int TFBSOUND_FORMAT_STEREO16;
unsigned int TFBSOUND_FORMAT_STEREO8;
unsigned int TFBSOUND_FORMAT_MONO8;
/*************************************************
* General interface
*/
uint32
TFBSound_GetError (void)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
return (alGetError ());
else
return (mixSDL_GetError ());
}
bool
TFBSound_OpenAudio (uint32 freq, uint32 format, uint32 chunksize)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
{
fprintf (stderr, "OpenAudio is not supported for openAL\n");
return (0);
}
else
return (mixSDL_OpenAudio (freq, format, chunksize));
}
void
TFBSound_CloseAudio (void)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
fprintf (stderr, "CloseAudio is not supported for openAL\n");
else
mixSDL_CloseAudio ();
}
bool
TFBSound_QuerySpec (uint32 *freq, uint32 *format, uint32 *channels)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
{
fprintf (stderr, "QuerySpec is not supported for openAL\n");
return (0);
}
else
return (mixSDL_QuerySpec (freq, format, channels));
}
/*************************************************
* Sources
*/
void
TFBSound_GenSources (uint32 n, mixSDL_Object *psrcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alGenSources (n, (ALuint *)psrcobj);
else
mixSDL_GenSources (n, (TFBSound_Object *)psrcobj);
}
void TFBSound_DeleteSources (uint32 n, TFBSound_Object *psrcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alDeleteSources (n, (ALuint *)psrcobj);
else
mixSDL_DeleteSources (n, (mixSDL_Object *)psrcobj);
}
bool
TFBSound_IsSource (TFBSound_Object srcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
return (alIsSource ((ALuint)srcobj));
else
return (mixSDL_IsSource ((mixSDL_Object)srcobj));
}
void
TFBSound_Sourcei (TFBSound_Object srcobj, TFBSound_SourceProp pname,
TFBSound_IntVal value)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourcei ((ALuint) srcobj, (ALenum) tfb_enum_lookup[pname], (ALint) value);
else
mixSDL_Sourcei ((mixSDL_Object) srcobj,
(mixSDL_SourceProp) tfb_enum_lookup[pname], (mixSDL_IntVal) value);
}
void
TFBSound_Sourcef (TFBSound_Object srcobj, TFBSound_SourceProp pname, float value)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourcef ((ALuint) srcobj, (ALenum) tfb_enum_lookup[pname], value);
else
mixSDL_Sourcef ((mixSDL_Object) srcobj,
(mixSDL_SourceProp) tfb_enum_lookup[pname], value);
}
void
TFBSound_GetSourcei (TFBSound_Object srcobj, TFBSound_SourceProp pname,
TFBSound_IntVal *value)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alGetSourcei ((ALuint) srcobj, (ALenum) tfb_enum_lookup[pname], (ALint *)value);
else
mixSDL_GetSourcei ((mixSDL_Object) srcobj,
(mixSDL_SourceProp) tfb_enum_lookup[pname], (mixSDL_IntVal *)value);
}
void
TFBSound_GetSourcef (TFBSound_Object srcobj, TFBSound_SourceProp pname,
float *value)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alGetSourcef ((ALuint) srcobj, (ALenum) tfb_enum_lookup[pname], value);
else
mixSDL_GetSourcef ((mixSDL_Object) srcobj,
(mixSDL_SourceProp) tfb_enum_lookup[pname], value);
}
void
TFBSound_SourceRewind (TFBSound_Object srcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourceRewind ((ALuint) srcobj);
else
mixSDL_SourceRewind ((mixSDL_Object) srcobj);
}
void
TFBSound_SourcePlay (TFBSound_Object srcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourcePlay ((ALuint) srcobj);
else
mixSDL_SourcePlay ((mixSDL_Object) srcobj);
}
void
TFBSound_SourcePause (TFBSound_Object srcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourcePause ((ALuint) srcobj);
else
mixSDL_SourcePause ((mixSDL_Object) srcobj);
}
void
TFBSound_SourceStop (TFBSound_Object srcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourceStop ((ALuint) srcobj);
else
mixSDL_SourceStop ((mixSDL_Object) srcobj);
}
void
TFBSound_SourceQueueBuffers (TFBSound_Object srcobj, uint32 n,
TFBSound_Object* pbufobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourceQueueBuffers ((ALuint) srcobj, n,(ALuint *) pbufobj);
else
mixSDL_SourceQueueBuffers ((mixSDL_Object) srcobj, n,
(mixSDL_Object*) pbufobj);
}
void
TFBSound_SourceUnqueueBuffers (TFBSound_Object srcobj, uint32 n,
TFBSound_Object* pbufobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourceUnqueueBuffers ((ALuint) srcobj, n, (ALuint *) pbufobj);
else
mixSDL_SourceUnqueueBuffers ((mixSDL_Object) srcobj, n,
(mixSDL_Object*) pbufobj);
}
/*************************************************
* Buffers
*/
void
TFBSound_GenBuffers (uint32 n, TFBSound_Object *pbufobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alGenBuffers (n, (ALuint *)pbufobj);
else
mixSDL_GenBuffers (n, (mixSDL_Object *)pbufobj);
}
void
TFBSound_DeleteBuffers (uint32 n, TFBSound_Object *pbufobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alDeleteBuffers (n, (ALuint *)pbufobj);
else
mixSDL_DeleteBuffers (n, (mixSDL_Object *)pbufobj);
}
bool
TFBSound_IsBuffer (TFBSound_Object bufobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
return (alIsBuffer ((ALuint) bufobj));
else
return (mixSDL_IsBuffer ((mixSDL_Object) bufobj));
}
void
TFBSound_GetBufferi (TFBSound_Object bufobj, TFBSound_BufferProp pname,
TFBSound_IntVal *value)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alGetBufferi ((ALuint) bufobj, (ALenum) tfb_enum_lookup[pname], (ALint *)value);
else
mixSDL_GetBufferi ((mixSDL_Object) bufobj,
(mixSDL_BufferProp) tfb_enum_lookup[pname], (mixSDL_IntVal *)value);
}
void
TFBSound_BufferData (TFBSound_Object bufobj, uint32 format, void* data,
uint32 size, uint32 freq)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alBufferData ((ALuint) bufobj, (ALenum) format, data, size, freq);
else
mixSDL_BufferData ((mixSDL_Object) bufobj, format, data, size, freq);
}
void
TFBSound_ConvertBuffer (uint32 srcfmt, void* srcdata, uint32 srcsize,
uint32 srcfreq, uint32 dstfmt, void* dstdata,
uint32 dstsize, uint32 dstfreq)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
fprintf (stderr, "ConvertBuffer is not supported bu openAL\n");
else
mixSDL_ConvertBuffer (srcfmt, srcdata, srcsize, srcfreq, dstfmt, dstdata,
dstsize, dstfreq);
}
int
TFB_choose_InitSound (int driver, int flags)
{
if (driver == TFB_SOUNDDRIVER_OPENAL)
{
SoundDriver = driver;
tfb_enum_lookup[TFBSOUND_GAIN] = AL_GAIN;
tfb_enum_lookup[TFBSOUND_BUFFER] = AL_BUFFER;
tfb_enum_lookup[TFBSOUND_SOURCE_STATE] = AL_SOURCE_STATE;
tfb_enum_lookup[TFBSOUND_LOOPING] = AL_LOOPING;
tfb_enum_lookup[TFBSOUND_BUFFERS_PROCESSED] = AL_BUFFERS_PROCESSED;
tfb_enum_lookup[TFBSOUND_BUFFERS_QUEUED] = AL_BUFFERS_QUEUED;
tfb_enum_lookup[TFBSOUND_SIZE] = AL_SIZE;
TFBSOUND_NO_ERROR = AL_NO_ERROR;
TFBSOUND_PAUSED = AL_PAUSED;
TFBSOUND_PLAYING = AL_PLAYING;
TFBSOUND_FORMAT_MONO16 = AL_FORMAT_MONO16;
TFBSOUND_FORMAT_STEREO16 = AL_FORMAT_STEREO16;
TFBSOUND_FORMAT_MONO8 = AL_FORMAT_MONO8;
TFBSOUND_FORMAT_STEREO8 = AL_FORMAT_STEREO8;
return (TFB_alInitSound (driver, flags));
}
else
{
SoundDriver = driver;
tfb_enum_lookup[TFBSOUND_GAIN] = MIX_GAIN;
tfb_enum_lookup[TFBSOUND_BUFFER] = MIX_BUFFER;
tfb_enum_lookup[TFBSOUND_SOURCE_STATE] = MIX_SOURCE_STATE;
tfb_enum_lookup[TFBSOUND_LOOPING] = MIX_LOOPING;
tfb_enum_lookup[TFBSOUND_BUFFERS_PROCESSED] = MIX_BUFFERS_PROCESSED;
tfb_enum_lookup[TFBSOUND_BUFFERS_QUEUED] = MIX_BUFFERS_QUEUED;
tfb_enum_lookup[TFBSOUND_SIZE] = MIX_SIZE;
TFBSOUND_NO_ERROR = MIX_NO_ERROR;
TFBSOUND_PAUSED = MIX_PAUSED;
TFBSOUND_PLAYING = MIX_PLAYING;
TFBSOUND_FORMAT_MONO16 = MIX_FORMAT_MONO16;
TFBSOUND_FORMAT_STEREO16 = MIX_FORMAT_STEREO16;
TFBSOUND_FORMAT_MONO8 = MIX_FORMAT_MONO8;
TFBSOUND_FORMAT_STEREO8 = MIX_FORMAT_STEREO8;
return (TFB_mixSDL_InitSound (driver, flags));
}
}
#endif
+126
View File
@@ -0,0 +1,126 @@
/*
* 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Simple mixer for use with SDL_audio
*/
#ifndef SOUNDCHOOSER_H
#define SOUNDCHOOSER_H
#ifdef WIN32
#include <al.h>
#include <alc.h>
#pragma comment (lib, "OpenAL32.lib")
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif
#include "mixsdl/mixer.h"
#include "openal/mixer.h"
#include "types.h"
int TFB_mixSDL_InitSound (int driver, int flags);
#ifdef HAVE_OPENAL
int TFB_choose_InitSound (int driver, int flags);
int TFB_alInitSound (int driver, int flags);
#endif
void TFB_mixSDL_UninitSound (void);
#ifdef HAVE_OPENAL
void TFB_alUninitSound (void);
#endif
/*************************************************
* Interface Types
*/
typedef unsigned int TFBSound_Object;
typedef int TFBSound_IntVal;
typedef const int TFBSound_SourceProp;
typedef const int TFBSound_BufferProp;
/*************************************************
* General interface
*/
uint32 TFBSound_GetError (void);
bool TFBSound_OpenAudio (uint32 freq, uint32 format, uint32 chunksize);
void TFBSound_CloseAudio (void);
bool TFBSound_QuerySpec (uint32 *freq, uint32 *format, uint32 *channels);
/*************************************************
* Sources
*/
void TFBSound_GenSources (uint32 n, TFBSound_Object *psrcobj);
void TFBSound_DeleteSources (uint32 n, TFBSound_Object *psrcobj);
bool TFBSound_IsSource (TFBSound_Object srcobj);
void TFBSound_Sourcei (TFBSound_Object srcobj, TFBSound_SourceProp pname,
TFBSound_IntVal value);
void TFBSound_Sourcef (TFBSound_Object srcobj, TFBSound_SourceProp pname,
float value);
void TFBSound_GetSourcei (TFBSound_Object srcobj, TFBSound_SourceProp pname,
TFBSound_IntVal *value);
void TFBSound_GetSourcef (TFBSound_Object srcobj, TFBSound_SourceProp pname,
float *value);
void TFBSound_SourceRewind (TFBSound_Object srcobj);
void TFBSound_SourcePlay (TFBSound_Object srcobj);
void TFBSound_SourcePause (TFBSound_Object srcobj);
void TFBSound_SourceStop (TFBSound_Object srcobj);
void TFBSound_SourceQueueBuffers (TFBSound_Object srcobj, uint32 n,
TFBSound_Object* pbufobj);
void TFBSound_SourceUnqueueBuffers (TFBSound_Object srcobj, uint32 n,
TFBSound_Object* pbufobj);
/*************************************************
* Buffers
*/
void TFBSound_GenBuffers (uint32 n, TFBSound_Object *pbufobj);
void TFBSound_DeleteBuffers (uint32 n, TFBSound_Object *pbufobj);
bool TFBSound_IsBuffer (TFBSound_Object bufobj);
void TFBSound_GetBufferi (TFBSound_Object bufobj, TFBSound_BufferProp pname,
TFBSound_IntVal *value);
void TFBSound_BufferData (TFBSound_Object bufobj, uint32 format, void* data,
uint32 size, uint32 freq);
void TFBSound_ConvertBuffer (uint32 srcfmt, void* srcdata, uint32 srcsize,
uint32 srcfreq, uint32 dstfmt, void* dstdata,
uint32 dstsize, uint32 dstfreq);
#define TFBSound_BufferData_Linux alBufferWriteData_LOKI
enum
{
TFBSOUND_GAIN = 0,
TFBSOUND_BUFFER,
TFBSOUND_SOURCE_STATE,
TFBSOUND_LOOPING,
TFBSOUND_BUFFERS_PROCESSED,
TFBSOUND_BUFFERS_QUEUED,
TFBSOUND_SIZE,
TFBSOUND_ENUMSIZE
};
extern int TFBSOUND_PAUSED;
extern int TFBSOUND_PLAYING;
extern unsigned int TFBSOUND_NO_ERROR;
extern unsigned int TFBSOUND_FORMAT_MONO16;
extern unsigned int TFBSOUND_FORMAT_STEREO16;
extern unsigned int TFBSOUND_FORMAT_MONO8;
extern unsigned int TFBSOUND_FORMAT_STEREO8;
#endif /* SOUNDCHOOSER_H */
+32
View File
@@ -18,8 +18,11 @@
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "libs/sound/sound_common.h" #include "libs/sound/sound_common.h"
#include "libs/sound/sound.h"
#include "libs/tasklib.h" #include "libs/tasklib.h"
int SoundDriver = TFB_SOUNDDRIVER_MIXSDL;
int musicVolume = (MAX_VOLUME >> 1); int musicVolume = (MAX_VOLUME >> 1);
float musicVolumeScale = 1.0f; float musicVolumeScale = 1.0f;
float sfxVolumeScale = 1.0f; float sfxVolumeScale = 1.0f;
@@ -86,3 +89,32 @@ FadeMusic (BYTE end_vol, SIZE TimeInterval)
return (TimeOut); return (TimeOut);
} }
int
TFB_InitSound (int driver, int flags)
{
#ifdef HAVE_OPENAL
return (TFB_choose_InitSound (driver, flags));
#else
if (driver == TFB_SOUNDDRIVER_OPENAL)
{
fprintf (stderr, "OpenAL driver not compiled in, so using MixSDL\n");
driver = TFB_SOUNDDRIVER_MIXSDL;
}
return (TFB_mixSDL_InitSound (driver, flags));
#endif
}
void
TFB_UninitSound (void)
{
#ifdef HAVE_OPENAL
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
TFB_alUninitSound ();
else
TFB_mixSDL_UninitSound ();
#else
TFB_mixSDL_UninitSound ();
#endif
}
+3 -1
View File
@@ -22,8 +22,10 @@
// driver for TFB_InitSound // driver for TFB_InitSound
enum enum
{ {
TFB_SOUNDDRIVER_SDL TFB_SOUNDDRIVER_MIXSDL,
TFB_SOUNDDRIVER_OPENAL
}; };
extern int SoundDriver;
// flags for TFB_InitSound // flags for TFB_InitSound
#define TFB_SOUNDFLAGS_HQAUDIO (1<<0) // high quality audio #define TFB_SOUNDFLAGS_HQAUDIO (1<<0) // high quality audio
+4 -7
View File
@@ -14,8 +14,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#if defined SOUNDMODULE_MIXSDL || defined SOUNDMODULE_OPENAL
#include <assert.h> #include <assert.h>
#include "sound.h" #include "sound.h"
@@ -325,11 +323,11 @@ StreamDecoderTaskFunc (void *data)
if (decoded_bytes > 0) if (decoded_bytes > 0)
{ {
#if defined SOUNDMODULE_OPENAL && !defined (WIN32) // && !defined (MacOS and BeOS too) #if defined HAVE_OPENAL && !defined (WIN32) // && !defined (MacOS and BeOS too)
// *nix OpenAL implementation has to handle stereo data differently to avoid mixing it to mono // *nix OpenAL implementation has to handle stereo data differently to avoid mixing it to mono
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL &&
if (soundSource[i].sample->decoder->format == TFBSOUND_FORMAT_STEREO8 || (soundSource[i].sample->decoder->format == TFBSOUND_FORMAT_STEREO8 ||
soundSource[i].sample->decoder->format == TFBSOUND_FORMAT_STEREO16) soundSource[i].sample->decoder->format == TFBSOUND_FORMAT_STEREO16))
{ {
TFBSound_BufferData_Linux (buffer, soundSource[i].sample->decoder->format, TFBSound_BufferData_Linux (buffer, soundSource[i].sample->decoder->format,
soundSource[i].sample->decoder->buffer, decoded_bytes, soundSource[i].sample->decoder->buffer, decoded_bytes,
@@ -423,4 +421,3 @@ StreamDecoderTaskFunc (void *data)
return 0; return 0;
} }
#endif
-4
View File
@@ -14,8 +14,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#if defined SOUNDMODULE_MIXSDL || defined SOUNDMODULE_OPENAL
#include <assert.h> #include <assert.h>
#include "sound.h" #include "sound.h"
#include "libs/sound/trackplayer.h" #include "libs/sound/trackplayer.h"
@@ -699,5 +697,3 @@ GetSoundInfo (int max_len)
return max_len; return max_len;
return (int)(max_len * offset / length); return (int)(max_len * offset / length);
} }
#endif
+8 -2
View File
@@ -80,6 +80,7 @@ int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
int gfxdriver = TFB_GFXDRIVER_SDL_PURE; int gfxdriver = TFB_GFXDRIVER_SDL_PURE;
int snddriver = TFB_SOUNDDRIVER_MIXSDL;
int gfxflags = 0; int gfxflags = 0;
int soundflags = TFB_SOUNDFLAGS_MQAUDIO; int soundflags = TFB_SOUNDFLAGS_MQAUDIO;
int width = 640, height = 480, bpp = 16; int width = 640, height = 480, bpp = 16;
@@ -102,6 +103,7 @@ main (int argc, char *argv[])
{"bpp", 1, NULL, 'd'}, {"bpp", 1, NULL, 'd'},
{"fullscreen", 0, NULL, 'f'}, {"fullscreen", 0, NULL, 'f'},
{"opengl", 0, NULL, 'o'}, {"opengl", 0, NULL, 'o'},
{"openal", 0, NULL, 'a'},
{"scale", 1, NULL, 'c'}, {"scale", 1, NULL, 'c'},
{"scanlines", 0, NULL, 's'}, {"scanlines", 0, NULL, 's'},
{"fps", 0, NULL, 'p'}, {"fps", 0, NULL, 'p'},
@@ -131,7 +133,7 @@ main (int argc, char *argv[])
strcpy (contentdir, "content"); strcpy (contentdir, "content");
#endif #endif
while ((c = getopt_long(argc, argv, "r:d:foc:spn:?hM:S:T:m:q:ua:", long_options, &option_index)) != -1) while ((c = getopt_long(argc, argv, "r:d:foac:spn:?hM:S:T:m:q:u", long_options, &option_index)) != -1)
{ {
switch (c) { switch (c) {
case 'r': case 'r':
@@ -146,6 +148,9 @@ main (int argc, char *argv[])
case 'o': case 'o':
gfxdriver = TFB_GFXDRIVER_SDL_OPENGL; gfxdriver = TFB_GFXDRIVER_SDL_OPENGL;
break; break;
case 'a':
snddriver = TFB_SOUNDDRIVER_OPENAL;
break;
case 'c': case 'c':
if (!strcmp (optarg, "bilinear")) if (!strcmp (optarg, "bilinear"))
{ {
@@ -252,6 +257,7 @@ main (int argc, char *argv[])
printf(" -d, --bpp=BITSPERPIXEL (default 16)\n"); printf(" -d, --bpp=BITSPERPIXEL (default 16)\n");
printf(" -f, --fullscreen (default off)\n"); printf(" -f, --fullscreen (default off)\n");
printf(" -o, --opengl (default off)\n"); printf(" -o, --opengl (default off)\n");
printf(" -a, --openal (default off)\n");
printf(" -c, --scale=mode (bilinear, biadapt or biadv, default is none)\n"); printf(" -c, --scale=mode (bilinear, biadapt or biadv, default is none)\n");
printf(" -s, --scanlines (default off)\n"); printf(" -s, --scanlines (default off)\n");
printf(" -p, --fps (default off)\n"); printf(" -p, --fps (default off)\n");
@@ -293,7 +299,7 @@ main (int argc, char *argv[])
init_xform_control (); init_xform_control ();
TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp); TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);
TFB_InitSound (TFB_SOUNDDRIVER_SDL, soundflags); TFB_InitSound (snddriver, soundflags);
TFB_InitInput (TFB_INPUTDRIVER_SDL, 0); TFB_InitInput (TFB_INPUTDRIVER_SDL, 0);
AssignTask (Starcon2Main, 1024, "Starcon2Main"); AssignTask (Starcon2Main, 1024, "Starcon2Main");
+1
View File
@@ -1,3 +1,4 @@
#!/bin/bash
#!/usr/bin/bash #!/usr/bin/bash
# Substitute a string in many files. By Serge van den Boom, 20020826 # Substitute a string in many files. By Serge van den Boom, 20020826