GBA Config: Add audio/video sync setting
Jeffrey Pfau jeffrey@endrift.com
Tue, 04 Nov 2014 01:19:10 -0800
8 files changed,
33 insertions(+),
10 deletions(-)
M
src/gba/gba-config.c
→
src/gba/gba-config.c
@@ -84,6 +84,14 @@ unsigned audioBuffers;
if (_lookupUIntValue(config, "audioBuffers", port, &audioBuffers)) { opts->audioBuffers = audioBuffers; } + + int fakeBool; + if (_lookupIntValue(config, "audioSync", port, &fakeBool)) { + opts->audioSync = fakeBool; + } + if (_lookupIntValue(config, "videoSync", port, &fakeBool)) { + opts->videoSync = fakeBool; + } } void GBAConfigMapGraphicsOpts(const struct Configuration* config, const char* port, struct GBAOptions* opts) {
M
src/gba/gba-config.h
→
src/gba/gba-config.h
@@ -17,6 +17,9 @@
int fullscreen; int width; int height; + + bool videoSync; + bool audioSync; }; bool GBAConfigLoad(struct Configuration*);
M
src/gba/gba-thread.c
→
src/gba/gba-thread.c
@@ -226,6 +226,8 @@ threadContext->frameskip = opts->frameskip;
threadContext->logLevel = opts->logLevel; threadContext->rewindBufferCapacity = opts->rewindBufferCapacity; threadContext->rewindBufferInterval = opts->rewindBufferInterval; + threadContext->sync.audioWait = opts->audioSync; + threadContext->sync.videoFrameWait = opts->videoSync; if (opts->fpsTarget) { threadContext->fpsTarget = opts->fpsTarget;
M
src/platform/perf-main.c
→
src/platform/perf-main.c
@@ -56,10 +56,7 @@
renderer.outputBuffer = malloc(256 * 256 * 4); renderer.outputBufferStride = 256; - struct GBAThread context = { - .sync.videoFrameWait = 0, - .sync.audioWait = 0 - }; + struct GBAThread context = { }; _thread = &context; if (!perfOpts.noVideo) {@@ -71,6 +68,9 @@ char gameCode[5] = { 0 };
GBAMapArgumentsToContext(&args, &context); GBAMapOptionsToContext(&opts, &context); + + context.sync.audioWait = false; + context.sync.videoFrameWait = false; GBAThreadStart(&context); GBAGetGameCode(context.gba, gameCode);
M
src/platform/qt/GBAApp.cpp
→
src/platform/qt/GBAApp.cpp
@@ -21,6 +21,9 @@
ConfigurationInit(&config); GBAConfigLoad(&config); + m_opts.audioSync = GameController::AUDIO_SYNC; + m_opts.videoSync = GameController::VIDEO_SYNC; + GBAConfigMapGeneralOpts(&config, PORT, &m_opts); GBAConfigMapGraphicsOpts(&config, PORT, &m_opts);
M
src/platform/qt/GameController.h
→
src/platform/qt/GameController.h
@@ -39,6 +39,9 @@
bool isPaused(); bool isLoaded() { return m_gameOpen; } + bool audioSync() const { return m_audioSync; } + bool videoSync() const { return m_videoSync; } + #ifdef USE_GDB_STUB ARMDebugger* debugger(); void setDebugger(ARMDebugger*);
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -113,7 +113,10 @@ }
void Window::setOptions(GBAOptions* opts) { m_logView->setLevels(opts->logLevel); + // TODO: Have these show up as modified in the menu m_controller->setFrameskip(opts->frameskip); + m_controller->setAudioSync(opts->audioSync); + m_controller->setVideoSync(opts->videoSync); if (opts->bios) { m_controller->loadBIOS(opts->bios);@@ -413,13 +416,13 @@ emulationMenu->addAction(turbo);
QAction* videoSync = new QAction(tr("Sync to &video"), emulationMenu); videoSync->setCheckable(true); - videoSync->setChecked(GameController::VIDEO_SYNC); + videoSync->setChecked(m_controller->videoSync()); connect(videoSync, SIGNAL(triggered(bool)), m_controller, SLOT(setVideoSync(bool))); emulationMenu->addAction(videoSync); QAction* audioSync = new QAction(tr("Sync to &audio"), emulationMenu); audioSync->setCheckable(true); - audioSync->setChecked(GameController::AUDIO_SYNC); + audioSync->setChecked(m_controller->audioSync()); connect(audioSync, SIGNAL(triggered(bool)), m_controller, SLOT(setAudioSync(bool))); emulationMenu->addAction(audioSync);
M
src/platform/sdl/gl-main.c
→
src/platform/sdl/gl-main.c
@@ -69,7 +69,11 @@ struct Configuration config;
ConfigurationInit(&config); GBAConfigLoad(&config); - struct GBAOptions opts = {}; + struct GBAOptions opts = { + .audioBuffers = 512, + .videoSync = false, + .audioSync = true, + }; struct GBAArguments args = {}; struct GraphicsOpts graphicsOpts = {};@@ -101,11 +105,8 @@ }
struct GBAThread context = { .renderer = &renderer.d.d, - .audioBuffers = 512, .startCallback = _GBASDLStart, .cleanCallback = _GBASDLClean, - .sync.videoFrameWait = false, - .sync.audioWait = true, .userData = &renderer };