all repos — mgba @ a000f219db86e17722c87fc58a44602f6ce98292

mGBA Game Boy Advance Emulator

GBA: Move A/V stream interface into core
Jeffrey Pfau jeffrey@endrift.com
Sun, 08 Mar 2015 20:56:42 -0700
commit

a000f219db86e17722c87fc58a44602f6ce98292

parent

cf71d39bf031322cdec54ffffe947bda070f4125

M CHANGESCHANGES

@@ -70,6 +70,7 @@ - Qt: Optimize logo drawing

- Qt: Move frame upload back onto main thread - All: Enable link-time optimization - GBA Thread: Make GBASyncWaitFrameStart time out + - GBA: Move A/V stream interface into core 0.1.1: (2015-01-24) Bugfixes:
M src/gba/audio.csrc/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.csrc/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.hsrc/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.csrc/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.hsrc/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.csrc/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;