GBA: Move A/V stream interface into core
Jeffrey Pfau jeffrey@endrift.com
Sun, 08 Mar 2015 20:56:42 -0700
7 files changed,
16 insertions(+),
12 deletions(-)
M
src/gba/audio.c
→
src/gba/audio.c
@@ -822,9 +822,8 @@ }
} produced = blip_samples_avail(audio->left); #endif - struct GBAThread* thread = GBAThreadGetContext(); - if (thread && thread->stream) { - thread->stream->postAudioFrame(thread->stream, sampleLeft, sampleRight); + if (audio->p->stream) { + audio->p->stream->postAudioFrame(audio->p->stream, sampleLeft, sampleRight); } GBASyncProduceAudio(audio->p->sync, produced >= audio->samples); }
M
src/gba/gba.c
→
src/gba/gba.c
@@ -77,7 +77,9 @@
gba->romVf = 0; gba->biosVf = 0; + gba->logHandler = 0; gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL; + gba->stream = 0; gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);@@ -733,8 +735,8 @@ if (!thread) {
return; } - if (thread->stream) { - thread->stream->postVideoFrame(thread->stream, thread->renderer); + if (gba->stream) { + gba->stream->postVideoFrame(gba->stream, gba->video.renderer); } if (thread->frameCallback) {
M
src/gba/gba.h
→
src/gba/gba.h
@@ -96,6 +96,11 @@ struct VFile;
typedef void (*GBALogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args); +struct GBAAVStream { + void (*postVideoFrame)(struct GBAAVStream*, struct GBAVideoRenderer* renderer); + void (*postAudioFrame)(struct GBAAVStream*, int16_t left, int16_t right); +}; + struct GBATimer { uint16_t reload; uint16_t oldReload;@@ -146,6 +151,7 @@ const char* activeFile;
GBALogHandler logHandler; enum GBALogLevel logLevel; + struct GBAAVStream* stream; enum GBAIdleLoopOptimization idleOptimization; uint32_t idleLoop;
M
src/gba/supervisor/thread.c
→
src/gba/supervisor/thread.c
@@ -135,6 +135,7 @@ gba.sync = &threadContext->sync;
threadContext->gba = &gba; gba.logLevel = threadContext->logLevel; gba.logHandler = threadContext->logHandler; + gba.stream = threadContext->stream; gba.idleOptimization = threadContext->idleOptimization; #ifdef USE_PTHREADS pthread_setspecific(_contextKey, threadContext);
M
src/gba/supervisor/thread.h
→
src/gba/supervisor/thread.h
@@ -48,11 +48,6 @@ Condition audioRequiredCond;
Mutex audioBufferMutex; }; -struct GBAAVStream { - void (*postVideoFrame)(struct GBAAVStream*, struct GBAVideoRenderer* renderer); - void (*postAudioFrame)(struct GBAAVStream*, int32_t left, int32_t right); -}; - struct GBAThread { // Output enum ThreadState state;
M
src/platform/ffmpeg/ffmpeg-encoder.c
→
src/platform/ffmpeg/ffmpeg-encoder.c
@@ -22,7 +22,7 @@ #include <libavresample/avresample.h>
#include <libswscale/swscale.h> static void _ffmpegPostVideoFrame(struct GBAAVStream*, struct GBAVideoRenderer* renderer); -static void _ffmpegPostAudioFrame(struct GBAAVStream*, int32_t left, int32_t right); +static void _ffmpegPostAudioFrame(struct GBAAVStream*, int16_t left, int16_t right); enum { PREFERRED_SAMPLE_RATE = 0x8000@@ -357,7 +357,7 @@ bool FFmpegEncoderIsOpen(struct FFmpegEncoder* encoder) {
return !!encoder->context; } -void _ffmpegPostAudioFrame(struct GBAAVStream* stream, int32_t left, int32_t right) { +void _ffmpegPostAudioFrame(struct GBAAVStream* stream, int16_t left, int16_t right) { struct FFmpegEncoder* encoder = (struct FFmpegEncoder*) stream; if (!encoder->context || !encoder->audioCodec) { return;