GBA Config: Add audio/video sync setting

This commit is contained in:
Jeffrey Pfau 2014-11-04 01:19:10 -08:00
parent d3bb022bf1
commit 4115b240eb
8 changed files with 33 additions and 10 deletions

View File

@ -84,6 +84,14 @@ void GBAConfigMapGeneralOpts(const struct Configuration* config, const char* por
if (_lookupUIntValue(config, "audioBuffers", port, &audioBuffers)) { if (_lookupUIntValue(config, "audioBuffers", port, &audioBuffers)) {
opts->audioBuffers = 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) { void GBAConfigMapGraphicsOpts(const struct Configuration* config, const char* port, struct GBAOptions* opts) {

View File

@ -17,6 +17,9 @@ struct GBAOptions {
int fullscreen; int fullscreen;
int width; int width;
int height; int height;
bool videoSync;
bool audioSync;
}; };
bool GBAConfigLoad(struct Configuration*); bool GBAConfigLoad(struct Configuration*);

View File

@ -226,6 +226,8 @@ void GBAMapOptionsToContext(struct GBAOptions* opts, struct GBAThread* threadCon
threadContext->logLevel = opts->logLevel; threadContext->logLevel = opts->logLevel;
threadContext->rewindBufferCapacity = opts->rewindBufferCapacity; threadContext->rewindBufferCapacity = opts->rewindBufferCapacity;
threadContext->rewindBufferInterval = opts->rewindBufferInterval; threadContext->rewindBufferInterval = opts->rewindBufferInterval;
threadContext->sync.audioWait = opts->audioSync;
threadContext->sync.videoFrameWait = opts->videoSync;
if (opts->fpsTarget) { if (opts->fpsTarget) {
threadContext->fpsTarget = opts->fpsTarget; threadContext->fpsTarget = opts->fpsTarget;

View File

@ -56,10 +56,7 @@ int main(int argc, char** argv) {
renderer.outputBuffer = malloc(256 * 256 * 4); renderer.outputBuffer = malloc(256 * 256 * 4);
renderer.outputBufferStride = 256; renderer.outputBufferStride = 256;
struct GBAThread context = { struct GBAThread context = { };
.sync.videoFrameWait = 0,
.sync.audioWait = 0
};
_thread = &context; _thread = &context;
if (!perfOpts.noVideo) { if (!perfOpts.noVideo) {
@ -72,6 +69,9 @@ int main(int argc, char** argv) {
GBAMapArgumentsToContext(&args, &context); GBAMapArgumentsToContext(&args, &context);
GBAMapOptionsToContext(&opts, &context); GBAMapOptionsToContext(&opts, &context);
context.sync.audioWait = false;
context.sync.videoFrameWait = false;
GBAThreadStart(&context); GBAThreadStart(&context);
GBAGetGameCode(context.gba, gameCode); GBAGetGameCode(context.gba, gameCode);

View File

@ -21,6 +21,9 @@ GBAApp::GBAApp(int& argc, char* argv[])
ConfigurationInit(&config); ConfigurationInit(&config);
GBAConfigLoad(&config); GBAConfigLoad(&config);
m_opts.audioSync = GameController::AUDIO_SYNC;
m_opts.videoSync = GameController::VIDEO_SYNC;
GBAConfigMapGeneralOpts(&config, PORT, &m_opts); GBAConfigMapGeneralOpts(&config, PORT, &m_opts);
GBAConfigMapGraphicsOpts(&config, PORT, &m_opts); GBAConfigMapGraphicsOpts(&config, PORT, &m_opts);

View File

@ -39,6 +39,9 @@ public:
bool isPaused(); bool isPaused();
bool isLoaded() { return m_gameOpen; } bool isLoaded() { return m_gameOpen; }
bool audioSync() const { return m_audioSync; }
bool videoSync() const { return m_videoSync; }
#ifdef USE_GDB_STUB #ifdef USE_GDB_STUB
ARMDebugger* debugger(); ARMDebugger* debugger();
void setDebugger(ARMDebugger*); void setDebugger(ARMDebugger*);

View File

@ -113,7 +113,10 @@ void Window::argumentsPassed(GBAArguments* args) {
void Window::setOptions(GBAOptions* opts) { void Window::setOptions(GBAOptions* opts) {
m_logView->setLevels(opts->logLevel); m_logView->setLevels(opts->logLevel);
// TODO: Have these show up as modified in the menu
m_controller->setFrameskip(opts->frameskip); m_controller->setFrameskip(opts->frameskip);
m_controller->setAudioSync(opts->audioSync);
m_controller->setVideoSync(opts->videoSync);
if (opts->bios) { if (opts->bios) {
m_controller->loadBIOS(opts->bios); m_controller->loadBIOS(opts->bios);
@ -413,13 +416,13 @@ void Window::setupMenu(QMenuBar* menubar) {
QAction* videoSync = new QAction(tr("Sync to &video"), emulationMenu); QAction* videoSync = new QAction(tr("Sync to &video"), emulationMenu);
videoSync->setCheckable(true); videoSync->setCheckable(true);
videoSync->setChecked(GameController::VIDEO_SYNC); videoSync->setChecked(m_controller->videoSync());
connect(videoSync, SIGNAL(triggered(bool)), m_controller, SLOT(setVideoSync(bool))); connect(videoSync, SIGNAL(triggered(bool)), m_controller, SLOT(setVideoSync(bool)));
emulationMenu->addAction(videoSync); emulationMenu->addAction(videoSync);
QAction* audioSync = new QAction(tr("Sync to &audio"), emulationMenu); QAction* audioSync = new QAction(tr("Sync to &audio"), emulationMenu);
audioSync->setCheckable(true); audioSync->setCheckable(true);
audioSync->setChecked(GameController::AUDIO_SYNC); audioSync->setChecked(m_controller->audioSync());
connect(audioSync, SIGNAL(triggered(bool)), m_controller, SLOT(setAudioSync(bool))); connect(audioSync, SIGNAL(triggered(bool)), m_controller, SLOT(setAudioSync(bool)));
emulationMenu->addAction(audioSync); emulationMenu->addAction(audioSync);

View File

@ -69,7 +69,11 @@ int main(int argc, char** argv) {
ConfigurationInit(&config); ConfigurationInit(&config);
GBAConfigLoad(&config); GBAConfigLoad(&config);
struct GBAOptions opts = {}; struct GBAOptions opts = {
.audioBuffers = 512,
.videoSync = false,
.audioSync = true,
};
struct GBAArguments args = {}; struct GBAArguments args = {};
struct GraphicsOpts graphicsOpts = {}; struct GraphicsOpts graphicsOpts = {};
@ -101,11 +105,8 @@ int main(int argc, char** argv) {
struct GBAThread context = { struct GBAThread context = {
.renderer = &renderer.d.d, .renderer = &renderer.d.d,
.audioBuffers = 512,
.startCallback = _GBASDLStart, .startCallback = _GBASDLStart,
.cleanCallback = _GBASDLClean, .cleanCallback = _GBASDLClean,
.sync.videoFrameWait = false,
.sync.audioWait = true,
.userData = &renderer .userData = &renderer
}; };