GBA: Add postAudioBuffer callback
Jeffrey Pfau jeffrey@endrift.com
Thu, 12 Mar 2015 00:45:08 -0700
4 files changed,
10 insertions(+),
2 deletions(-)
M
src/gba/audio.c
→
src/gba/audio.c
@@ -822,10 +822,15 @@ }
} produced = blip_samples_avail(audio->left); #endif - if (audio->p->stream) { + if (audio->p->stream && audio->p->stream->postAudioFrame) { audio->p->stream->postAudioFrame(audio->p->stream, sampleLeft, sampleRight); } - GBASyncProduceAudio(audio->p->sync, produced >= audio->samples); + bool wait = produced >= audio->samples; + GBASyncProduceAudio(audio->p->sync, wait); + + if (wait && audio->p->stream && audio->p->stream->postAudioBuffer) { + audio->p->stream->postAudioBuffer(audio->p->stream, audio); + } } void GBAAudioSerialize(const struct GBAAudio* audio, struct GBASerializedState* state) {
M
src/gba/gba.h
→
src/gba/gba.h
@@ -99,6 +99,7 @@
struct GBAAVStream { void (*postVideoFrame)(struct GBAAVStream*, struct GBAVideoRenderer* renderer); void (*postAudioFrame)(struct GBAAVStream*, int16_t left, int16_t right); + void (*postAudioBuffer)(struct GBAAVStream*, struct GBAAudio*); }; struct GBATimer {
M
src/platform/ffmpeg/ffmpeg-encoder.c
→
src/platform/ffmpeg/ffmpeg-encoder.c
@@ -33,6 +33,7 @@ av_register_all();
encoder->d.postVideoFrame = _ffmpegPostVideoFrame; encoder->d.postAudioFrame = _ffmpegPostAudioFrame; + encoder->d.postAudioBuffer = 0; encoder->audioCodec = 0; encoder->videoCodec = 0;
M
src/platform/imagemagick/imagemagick-gif-encoder.c
→
src/platform/imagemagick/imagemagick-gif-encoder.c
@@ -15,6 +15,7 @@ encoder->wand = 0;
encoder->d.postVideoFrame = _magickPostVideoFrame; encoder->d.postAudioFrame = _magickPostAudioFrame; + encoder->d.postAudioBuffer = 0; encoder->frameskip = 2; }