diff --git a/src/gb/audio.c b/src/gb/audio.c index 8021f7bdf..cd292bc5e 100644 --- a/src/gb/audio.c +++ b/src/gb/audio.c @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "audio.h" +#include "core/interface.h" #include "core/sync.h" #include "gb/gb.h" #include "gb/io.h" @@ -671,9 +672,15 @@ void _sample(struct GBAudio* audio, int32_t cycles) { } } produced = blip_samples_avail(audio->left); + if (audio->p->stream && audio->p->stream->postAudioFrame) { + audio->p->stream->postAudioFrame(audio->p->stream, sampleLeft, sampleRight); + } bool wait = produced >= audio->samples; mCoreSyncProduceAudio(audio->p->sync, wait); - // TODO: Put AVStream back + + if (wait && audio->p->stream && audio->p->stream->postAudioBuffer) { + audio->p->stream->postAudioBuffer(audio->p->stream, audio->left, audio->right); + } } void _writeDuty(struct GBAudioEnvelope* envelope, uint8_t value) { diff --git a/src/gb/core.c b/src/gb/core.c index 97bc15d9c..6c3fd7e0f 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -115,7 +115,8 @@ static size_t _GBCoreGetAudioBufferSize(struct mCore* core) { } static void _GBCoreSetAVStream(struct mCore* core, struct mAVStream* stream) { - // TODO + struct GB* gb = core->board; + gb->stream = stream; } static bool _GBCoreLoadROM(struct mCore* core, struct VFile* vf) { diff --git a/src/gb/gb.h b/src/gb/gb.h index 99b605e2e..251370a9d 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -41,6 +41,7 @@ enum GBIRQVector { }; struct mCoreSync; +struct mAVStream; struct GB { struct mCPUComponent d; @@ -61,6 +62,8 @@ struct GB { struct VFile* romVf; struct VFile* sramVf; + struct mAVStream* stream; + int32_t eiPending; };