Skip to content

Commit

Permalink
fix: increase sfx buffer to prevent "Out of buffers" log spam
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Feb 23, 2024
1 parent 5732b53 commit e7c214e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion third_party/allegro_legacy/src/a5/a5_sound.c
Expand Up @@ -20,7 +20,7 @@
#include "allegro/platform/ainta5.h"
#include "allegro/platform/ala5.h"

#define _A5_SOUND_BUFFERS 2
#define _A5_SOUND_BUFFERS 8
#define _A5_SOUND_BUFFER_SIZE 1024
#ifdef __EMSCRIPTEN__
#define _A5_SOUND_FREQUENCY 22050
Expand All @@ -47,6 +47,14 @@ static void * a5_sound_thread_proc(ALLEGRO_THREAD * thread, void * data)
{
return NULL;
}
// local edit - Avoids "Out of buffer" warning in logs.
while ((fragment = al_get_audio_stream_fragment(a5_sound_stream)))
{
int bytes_per_sample = al_get_channel_count(_A5_SOUND_CHANNELS) * al_get_audio_depth_size(_A5_SOUND_DEPTH);
int samples = _A5_SOUND_BUFFER_SIZE / bytes_per_sample / _A5_SOUND_CHANNELS;
al_fill_silence(fragment, samples, _A5_SOUND_DEPTH, _A5_SOUND_CHANNELS);
al_set_audio_stream_fragment(a5_sound_stream, fragment);
}
if(!al_attach_audio_stream_to_mixer(a5_sound_stream, al_get_default_mixer()))
{
al_destroy_audio_stream(a5_sound_stream);
Expand Down

0 comments on commit e7c214e

Please sign in to comment.