Skip to content

Commit

Permalink
Minor fixes, style update
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed May 10, 2020
1 parent 5f2c7b9 commit 1b7c3c4
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions SDL/audio/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
static SDL_AudioDeviceID device_id;
static SDL_AudioSpec want_aspec, have_aspec;

#define BUFFERSIZE 1024
static int bufferpos = 0;
static int16_t audiobuffer[BUFFERSIZE];
#define AUDIO_BUFFER_SIZE 512
static unsigned buffer_pos = 0;
static GB_sample_t audio_buffer[AUDIO_BUFFER_SIZE];

bool GB_audio_is_playing(void)
{
Expand Down Expand Up @@ -57,13 +57,11 @@ size_t GB_audio_get_queue_length(void)

void GB_audio_queue_sample(GB_sample_t *sample)
{
audiobuffer[bufferpos++] = sample->left;
audiobuffer[bufferpos++] = sample->right;
audio_buffer[buffer_pos++] = *sample;

if (bufferpos == BUFFERSIZE)
{
bufferpos = 0;
SDL_QueueAudio(device_id, (const void*)audiobuffer, BUFFERSIZE * sizeof(int16_t));
if (buffer_pos == AUDIO_BUFFER_SIZE) {
buffer_pos = 0;
SDL_QueueAudio(device_id, (const void *)audio_buffer, sizeof(audio_buffer));
}
}

Expand All @@ -74,7 +72,7 @@ void GB_audio_init(void)
want_aspec.freq = AUDIO_FREQUENCY;
want_aspec.format = AUDIO_S16SYS;
want_aspec.channels = 2;
want_aspec.samples = 1024;
want_aspec.samples = 512;

SDL_version _sdl_version;
SDL_GetVersion(&_sdl_version);
Expand Down

0 comments on commit 1b7c3c4

Please sign in to comment.