mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-25 11:30:06 +00:00
Refactor : rename a number of structures and constify a few public API methods
This commit is contained in:
parent
8dd82642d3
commit
d6b5c19584
@ -29,8 +29,6 @@
|
||||
|
||||
#define OPENAL_NUM_BUFFERS 4
|
||||
|
||||
typedef struct IDirectSoundBuffer ALSoundBufferStruct;
|
||||
|
||||
typedef struct ALPlayBuf {
|
||||
const ALuint bufid; // the hash id
|
||||
ALuint bytes; // bytes to play
|
||||
@ -72,8 +70,8 @@ static ALVoices *voices = NULL;
|
||||
|
||||
static audio_backend_s openal_audio_backend = { 0 };
|
||||
|
||||
static long OpenALCreateSoundBuffer(AudioParams_s *params, ALSoundBufferStruct **soundbuf_struct, void *extra_data);
|
||||
static long OpenALDestroySoundBuffer(ALSoundBufferStruct **soundbuf_struct);
|
||||
static long OpenALCreateSoundBuffer(const AudioParams_s *params, INOUT AudioBuffer_s **soundbuf_struct, const SoundSystem_s *sound_struct);
|
||||
static long OpenALDestroySoundBuffer(INOUT AudioBuffer_s **soundbuf_struct);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// uthash of OpenAL buffers
|
||||
@ -153,7 +151,7 @@ static void PlaylistDequeue(ALVoice *voice, ALPlayBuf *node)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static long openal_systemInit(const char *sound_device, SoundSystemStruct **sound_struct)
|
||||
static long openal_systemInit(const char *sound_device, SoundSystem_s **sound_struct)
|
||||
{
|
||||
assert(*sound_struct == NULL);
|
||||
assert(voices == NULL);
|
||||
@ -177,15 +175,15 @@ static long openal_systemInit(const char *sound_device, SoundSystemStruct **soun
|
||||
LOG("WARNING - AL_SOFT_buffer_samples extension not supported... Proceeding anyway...");
|
||||
}
|
||||
|
||||
if ((*sound_struct = malloc(sizeof(SoundSystemStruct))) == NULL)
|
||||
if ((*sound_struct = malloc(sizeof(SoundSystem_s))) == NULL)
|
||||
{
|
||||
ERRLOG("OOPS, Not enough memory");
|
||||
break;
|
||||
}
|
||||
|
||||
(*sound_struct)->implementation_specific = ctx;
|
||||
(*sound_struct)->CreateSoundBuffer = (int (*)(AudioParams_s *, LPDIRECTSOUNDBUFFER *, void *))OpenALCreateSoundBuffer;
|
||||
(*sound_struct)->DestroySoundBuffer = (int (*)(LPDIRECTSOUNDBUFFER *))OpenALDestroySoundBuffer;
|
||||
(*sound_struct)->CreateSoundBuffer = &OpenALCreateSoundBuffer;
|
||||
(*sound_struct)->DestroySoundBuffer = &OpenALDestroySoundBuffer;
|
||||
|
||||
return 0;
|
||||
} while(0);
|
||||
@ -199,7 +197,7 @@ static long openal_systemInit(const char *sound_device, SoundSystemStruct **soun
|
||||
return -1;
|
||||
}
|
||||
|
||||
static long openal_systemShutdown(SoundSystemStruct **sound_struct)
|
||||
static long openal_systemShutdown(SoundSystem_s **sound_struct)
|
||||
{
|
||||
assert(*sound_struct != NULL);
|
||||
|
||||
@ -302,7 +300,7 @@ static void DeleteVoice(ALVoice *voice)
|
||||
/* Creates a new voice object, and allocates the needed OpenAL source and
|
||||
* buffer objects. Error checking is simplified for the purposes of this
|
||||
* example, and will cause an abort if needed. */
|
||||
static ALVoice *NewVoice(AudioParams_s *params)
|
||||
static ALVoice *NewVoice(const AudioParams_s *params)
|
||||
{
|
||||
ALVoice *voice = NULL;
|
||||
|
||||
@ -732,12 +730,11 @@ static long ALGetStatus(void *_this, unsigned long *status)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long OpenALCreateSoundBuffer(AudioParams_s *params, ALSoundBufferStruct **soundbuf_struct, void *extra_data)
|
||||
static long OpenALCreateSoundBuffer(const AudioParams_s *params, INOUT AudioBuffer_s **soundbuf_struct, const SoundSystem_s *sound_struct)
|
||||
{
|
||||
LOG("OpenALCreateSoundBuffer ...");
|
||||
assert(*soundbuf_struct == NULL);
|
||||
|
||||
const SoundSystemStruct *sound_struct = (SoundSystemStruct*)extra_data;
|
||||
ALCcontext *ctx = (ALCcontext*)(sound_struct->implementation_specific);
|
||||
assert(ctx != NULL);
|
||||
|
||||
@ -762,7 +759,7 @@ static long OpenALCreateSoundBuffer(AudioParams_s *params, ALSoundBufferStruct *
|
||||
vnode->voice = voice;
|
||||
HASH_ADD_INT(voices, source, vnode);
|
||||
|
||||
if ((*soundbuf_struct = malloc(sizeof(ALSoundBufferStruct))) == NULL)
|
||||
if ((*soundbuf_struct = malloc(sizeof(AudioBuffer_s))) == NULL)
|
||||
{
|
||||
ERRLOG("OOPS, Not enough memory");
|
||||
break;
|
||||
@ -798,7 +795,7 @@ static long OpenALCreateSoundBuffer(AudioParams_s *params, ALSoundBufferStruct *
|
||||
return -1;
|
||||
}
|
||||
|
||||
static long OpenALDestroySoundBuffer(ALSoundBufferStruct **soundbuf_struct)
|
||||
static long OpenALDestroySoundBuffer(INOUT AudioBuffer_s **soundbuf_struct)
|
||||
{
|
||||
if (!*soundbuf_struct) {
|
||||
// already dealloced
|
||||
|
@ -35,8 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
static char **sound_devices = NULL;
|
||||
static long num_sound_devices = 0;
|
||||
|
||||
LPDIRECTSOUND g_lpDS = NULL;
|
||||
static SoundSystem_s *g_lpDS = NULL;
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
@ -56,7 +55,7 @@ audio_backend_s *audio_backend = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool DSGetLock(LPDIRECTSOUNDBUFFER pVoice, unsigned long dwOffset, unsigned long dwBytes,
|
||||
bool DSGetLock(AudioBuffer_s *pVoice, unsigned long dwOffset, unsigned long dwBytes,
|
||||
int16_t** ppDSLockedBuffer0, unsigned long* pdwDSLockedBufferSize0,
|
||||
int16_t** ppDSLockedBuffer1, unsigned long* pdwDSLockedBufferSize1)
|
||||
{
|
||||
@ -263,9 +262,9 @@ bool audio_init(void)
|
||||
{
|
||||
if (g_lpDS)
|
||||
{
|
||||
audio_backend->shutdown((SoundSystemStruct**)&g_lpDS);
|
||||
audio_backend->shutdown((SoundSystem_s**)&g_lpDS);
|
||||
}
|
||||
hr = (int)audio_backend->init(sound_devices[x], (SoundSystemStruct**)&g_lpDS);
|
||||
hr = (int)audio_backend->init(sound_devices[x], (SoundSystem_s**)&g_lpDS);
|
||||
if(hr == 0)
|
||||
{
|
||||
bCreatedOK = true;
|
||||
@ -310,7 +309,7 @@ void audio_shutdown(void)
|
||||
|
||||
assert(g_uNumVoices == 0);
|
||||
|
||||
audio_backend->shutdown((SoundSystemStruct**)&g_lpDS);
|
||||
audio_backend->shutdown((SoundSystem_s**)&g_lpDS);
|
||||
audio_isAvailable = false;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define AUDIO_STATUS_PLAYING 0x00000001
|
||||
#define AUDIO_STATUS_NOTPLAYING 0x08000000
|
||||
|
||||
typedef struct IDirectSoundBuffer {
|
||||
typedef struct AudioBuffer_s {
|
||||
|
||||
void *_this;
|
||||
|
||||
@ -50,7 +50,7 @@ typedef struct IDirectSoundBuffer {
|
||||
int (*UnlockStaticBuffer)(void* _this, unsigned long dwAudioBytes);
|
||||
int (*Replay)(void* _this);
|
||||
|
||||
} IDirectSoundBuffer, *LPDIRECTSOUNDBUFFER, **LPLPDIRECTSOUNDBUFFER;
|
||||
} AudioBuffer_s;
|
||||
|
||||
typedef struct AudioParams_s {
|
||||
uint16_t nChannels;
|
||||
@ -61,16 +61,15 @@ typedef struct AudioParams_s {
|
||||
unsigned long dwBufferBytes;
|
||||
} AudioParams_s;
|
||||
|
||||
typedef struct IDirectSound {
|
||||
typedef struct SoundSystem_s {
|
||||
void *implementation_specific;
|
||||
int (*CreateSoundBuffer)(AudioParams_s *pcDSBufferDesc, LPDIRECTSOUNDBUFFER * ppDSBuffer, void *pUnkOuter);
|
||||
int (*DestroySoundBuffer)(LPDIRECTSOUNDBUFFER * ppDSBuffer);
|
||||
} IDirectSound, *LPDIRECTSOUND;
|
||||
typedef struct IDirectSound SoundSystemStruct;
|
||||
long (*CreateSoundBuffer)(const AudioParams_s *params, INOUT AudioBuffer_s **buffer, const struct SoundSystem_s *sound_system);
|
||||
long (*DestroySoundBuffer)(INOUT AudioBuffer_s **buffer);
|
||||
} SoundSystem_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER lpDSBvoice;
|
||||
AudioBuffer_s *lpDSBvoice;
|
||||
bool bActive; // Playback is active
|
||||
bool bMute;
|
||||
long nVolume; // Current volume (as used by DirectSound)
|
||||
@ -81,7 +80,7 @@ typedef struct
|
||||
} VOICE, *PVOICE;
|
||||
|
||||
|
||||
bool DSGetLock(LPDIRECTSOUNDBUFFER pVoice, unsigned long dwOffset, unsigned long dwBytes,
|
||||
bool DSGetLock(AudioBuffer_s *pVoice, unsigned long dwOffset, unsigned long dwBytes,
|
||||
int16_t** ppDSLockedBuffer0, unsigned long* pdwDSLockedBufferSize0,
|
||||
int16_t** ppDSLockedBuffer1, unsigned long* pdwDSLockedBufferSize1);
|
||||
|
||||
@ -114,9 +113,9 @@ extern bool audio_isAvailable;
|
||||
typedef struct audio_backend_s {
|
||||
|
||||
// basic backend functionality controlled by soundcore
|
||||
PRIVATE long (*init)(const char *sound_device, SoundSystemStruct **sound_struct);
|
||||
PRIVATE long (*shutdown)(SoundSystemStruct **sound_struct);
|
||||
PRIVATE long (*enumerateDevices)(char ***sound_devices, const int maxcount);
|
||||
PRIVATE long (*init)(const char *sound_device, INOUT SoundSystem_s **sound_struct);
|
||||
PRIVATE long (*shutdown)(INOUT SoundSystem_s **sound_struct);
|
||||
PRIVATE long (*enumerateDevices)(INOUT char ***sound_devices, const int maxcount);
|
||||
|
||||
PUBLIC long (*pause)(void);
|
||||
PUBLIC long (*resume)(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user