Minor fixes, style update

This commit is contained in:
Lior Halphon 2020-05-10 22:16:49 +03:00
parent 5f2c7b966f
commit 1b7c3c4c7c
1 changed files with 8 additions and 10 deletions

View File

@ -25,9 +25,9 @@
static SDL_AudioDeviceID device_id; static SDL_AudioDeviceID device_id;
static SDL_AudioSpec want_aspec, have_aspec; static SDL_AudioSpec want_aspec, have_aspec;
#define BUFFERSIZE 1024 #define AUDIO_BUFFER_SIZE 512
static int bufferpos = 0; static unsigned buffer_pos = 0;
static int16_t audiobuffer[BUFFERSIZE]; static GB_sample_t audio_buffer[AUDIO_BUFFER_SIZE];
bool GB_audio_is_playing(void) bool GB_audio_is_playing(void)
{ {
@ -57,13 +57,11 @@ size_t GB_audio_get_queue_length(void)
void GB_audio_queue_sample(GB_sample_t *sample) void GB_audio_queue_sample(GB_sample_t *sample)
{ {
audiobuffer[bufferpos++] = sample->left; audio_buffer[buffer_pos++] = *sample;
audiobuffer[bufferpos++] = sample->right;
if (bufferpos == BUFFERSIZE) if (buffer_pos == AUDIO_BUFFER_SIZE) {
{ buffer_pos = 0;
bufferpos = 0; SDL_QueueAudio(device_id, (const void *)audio_buffer, sizeof(audio_buffer));
SDL_QueueAudio(device_id, (const void*)audiobuffer, BUFFERSIZE * sizeof(int16_t));
} }
} }
@ -74,7 +72,7 @@ void GB_audio_init(void)
want_aspec.freq = AUDIO_FREQUENCY; want_aspec.freq = AUDIO_FREQUENCY;
want_aspec.format = AUDIO_S16SYS; want_aspec.format = AUDIO_S16SYS;
want_aspec.channels = 2; want_aspec.channels = 2;
want_aspec.samples = 1024; want_aspec.samples = 512;
SDL_version _sdl_version; SDL_version _sdl_version;
SDL_GetVersion(&_sdl_version); SDL_GetVersion(&_sdl_version);