GBA: Move A/V stream interface into core

This commit is contained in:
Jeffrey Pfau 2015-03-08 20:56:42 -07:00
parent cf71d39bf0
commit a000f219db
7 changed files with 16 additions and 12 deletions

View File

@ -70,6 +70,7 @@ Misc:
- Qt: Move frame upload back onto main thread - Qt: Move frame upload back onto main thread
- All: Enable link-time optimization - All: Enable link-time optimization
- GBA Thread: Make GBASyncWaitFrameStart time out - GBA Thread: Make GBASyncWaitFrameStart time out
- GBA: Move A/V stream interface into core
0.1.1: (2015-01-24) 0.1.1: (2015-01-24)
Bugfixes: Bugfixes:

View File

@ -822,9 +822,8 @@ static void _sample(struct GBAAudio* audio) {
} }
produced = blip_samples_avail(audio->left); produced = blip_samples_avail(audio->left);
#endif #endif
struct GBAThread* thread = GBAThreadGetContext(); if (audio->p->stream) {
if (thread && thread->stream) { audio->p->stream->postAudioFrame(audio->p->stream, sampleLeft, sampleRight);
thread->stream->postAudioFrame(thread->stream, sampleLeft, sampleRight);
} }
GBASyncProduceAudio(audio->p->sync, produced >= audio->samples); GBASyncProduceAudio(audio->p->sync, produced >= audio->samples);
} }

View File

@ -77,7 +77,9 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
gba->romVf = 0; gba->romVf = 0;
gba->biosVf = 0; gba->biosVf = 0;
gba->logHandler = 0;
gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL; 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); gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
@ -733,8 +735,8 @@ void GBAFrameEnded(struct GBA* gba) {
return; return;
} }
if (thread->stream) { if (gba->stream) {
thread->stream->postVideoFrame(thread->stream, thread->renderer); gba->stream->postVideoFrame(gba->stream, gba->video.renderer);
} }
if (thread->frameCallback) { if (thread->frameCallback) {

View File

@ -96,6 +96,11 @@ struct VFile;
typedef void (*GBALogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args); 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 { struct GBATimer {
uint16_t reload; uint16_t reload;
uint16_t oldReload; uint16_t oldReload;
@ -146,6 +151,7 @@ struct GBA {
GBALogHandler logHandler; GBALogHandler logHandler;
enum GBALogLevel logLevel; enum GBALogLevel logLevel;
struct GBAAVStream* stream;
enum GBAIdleLoopOptimization idleOptimization; enum GBAIdleLoopOptimization idleOptimization;
uint32_t idleLoop; uint32_t idleLoop;

View File

@ -135,6 +135,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
threadContext->gba = &gba; threadContext->gba = &gba;
gba.logLevel = threadContext->logLevel; gba.logLevel = threadContext->logLevel;
gba.logHandler = threadContext->logHandler; gba.logHandler = threadContext->logHandler;
gba.stream = threadContext->stream;
gba.idleOptimization = threadContext->idleOptimization; gba.idleOptimization = threadContext->idleOptimization;
#ifdef USE_PTHREADS #ifdef USE_PTHREADS
pthread_setspecific(_contextKey, threadContext); pthread_setspecific(_contextKey, threadContext);

View File

@ -48,11 +48,6 @@ struct GBASync {
Mutex audioBufferMutex; Mutex audioBufferMutex;
}; };
struct GBAAVStream {
void (*postVideoFrame)(struct GBAAVStream*, struct GBAVideoRenderer* renderer);
void (*postAudioFrame)(struct GBAAVStream*, int32_t left, int32_t right);
};
struct GBAThread { struct GBAThread {
// Output // Output
enum ThreadState state; enum ThreadState state;

View File

@ -22,7 +22,7 @@
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
static void _ffmpegPostVideoFrame(struct GBAAVStream*, struct GBAVideoRenderer* renderer); 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 { enum {
PREFERRED_SAMPLE_RATE = 0x8000 PREFERRED_SAMPLE_RATE = 0x8000
@ -357,7 +357,7 @@ bool FFmpegEncoderIsOpen(struct FFmpegEncoder* encoder) {
return !!encoder->context; 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; struct FFmpegEncoder* encoder = (struct FFmpegEncoder*) stream;
if (!encoder->context || !encoder->audioCodec) { if (!encoder->context || !encoder->audioCodec) {
return; return;