Removed again some already deleted files which reappeared due to some

bizarre cvs glitch


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1316 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2004-01-27 19:24:30 +00:00
parent 75ef6e0412
commit ca35d119fa
14 changed files with 0 additions and 3970 deletions
@@ -1 +0,0 @@
uqm_CFILES="mixer.c sound_mixsdl.c"
File diff suppressed because it is too large Load Diff
-280
View File
@@ -1,280 +0,0 @@
/*
* 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 MIXER_H
#define MIXER_H
#include "types.h"
#include "SDL_byteorder.h"
/**
* The interface heavily influenced by OpenAL
* to the point where you should use OpenAL's
* documentation when programming the mixer.
* (some source properties are not supported)
*
* EXCEPTION: You may not queue the same buffer
* on more than one source
*/
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
# define MIX_IS_BIG_ENDIAN true
# define MIX_WANT_BIG_ENDIAN true
#else
# define MIX_IS_BIG_ENDIAN false
# define MIX_WANT_BIG_ENDIAN false
#endif
/**
* Mixer errors (see OpenAL errors)
*/
enum
{
MIX_NO_ERROR = 0,
MIX_INVALID_NAME = 0xA001U,
MIX_INVALID_ENUM = 0xA002U,
MIX_INVALID_VALUE = 0xA003U,
MIX_INVALID_OPERATION = 0xA004U,
MIX_OUT_OF_MEMORY = 0xA005U,
MIX_SDL_FAILURE = 0xA101U
};
/**
* Source properties (see OpenAL)
*/
typedef enum
{
MIX_POSITION = 0x1004,
MIX_LOOPING = 0x1007,
MIX_BUFFER = 0x1009,
MIX_GAIN = 0x100A,
MIX_SOURCE_STATE = 0x1010,
MIX_BUFFERS_QUEUED = 0x1015,
MIX_BUFFERS_PROCESSED = 0x1016
} mixSDL_SourceProp;
/**
* Source state information
*/
typedef enum
{
MIX_INITIAL = 0,
MIX_STOPPED,
MIX_PLAYING,
MIX_PAUSED,
} mixSDL_SourceState;
/**
* Sound buffer properties
*/
typedef enum
{
MIX_FREQUENCY = 0x2001,
MIX_BITS = 0x2002,
MIX_CHANNELS = 0x2003,
MIX_SIZE = 0x2004,
MIX_DATA = 0x2005
} mixSDL_BufferProp;
/**
* Buffer states: semi-private
*/
typedef enum
{
MIX_BUF_INITIAL = 0,
MIX_BUF_FILLED,
MIX_BUF_QUEUED,
MIX_BUF_PLAYING,
MIX_BUF_PROCESSED
} mixSDL_BufferState;
/** Sound buffers: format specifier.
* bits 00..07: bytes per sample
* bits 08..15: channels
* bits 15..31: meaningless
*/
#define MIX_FORMAT_DUMMYID 0x00170000
#define MIX_FORMAT_BPC(f) ((f) & 0xff)
#define MIX_FORMAT_CHANS(f) (((f) >> 8) & 0xff)
#define MIX_FORMAT_BPC_MAX 2
#define MIX_FORMAT_CHANS_MAX 2
#define MIX_FORMAT_MAKE(b, c) \
( MIX_FORMAT_DUMMYID | ((b) & 0xff) | (((c) & 0xff) << 8) )
#define MIX_FORMAT_SAMPSIZE(f) \
( MIX_FORMAT_BPC(f) * MIX_FORMAT_CHANS(f) )
typedef enum
{
MIX_FORMAT_MONO8 = MIX_FORMAT_MAKE (1, 1),
MIX_FORMAT_STEREO8 = MIX_FORMAT_MAKE (1, 2),
MIX_FORMAT_MONO16 = MIX_FORMAT_MAKE (2, 1),
MIX_FORMAT_STEREO16 = MIX_FORMAT_MAKE (2, 2)
} mixSDL_Format;
typedef enum
{
MIX_QUALITY_LOW = 0,
MIX_QUALITY_MEDIUM,
MIX_QUALITY_HIGH,
MIX_QUALITY_DEFAULT = MIX_QUALITY_MEDIUM,
MIX_QUALITY_COUNT
} mixSDL_Quality;
typedef enum
{
MIX_DRIVER_NOFLAGS = 0,
MIX_DRIVER_FAKE_DATA = 1,
MIX_DRIVER_FAKE_PLAY = 2,
MIX_DRIVER_FAKE_ALL = MIX_DRIVER_FAKE_DATA | MIX_DRIVER_FAKE_PLAY
} mixSDL_DriverFlags;
/*************************************************
* Interface Types
*/
typedef intptr_t mixSDL_Object;
typedef intptr_t mixSDL_IntVal;
typedef struct _mixSDL_Buffer
{
uint32 magic;
bool locked;
mixSDL_BufferState state;
uint8 *data;
uint32 size;
/* original buffer values for OpenAL compat */
void* orgdata;
uint32 orgfreq;
uint32 orgsize;
uint32 orgchannels;
uint32 orgchansize;
/* next buffer in chain */
struct _mixSDL_Buffer *next;
} mixSDL_Buffer;
#define mixSDL_bufMagic 0x4258494DU /* MIXB in LSB */
typedef struct
{
uint32 magic;
bool locked;
mixSDL_SourceState state;
bool looping;
float gain;
uint32 cqueued;
uint32 cprocessed;
mixSDL_Buffer *firstqueued; /* first buf in the queue */
mixSDL_Buffer *nextqueued; /* next to play, or 0 */
mixSDL_Buffer *prevqueued; /* previously played */
mixSDL_Buffer *lastqueued; /* last in queue */
uint32 curbufofs;
double curbufdelta;
} mixSDL_Source;
#define mixSDL_srcMagic 0x5358494DU /* MIXS in LSB */
typedef struct
{
const char* (* GetDriverName) (void);
const char* (* GetError) (void);
/* see SDL for description of these functions */
int (* OpenAudio) (void *desired, void *obtained);
void (* CloseAudio) (void);
void (* PauseAudio) (int pause_on);
} mixSDL_DriverInfo;
typedef const mixSDL_DriverInfo *mixSDL_Driver;
/*************************************************
* General interface
*/
uint32 mixSDL_GetError (void);
void mixSDL_UseDriver (mixSDL_Driver driver, mixSDL_DriverFlags flags);
bool mixSDL_OpenAudio (uint32 freq, uint32 format, uint32 samples_buf,
mixSDL_Quality quality);
void mixSDL_CloseAudio (void);
bool mixSDL_QuerySpec (uint32 *freq, uint32 *format, uint32 *channels);
/*************************************************
* Sources
*/
void mixSDL_GenSources (uint32 n, mixSDL_Object *psrcobj);
void mixSDL_DeleteSources (uint32 n, mixSDL_Object *psrcobj);
bool mixSDL_IsSource (mixSDL_Object srcobj);
void mixSDL_Sourcei (mixSDL_Object srcobj, mixSDL_SourceProp pname,
mixSDL_IntVal value);
void mixSDL_Sourcef (mixSDL_Object srcobj, mixSDL_SourceProp pname,
float value);
void mixSDL_Sourcefv (mixSDL_Object srcobj, mixSDL_SourceProp pname,
float *value);
void mixSDL_GetSourcei (mixSDL_Object srcobj, mixSDL_SourceProp pname,
mixSDL_IntVal *value);
void mixSDL_GetSourcef (mixSDL_Object srcobj, mixSDL_SourceProp pname,
float *value);
void mixSDL_SourceRewind (mixSDL_Object srcobj);
void mixSDL_SourcePlay (mixSDL_Object srcobj);
void mixSDL_SourcePause (mixSDL_Object srcobj);
void mixSDL_SourceStop (mixSDL_Object srcobj);
void mixSDL_SourceQueueBuffers (mixSDL_Object srcobj, uint32 n,
mixSDL_Object* pbufobj);
void mixSDL_SourceUnqueueBuffers (mixSDL_Object srcobj, uint32 n,
mixSDL_Object* pbufobj);
/*************************************************
* Buffers
*/
void mixSDL_GenBuffers (uint32 n, mixSDL_Object *pbufobj);
void mixSDL_DeleteBuffers (uint32 n, mixSDL_Object *pbufobj);
bool mixSDL_IsBuffer (mixSDL_Object bufobj);
void mixSDL_GetBufferi (mixSDL_Object bufobj, mixSDL_BufferProp pname,
mixSDL_IntVal *value);
void mixSDL_BufferData (mixSDL_Object bufobj, uint32 format, void* data,
uint32 size, uint32 freq);
/* Make sure the prop-value type is of suitable size
* it must be able to store both int and void*
* Adapted from SDL
* This will generate "negative subscript or subscript is too large"
* error during compile, if the actual size of a type is wrong
*/
#define MIX_COMPILE_TIME_ASSERT(name, x) \
typedef int mixSDL_dummy_##name [(x) * 2 - 1]
MIX_COMPILE_TIME_ASSERT (mixSDL_Object,
sizeof(mixSDL_Object) >= sizeof(void*));
MIX_COMPILE_TIME_ASSERT (mixSDL_IntVal,
sizeof(mixSDL_IntVal) >= sizeof(mixSDL_Object));
#undef MIX_COMPILE_TIME_ASSERT
#endif /* MIXER_H */
@@ -1,120 +0,0 @@
/*
* 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
* Internals
*/
#ifndef MIXERINT_H
#define MIXERINT_H
#include "types.h"
/*************************************************
* Internals
*/
/* Conversion info types and funcs */
typedef enum
{
mixConvNone = 0,
mixConvStereoUp = 1,
mixConvStereoDown = 2,
mixConvSizeUp = 4,
mixConvSizeDown = 8
} mixSDL_ConvFlags;
typedef struct
{
uint32 srcfmt;
void *srcdata;
uint32 srcsize;
uint32 srcbpc; /* bytes/sample for 1 chan */
uint32 srcchans;
uint32 srcsamples;
uint32 dstfmt;
void *dstdata;
uint32 dstsize;
uint32 dstbpc; /* bytes/sample for 1 chan */
uint32 dstchans;
uint32 dstsamples;
mixSDL_ConvFlags flags;
} mixSDL_Convertion;
static void mixSDL_ConvertBuffer_internal (mixSDL_Convertion *conv);
static void mixSDL_ResampleFlat (mixSDL_Convertion *conv);
static __inline__ sint32 mixSDL_GetSampleExt (void *src, uint32 bpc);
static __inline__ sint32 mixSDL_GetSampleInt (void *src, uint32 bpc);
static __inline__ void mixSDL_PutSampleInt (void *dst, uint32 bpc,
sint32 samp);
static __inline__ void mixSDL_PutSampleExt (void *dst, uint32 bpc,
sint32 samp);
static __inline__ sint32 mixSDL_GetResampledInt_nearest (mixSDL_Source *src, bool left);
static __inline__ sint32 mixSDL_GetResampledInt_linear (mixSDL_Source *src, bool left);
static __inline__ sint32 mixSDL_GetResampledInt_cubic (mixSDL_Source *src, bool left);
/* Source manipulation */
static void mixSDL_SourceUnqueueAll (mixSDL_Source *src);
static void mixSDL_SourceStop_internal (mixSDL_Source *src);
static void mixSDL_SourceRewind_internal (mixSDL_Source *src);
static void mixSDL_SourceActivate (mixSDL_Source* src);
static void mixSDL_SourceDeactivate (mixSDL_Source* src);
static __inline__ bool mixSDL_CheckBufferState (mixSDL_Buffer *buf,
const char* FuncName);
/* Clipping boundaries */
#define MIX_S16_MAX ((double) SINT16_MAX)
#define MIX_S16_MIN ((double) SINT16_MIN)
#define MIX_S8_MAX ((double) SINT8_MAX)
#define MIX_S8_MIN ((double) SINT8_MIN)
/* Channel gain adjustment for clipping reduction */
#define MIX_GAIN_ADJ (0.8f)
/* Clipping filter boundaries */
#define MIX_UNCLIP_AREA 30 /* percent */
#define MIX_UNCLIP_S16_AREA ((sint32) SINT16_MAX * MIX_UNCLIP_AREA / 100)
#define MIX_UNCLIP_S16_MAX ((sint32) SINT16_MAX - MIX_UNCLIP_S16_AREA)
#define MIX_UNCLIP_S16_MIN ((sint32) SINT16_MIN + MIX_UNCLIP_S16_AREA)
#define MIX_UNCLIP_S8_AREA ((sint32) SINT8_MAX * MIX_UNCLIP_AREA / 100)
#define MIX_UNCLIP_S8_MAX ((sint32) SINT8_MAX - MIX_UNCLIP_S8_AREA)
#define MIX_UNCLIP_S8_MIN ((sint32) SINT8_MIN + MIX_UNCLIP_S8_AREA)
/* The Mixer */
static void mixSDL_mix_channels (void *userdata, uint8 *stream,
sint32 len);
static void mixSDL_mix_lowq (void *userdata, uint8 *stream, sint32 len);
static void mixSDL_mix_fake (void *userdata, uint8 *stream, sint32 len);
static void mixSDL_UnclipWorkBuffer (sint32 *data, sint32 *end_data,
uint32 step);
static __inline__ bool mixSDL_SourceGetNextSample (mixSDL_Source *src,
sint32* samp, bool left);
static __inline__ bool mixSDL_SourceGetFakeSample (mixSDL_Source *src,
sint32* psamp, bool left);
/* SDL driver */
static const char* mixSDL_DriverGetName (void);
static const char* mixSDL_DriverGetError (void);
static int mixSDL_DriverOpenAudio (void *desired, void *obtained);
#endif /* MIXERINT_H */
@@ -1,349 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
//#include "libs/graphics/sdl/sdl_common.h"
#include "SDL.h"
#include "libs/sound/sound.h"
#include "libs/tasklib.h"
static Task StreamDecoderTask;
/*******************************************************************
* NoSound driver for MixSDL - declarations
*/
static const char* NoSound_GetDriverName (void);
static const char* NoSound_GetError (void);
static int NoSound_OpenAudio (void *desired, void *obtained);
static void NoSound_CloseAudio (void);
static void NoSound_PauseAudio (int pause_on);
/* The nosound driver */
static const
mixSDL_DriverInfo NoSound_driver =
{
NoSound_GetDriverName,
NoSound_GetError,
NoSound_OpenAudio,
NoSound_CloseAudio,
NoSound_PauseAudio
};
static SDL_AudioSpec NoSound_spec;
static Task NoSound_PlaybackTask;
static bool NoSound_Paused = true;
static const char* NoSound_ErrorStr = "";
/*******************************************************************
* Other stuff
*/
static int current_driver = 0;
int TFB_NoSound_InitSound (int driver, int flags);
/*******************************************************************
* Normal MixSDL sound
*/
int
TFB_mixSDL_InitSound (int driver, int flags)
{
int i;
char SoundcardName[256];
uint32 audio_rate, audio_channels, audio_bufsize, audio_format;
mixSDL_Quality audio_quality;
TFB_DecoderFormats formats =
{
MIX_IS_BIG_ENDIAN, MIX_WANT_BIG_ENDIAN,
MIX_FORMAT_MONO8, MIX_FORMAT_STEREO8,
MIX_FORMAT_MONO16, MIX_FORMAT_STEREO16
};
fprintf (stderr, "Initializing SDL audio subsystem.\n");
if ((SDL_InitSubSystem(SDL_INIT_AUDIO)) == -1)
{
fprintf (stderr, "Couldn't initialize audio subsystem: %s\n", SDL_GetError());
return -1;
}
fprintf (stderr, "SDL audio subsystem initialized.\n");
if (flags & TFB_SOUNDFLAGS_HQAUDIO)
{
audio_quality = MIX_QUALITY_HIGH;
audio_rate = 44100;
audio_bufsize = 4096;
}
else if (flags & TFB_SOUNDFLAGS_LQAUDIO)
{
audio_quality = MIX_QUALITY_LOW;
audio_rate = 22050;
audio_bufsize = 2048;
}
else
{
audio_quality = MIX_QUALITY_DEFAULT;
audio_rate = 44100;
audio_bufsize = 4096;
}
fprintf (stderr, "Initializing MixSDL mixer.\n");
if (!mixSDL_OpenAudio(audio_rate, MIX_FORMAT_STEREO16,
audio_bufsize, audio_quality))
{
fprintf (stderr, "Unable to open audio: %x, %s\n",
mixSDL_GetError (), SDL_GetError ());
SDL_QuitSubSystem (SDL_INIT_AUDIO);
return -1;
}
fprintf (stderr, "MixSDL Mixer initialized.\n");
atexit (TFB_UninitSound);
SDL_AudioDriverName (SoundcardName, sizeof (SoundcardName));
mixSDL_QuerySpec (&audio_rate, &audio_format, &audio_channels);
fprintf (stderr, " opened %s at %d Hz %d bit %s, %d samples audio buffer\n",
SoundcardName, audio_rate, audio_format & 0xFF,
audio_channels > 1 ? "stereo" : "mono", audio_bufsize);
fprintf (stderr, "Initializing sound decoders.\n");
SoundDecoder_Init (flags, &formats);
fprintf (stderr, "Sound decoders initialized.\n");
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
{
mixSDL_GenSources (1, &soundSource[i].handle);
soundSource[i].sample = NULL;
soundSource[i].stream_should_be_playing = FALSE;
soundSource[i].stream_mutex = CreateMutex ("MixSDL stream mutex", SYNC_CLASS_AUDIO);
soundSource[i].sbuffer = NULL;
soundSource[i].sbuf_start = 0;
soundSource[i].sbuf_size = 0;
soundSource[i].sbuf_offset = 0;
}
SetSFXVolume (sfxVolumeScale);
SetSpeechVolume (speechVolumeScale);
SetMusicVolume ((COUNT)musicVolume);
StreamDecoderTask = AssignTask (StreamDecoderTaskFunc, 1024,
"audio stream decoder");
current_driver = driver;
return 0;
}
void
TFB_mixSDL_UninitSound (void)
{
int i;
if (StreamDecoderTask)
{
ConcludeTask (StreamDecoderTask);
StreamDecoderTask = NULL;
}
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
{
if (soundSource[i].sample && soundSource[i].sample->decoder)
{
StopStream (i);
}
if (soundSource[i].sbuffer)
{
void *sbuffer = soundSource[i].sbuffer;
soundSource[i].sbuffer = NULL;
HFree (sbuffer);
}
DestroyMutex (soundSource[i].stream_mutex);
mixSDL_DeleteSources (1, &soundSource[i].handle);
}
SoundDecoder_Uninit ();
mixSDL_CloseAudio ();
}
/*******************************************************************
* NoSound driver for MixSDL
*/
int
TFB_NoSound_InitSound (int driver, int flags)
{
int i;
uint32 audio_rate, audio_channels, audio_bufsize, audio_format;
TFB_DecoderFormats formats =
{
0, 0, /* do not care about endianness */
MIX_FORMAT_MONO8, MIX_FORMAT_STEREO8,
MIX_FORMAT_MONO16, MIX_FORMAT_STEREO16
};
if (flags & TFB_SOUNDFLAGS_HQAUDIO)
{
audio_rate = 44100;
audio_bufsize = 4096;
}
else if (flags & TFB_SOUNDFLAGS_LQAUDIO)
{
audio_rate = 22050;
audio_bufsize = 2048;
}
else
{
audio_rate = 44100;
audio_bufsize = 4096;
}
fprintf (stderr, "Initializing MixSDL mixer.\n");
mixSDL_UseDriver (&NoSound_driver, MIX_DRIVER_FAKE_ALL);
if (!mixSDL_OpenAudio (audio_rate, MIX_FORMAT_STEREO16,
audio_bufsize, MIX_QUALITY_DEFAULT))
{
fprintf (stderr, "Unable to open audio: %x, %s\n",
mixSDL_GetError (), SDL_GetError ());
return -1;
}
fprintf (stderr, "MixSDL mixer initialized.\n");
atexit (TFB_UninitSound);
mixSDL_QuerySpec (&audio_rate, &audio_format, &audio_channels);
fprintf (stderr, " opened 'fake' "
"at %d Hz %d bit %s, %d samples audio buffer\n",
audio_rate, audio_format & 0xFF,
audio_channels > 1 ? "stereo" : "mono", audio_bufsize);
fprintf (stderr, "Initializing sound decoders.\n");
SoundDecoder_Init (flags, &formats);
fprintf (stderr, "Sound decoders initialized.\n");
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
{
mixSDL_GenSources (1, &soundSource[i].handle);
soundSource[i].sample = NULL;
soundSource[i].stream_should_be_playing = FALSE;
soundSource[i].stream_mutex = CreateMutex ("MixSDL stream mutex", SYNC_CLASS_AUDIO);
soundSource[i].sbuffer = NULL;
soundSource[i].sbuf_start = 0;
soundSource[i].sbuf_size = 0;
soundSource[i].sbuf_offset = 0;
}
SetSFXVolume (sfxVolumeScale);
SetSpeechVolume (speechVolumeScale);
SetMusicVolume ((COUNT)musicVolume);
StreamDecoderTask = AssignTask (StreamDecoderTaskFunc, 1024,
"audio stream decoder");
current_driver = driver;
return 0;
}
void
TFB_NoSound_UninitSound (void)
{
TFB_mixSDL_UninitSound ();
}
int
NoSound_PlaybackTaskFunc (void *data)
{
Task task = (Task)data;
uint8 *stream;
uint32 entryTime;
sint32 period, delay;
stream = (uint8 *) HMalloc (NoSound_spec.size);
period = 1000 * NoSound_spec.samples / NoSound_spec.freq;
while (!Task_ReadState (task, TASK_EXIT))
{
entryTime = SDL_GetTicks ();
if (!NoSound_Paused)
{
NoSound_spec.callback (NoSound_spec.userdata,
stream, NoSound_spec.size);
}
delay = period - (SDL_GetTicks () - entryTime);
if (delay > 0)
SDL_Delay (delay);
}
HFree (stream);
FinishTask (task);
return 0;
}
static const char*
NoSound_GetDriverName ()
{
return "NoSound";
}
static const char*
NoSound_GetError ()
{
return NoSound_ErrorStr;
}
static int
NoSound_OpenAudio (void *desired, void *obtained)
{
/* we accept anything - copy the format verbatim */
memcpy (&NoSound_spec, desired, sizeof (SDL_AudioSpec));
/* calculate the requested PCM-buffer size and silence val */
NoSound_spec.size = (NoSound_spec.format & 0x003f) / 8
* NoSound_spec.channels * NoSound_spec.samples;
NoSound_spec.silence = ((NoSound_spec.format >> 8) & 0x80) ^ 0x80;
memcpy (obtained, &NoSound_spec, sizeof (SDL_AudioSpec));
NoSound_PlaybackTask = AssignTask (NoSound_PlaybackTaskFunc, 1024,
"nosound audio playback");
if (!NoSound_PlaybackTask)
{
NoSound_ErrorStr = "Could not start Playback Task";
return -1;
}
return 0;
}
static void
NoSound_CloseAudio (void)
{
if (NoSound_PlaybackTask)
{
ConcludeTask (NoSound_PlaybackTask);
NoSound_PlaybackTask = 0;
}
}
static void
NoSound_PauseAudio (int pause_on)
{
NoSound_Paused = pause_on;
}
@@ -1,73 +0,0 @@
/*
* 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
*/
#include "mixer.h"
/*************************************************
* Interface Types
*/
#define TFBSound_Object mixSDL_Object
#define TFBSound_IntVal mixSDL_IntVal
/*************************************************
* General interface
*/
#define TFBSound_GetError mixSDL_GetError
/*************************************************
* Sources
*/
#define TFBSound_GenSources mixSDL_GenSources
#define TFBSound_DeleteSources mixSDL_DeleteSources
#define TFBSound_IsSource mixSDL_IsSource
#define TFBSound_Sourcei mixSDL_Sourcei
#define TFBSound_Sourcef mixSDL_Sourcef
#define TFBSound_Sourcefv mixSDL_Sourcefv
#define TFBSound_GetSourcei mixSDL_GetSourcei
#define TFBSound_GetSourcef mixSDL_GetSourcef
#define TFBSound_SourceRewind mixSDL_SourceRewind
#define TFBSound_SourcePlay mixSDL_SourcePlay
#define TFBSound_SourcePause mixSDL_SourcePause
#define TFBSound_SourceStop mixSDL_SourceStop
#define TFBSound_SourceQueueBuffers mixSDL_SourceQueueBuffers
#define TFBSound_SourceUnqueueBuffers mixSDL_SourceUnqueueBuffers
/*************************************************
* Buffers
*/
#define TFBSound_GenBuffers mixSDL_GenBuffers
#define TFBSound_DeleteBuffers mixSDL_DeleteBuffers
#define TFBSound_IsBuffer mixSDL_IsBuffer
#define TFBSound_GetBufferi mixSDL_GetBufferi
#define TFBSound_BufferData mixSDL_BufferData
#define TFBSOUND_GAIN MIX_GAIN
#define TFBSOUND_BUFFER MIX_BUFFER
#define TFBSOUND_SOURCE_STATE MIX_SOURCE_STATE
#define TFBSOUND_PLAYING MIX_PLAYING
#define TFBSOUND_PAUSED MIX_PAUSED
#define TFBSOUND_STOPPED MIX_STOPPED
#define TFBSOUND_FORMAT_MONO16 MIX_FORMAT_MONO16
#define TFBSOUND_FORMAT_STEREO16 MIX_FORMAT_STEREO16
#define TFBSOUND_FORMAT_STEREO8 MIX_FORMAT_STEREO8
#define TFBSOUND_LOOPING MIX_LOOPING
#define TFBSOUND_BUFFERS_PROCESSED MIX_BUFFERS_PROCESSED
#define TFBSOUND_BUFFERS_QUEUED MIX_BUFFERS_QUEUED
#define TFBSOUND_NO_ERROR MIX_NO_ERROR
#define TFBSOUND_SIZE MIX_SIZE
#define TFBSOUND_POSITION MIX_POSITION
-38
View File
@@ -1,38 +0,0 @@
/*
* 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.
*/
/* Adaptation layer
*/
#ifndef MIXER_H
#define MIXER_H
#include "types.h"
#include "SDL_byteorder.h"
/**
* This is just a simple endianness setup for the mixer
*/
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
# define MIX_IS_BIG_ENDIAN true
# define MIX_WANT_BIG_ENDIAN false
#else
# define MIX_IS_BIG_ENDIAN false
# define MIX_WANT_BIG_ENDIAN false
#endif
#endif /* MIXER_H */
@@ -1,151 +0,0 @@
/*
* 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.
*/
#ifdef HAVE_OPENAL
#include "libs/sound/sound.h"
#include "options.h"
ALCcontext *alcContext = NULL;
ALCdevice *alcDevice = NULL;
ALfloat listenerPos[] = {0.0f, 0.0f, 0.0f};
ALfloat listenerVel[] = {0.0f, 0.0f, 0.0f};
ALfloat listenerOri[] = {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f};
static Task StreamDecoderTask;
int
TFB_alInitSound (int driver, int flags)
{
int i;
TFB_DecoderFormats formats =
{
MIX_IS_BIG_ENDIAN, MIX_WANT_BIG_ENDIAN,
AL_FORMAT_MONO8, AL_FORMAT_STEREO8,
AL_FORMAT_MONO16, AL_FORMAT_STEREO16
};
fprintf (stderr, "Initializing OpenAL.\n");
#ifdef WIN32
alcDevice = alcOpenDevice ((ALubyte*)"DirectSound3D");
#else
alcDevice = alcOpenDevice (NULL);
#endif
if (!alcDevice)
{
fprintf (stderr,"Couldn't initialize OpenAL: %d\n", alcGetError (NULL));
return -1;
}
atexit (TFB_UninitSound);
alcContext = alcCreateContext (alcDevice, NULL);
if (!alcContext)
{
fprintf (stderr, "Couldn't create OpenAL context: %d\n", alcGetError (alcDevice));
}
alcMakeContextCurrent (alcContext);
fprintf (stderr, "OpenAL initialized.\n");
fprintf (stderr, " version: %s\n", alGetString (AL_VERSION));
fprintf (stderr, " vendor: %s\n", alGetString (AL_VENDOR));
fprintf (stderr, " renderer: %s\n", alGetString (AL_RENDERER));
fprintf (stderr, " device: %s\n",
alcGetString (alcDevice, ALC_DEFAULT_DEVICE_SPECIFIER));
//fprintf (stderr, " extensions: %s\n", alGetString (AL_EXTENSIONS));
fprintf (stderr, "Initializing sound decoders.\n");
SoundDecoder_Init (flags, &formats);
fprintf (stderr, "Sound decoders initialized.\n");
alListenerfv (AL_POSITION, listenerPos);
alListenerfv (AL_VELOCITY, listenerVel);
alListenerfv (AL_ORIENTATION, listenerOri);
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
{
float zero[3] = {0.0f, 0.0f, 0.0f};
alGenSources (1, &soundSource[i].handle);
alSourcei (soundSource[i].handle, AL_LOOPING, AL_FALSE);
alSourcefv (soundSource[i].handle, AL_POSITION, zero);
alSourcefv (soundSource[i].handle, AL_VELOCITY, zero);
alSourcefv (soundSource[i].handle, AL_DIRECTION, zero);
soundSource[i].sample = NULL;
soundSource[i].stream_should_be_playing = FALSE;
soundSource[i].stream_mutex = CreateMutex ("OpenAL stream mutex", SYNC_CLASS_AUDIO);
soundSource[i].sbuffer = NULL;
soundSource[i].sbuf_start = 0;
soundSource[i].sbuf_size = 0;
soundSource[i].sbuf_offset = 0;
}
SetSFXVolume (sfxVolumeScale);
SetSpeechVolume (speechVolumeScale);
SetMusicVolume ((COUNT) musicVolume);
if (optStereoSFX)
alDistanceModel (AL_INVERSE_DISTANCE);
else
alDistanceModel (AL_NONE);
StreamDecoderTask = AssignTask (StreamDecoderTaskFunc, 1024,
"audio stream decoder");
(void) driver; // eat compiler warning
return 0;
}
void
TFB_alUninitSound (void)
{
int i;
if (StreamDecoderTask)
{
ConcludeTask (StreamDecoderTask);
StreamDecoderTask = NULL;
}
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
{
if (soundSource[i].sample && soundSource[i].sample->decoder)
{
StopStream (i);
}
if (soundSource[i].sbuffer)
{
void *sbuffer = soundSource[i].sbuffer;
soundSource[i].sbuffer = NULL;
HFree (sbuffer);
}
DestroyMutex (soundSource[i].stream_mutex);
}
alcMakeContextCurrent (NULL);
alcDestroyContext (alcContext);
alcContext = NULL;
alcCloseDevice (alcDevice);
alcDevice = NULL;
SoundDecoder_Uninit ();
}
#endif
-92
View File
@@ -1,92 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#ifndef _PLAY_H
#define _PLAY_H
enum
{
MOD_TRACK,
RED_BOOK_TRACK,
NUM_TRACK_TYPES
};
typedef struct
{
MUSIC_REF TrackRef;
PBYTE TrackPtr;
} TRACK_DESC;
extern TRACK_DESC volatile _TrackList[NUM_TRACK_TYPES];
#define MAX_CHANNELS 4
#define MAX_TRACKS 16
#define MAX_INSTRUMENTS 63
#define MAX_BLOCKS 256
#define MAX_TRACK_VOLUME 64
typedef unsigned short SAMPLE_RATE;
typedef struct
{
COUNT LoopBegin, LoopLength;
COUNT SampleLength;
BYTE volume, transposition;
} INSTRUMENT_DESC;
typedef struct
{
BYTE LineCommands[MAX_CHANNELS][3];
} LINE_DESC;
typedef LINE_DESC *PLINE_DESC;
#define LINE_DESCPTR PLINE_DESC
typedef struct
{
BYTE NumTracks, LastLine;
LINE_DESC LineList[1];
} BLOCK_DESC;
typedef BLOCK_DESC *PBLOCK_DESC;
#define BLOCK_DESCPTR PBLOCK_DESC
#define PLAY_CONTINUOUS (1 << 0)
typedef struct
{
INSTRUMENT_DESC PresetList[MAX_INSTRUMENTS];
BYTE NumPhysicalBlocks, NumLogicalBlocks;
BYTE LogToPhysBlockList[MAX_BLOCKS];
BYTE Tempo, NumSteps;
BYTE Priority, Flags;
BYTE TrackVolumeList[MAX_TRACKS];
BYTE MasterVolume;
BYTE NumInstruments;
DWORD InstrumentList[MAX_INSTRUMENTS];
DWORD BlockList[1];
} SONG_DESC;
typedef SONG_DESC *PSONG_DESC;
#define SONG_DESCPTR PSONG_DESC
extern void _download_effects (SOUND_REF SoundRef);
extern BOOLEAN _download_instruments (MUSIC_REF MusicRef);
#include "redbook.h"
#endif /* _PLAY_H */
-29
View File
@@ -1,29 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#ifndef _REDBOOK_H
#define _REDBOOK_H
extern BOOLEAN _is_red_book (PBYTE TrackInfo);
extern BOOLEAN _play_red_book (PBYTE TrackInfo, BOOLEAN Loop);
extern void _stop_red_book (void);
extern BOOLEAN _red_book_playing (void);
extern void _pause_red_book (void);
extern void _resume_red_book (void);
#endif /* _REDBOOK_H */
-299
View File
@@ -1,299 +0,0 @@
/*
* 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
*/
#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;
int TFBSOUND_STOPPED;
unsigned int TFBSOUND_FORMAT_MONO16;
unsigned int TFBSOUND_FORMAT_STEREO16;
unsigned int TFBSOUND_FORMAT_STEREO8;
unsigned int TFBSOUND_FORMAT_MONO8;
int TFB_mixSDL_InitSound (int driver, int flags);
int TFB_NoSound_InitSound (int driver, int flags);
#ifdef HAVE_OPENAL
int TFB_alInitSound (int driver, int flags);
#endif
/*************************************************
* General interface
*/
uint32
TFBSound_GetError (void)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
return (alGetError ());
else
return (mixSDL_GetError ());
}
/*************************************************
* Sources
*/
void
TFBSound_GenSources (uint32 n, TFBSound_Object *psrcobj)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alGenSources (n, (ALuint *)psrcobj);
else
mixSDL_GenSources (n, (mixSDL_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_Sourcefv (TFBSound_Object srcobj, TFBSound_SourceProp pname, float *value)
{
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
alSourcefv ((ALuint) srcobj, (ALenum) tfb_enum_lookup[pname], value);
else
mixSDL_Sourcefv ((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);
}
int
TFB_choose_InitSound (int driver, int flags)
{
SoundDriver = driver;
if (driver == TFB_SOUNDDRIVER_OPENAL)
{
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;
tfb_enum_lookup[TFBSOUND_POSITION] = AL_POSITION;
TFBSOUND_NO_ERROR = AL_NO_ERROR;
TFBSOUND_PAUSED = AL_PAUSED;
TFBSOUND_PLAYING = AL_PLAYING;
TFBSOUND_STOPPED = AL_STOPPED;
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
{
/* NoSound uses MixSDL, common values */
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;
tfb_enum_lookup[TFBSOUND_POSITION] = MIX_POSITION;
TFBSOUND_NO_ERROR = MIX_NO_ERROR;
TFBSOUND_PAUSED = MIX_PAUSED;
TFBSOUND_PLAYING = MIX_PLAYING;
TFBSOUND_STOPPED = MIX_STOPPED;
TFBSOUND_FORMAT_MONO16 = MIX_FORMAT_MONO16;
TFBSOUND_FORMAT_STEREO16 = MIX_FORMAT_STEREO16;
TFBSOUND_FORMAT_MONO8 = MIX_FORMAT_MONO8;
TFBSOUND_FORMAT_STEREO8 = MIX_FORMAT_STEREO8;
if (driver == TFB_SOUNDDRIVER_MIXSDL)
return (TFB_mixSDL_InitSound (driver, flags));
else
return (TFB_NoSound_InitSound (driver, flags));
}
}
#endif
-112
View File
@@ -1,112 +0,0 @@
/*
* 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
*/
#ifndef SOUNDCHOOSER_H
# define SOUNDCHOOSER_H
# ifdef WIN32
# include <al.h>
# include <alc.h>
# ifdef _MSC_VER
# pragma comment (lib, "OpenAL32.lib")
# endif
#else
# include <AL/al.h>
# include <AL/alc.h>
#endif
#include "mixsdl/mixer.h"
#include "openal/mixer.h"
#include "types.h"
/*************************************************
* Interface Types
*/
typedef intptr_t TFBSound_Object;
typedef intptr_t TFBSound_IntVal;
typedef const int TFBSound_SourceProp;
typedef const int TFBSound_BufferProp;
/*************************************************
* General interface
*/
uint32 TFBSound_GetError (void);
/*************************************************
* 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_Sourcefv (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);
#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_POSITION,
TFBSOUND_ENUMSIZE
};
extern int TFBSOUND_PAUSED;
extern int TFBSOUND_PLAYING;
extern int TFBSOUND_STOPPED;
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 */
-161
View File
@@ -1,161 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#include "libs/graphics/gfx_common.h"
#include "libs/sound/sound_common.h"
#include "libs/sound/sound.h"
#include "libs/tasklib.h"
int SoundDriver = TFB_SOUNDDRIVER_MIXSDL;
int musicVolume = (MAX_VOLUME >> 1);
float musicVolumeScale = 1.0f;
float sfxVolumeScale = 1.0f;
float speechVolumeScale = 1.0f;
static Task FadeTask;
static SIZE TTotal;
static SIZE volume_end;
int TFB_mixSDL_InitSound (int driver, int flags);
int TFB_NoSound_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);
void TFB_NoSound_UninitSound (void);
#ifdef HAVE_OPENAL
void TFB_alUninitSound (void);
#endif
static int
fade_task (void *data)
{
SIZE TDelta, volume_beg;
DWORD StartTime, CurTime;
Task task = (Task) data;
volume_beg = musicVolume;
StartTime = CurTime = GetTimeCounter ();
do
{
SleepThreadUntil (CurTime + ONE_SECOND / 120);
CurTime = GetTimeCounter ();
if ((TDelta = (SIZE) (CurTime - StartTime)) > TTotal)
TDelta = TTotal;
SetMusicVolume ((COUNT) (volume_beg + (SIZE)
((long) (volume_end - volume_beg) * TDelta / TTotal)));
} while (TDelta < TTotal);
FadeTask = 0;
FinishTask (task);
return (1);
}
DWORD
FadeMusic (BYTE end_vol, SIZE TimeInterval)
{
DWORD TimeOut;
if (FadeTask)
{
volume_end = musicVolume;
TTotal = 1;
do
TaskSwitch ();
while (FadeTask);
TaskSwitch ();
}
if ((TTotal = TimeInterval) <= 0)
TTotal = 1; /* prevent divide by zero and negative fade */
volume_end = end_vol;
if (TTotal > 1 && (FadeTask = AssignTask (fade_task, 0,
"fade music")))
{
TimeOut = GetTimeCounter () + TTotal + 1;
}
else
{
SetMusicVolume (end_vol);
TimeOut = GetTimeCounter ();
}
return (TimeOut);
}
int
TFB_InitSound (int driver, int flags)
{
int ret;
#ifdef HAVE_OPENAL
ret = TFB_choose_InitSound (driver, flags);
#else
SoundDriver = driver;
if (SoundDriver == TFB_SOUNDDRIVER_OPENAL)
{
fprintf (stderr, "OpenAL driver not compiled in, so using MixSDL\n");
SoundDriver = TFB_SOUNDDRIVER_MIXSDL;
}
if (SoundDriver == TFB_SOUNDDRIVER_MIXSDL)
ret = TFB_mixSDL_InitSound (SoundDriver, flags);
else
ret = TFB_NoSound_InitSound (SoundDriver, flags);
#endif
if (ret != 0)
{
fprintf (stderr, "Sound driver initialization failed.\n"
"This may happen when a soundcard is "
"not present or not available.\n"
"NOTICE: Try running UQM with '--sound=none' option\n");
exit (EXIT_FAILURE);
}
return ret;
}
void
TFB_UninitSound (void)
{
switch (SoundDriver)
{
case TFB_SOUNDDRIVER_OPENAL:
#ifdef HAVE_OPENAL
TFB_alUninitSound ();
#else
fprintf (stderr, "TFB_UninitSound(): driver is set to OpenAL"
"while OpenAL driver is not compiled in\n");
#endif
break;
case TFB_SOUNDDRIVER_MIXSDL:
TFB_mixSDL_UninitSound ();
break;
case TFB_SOUNDDRIVER_NOSOUND:
TFB_NoSound_UninitSound ();
break;
}
}
-44
View File
@@ -1,44 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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.
*/
#ifndef SOUND_COMMON_H
#define SOUND_COMMON_H
// driver for TFB_InitSound
enum
{
TFB_SOUNDDRIVER_MIXSDL,
TFB_SOUNDDRIVER_NOSOUND,
TFB_SOUNDDRIVER_OPENAL
};
extern int SoundDriver;
// flags for TFB_InitSound
#define TFB_SOUNDFLAGS_HQAUDIO (1<<0) // high quality audio
#define TFB_SOUNDFLAGS_MQAUDIO (1<<1) // medium quality audio
#define TFB_SOUNDFLAGS_LQAUDIO (1<<2) // low quality audio
int TFB_InitSound (int driver, int flags);
void TFB_UninitSound (void);
extern int musicVolume;
extern float musicVolumeScale;
extern float sfxVolumeScale;
extern float speechVolumeScale;
#endif