(audio_mixer.c) Cleanups

This commit is contained in:
twinaphex 2017-05-08 18:11:09 +02:00
parent 6c164984a0
commit 0411aba219
2 changed files with 14 additions and 8 deletions

View File

@ -50,7 +50,7 @@
#define AUDIO_MIXER_TYPE_WAV 1
#define AUDIO_MIXER_TYPE_OGG 2
struct audio_mixer_sound_t
struct audio_mixer_sound
{
unsigned type;
@ -74,12 +74,12 @@ struct audio_mixer_sound_t
} types;
};
struct audio_mixer_voice_t
struct audio_mixer_voice
{
unsigned type;
bool repeat;
float volume;
audio_mixer_sound_t* sound;
audio_mixer_sound_t *sound;
audio_mixer_stop_cb_t stop_cb;
union
@ -96,7 +96,7 @@ struct audio_mixer_voice_t
/* ogg */
unsigned position;
unsigned samples;
stb_vorbis* stream;
stb_vorbis *stream;
float* buffer;
unsigned buf_samples;
void* resampler_data;
@ -329,6 +329,9 @@ audio_mixer_sound_t* audio_mixer_load_ogg(const char* path)
void audio_mixer_destroy(audio_mixer_sound_t* sound)
{
if (!sound)
return;
switch (sound->type)
{
case AUDIO_MIXER_TYPE_WAV:

View File

@ -31,8 +31,8 @@
RETRO_BEGIN_DECLS
typedef struct audio_mixer_sound_t audio_mixer_sound_t;
typedef struct audio_mixer_voice_t audio_mixer_voice_t;
typedef struct audio_mixer_sound audio_mixer_sound_t;
typedef struct audio_mixer_voice audio_mixer_voice_t;
typedef void (*audio_mixer_stop_cb_t)(audio_mixer_voice_t* voice, unsigned reason);
@ -42,6 +42,7 @@ typedef void (*audio_mixer_stop_cb_t)(audio_mixer_voice_t* voice, unsigned reaso
#define AUDIO_MIXER_SOUND_REPEATED 2
void audio_mixer_init(unsigned rate);
void audio_mixer_done(void);
audio_mixer_sound_t* audio_mixer_load_wav(const char* path);
@ -49,8 +50,10 @@ audio_mixer_sound_t* audio_mixer_load_ogg(const char* path);
void audio_mixer_destroy(audio_mixer_sound_t* sound);
audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat, float volume, audio_mixer_stop_cb_t stop_cb);
void audio_mixer_stop(audio_mixer_voice_t* voice);
audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound,
bool repeat, float volume, audio_mixer_stop_cb_t stop_cb);
void audio_mixer_stop(audio_mixer_voice_t* voice);
void audio_mixer_mix(float* buffer, size_t num_frames);