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
- 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:

View File

@ -822,9 +822,8 @@ static void _sample(struct GBAAudio* audio) {
}
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);
}

View File

@ -77,7 +77,9 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
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 @@ void GBAFrameEnded(struct GBA* gba) {
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) {

View File

@ -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 @@ struct GBA {
GBALogHandler logHandler;
enum GBALogLevel logLevel;
struct GBAAVStream* stream;
enum GBAIdleLoopOptimization idleOptimization;
uint32_t idleLoop;

View File

@ -135,6 +135,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
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);

View File

@ -48,11 +48,6 @@ struct GBASync {
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;

View File

@ -22,7 +22,7 @@
#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;