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)) {
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) {

View File

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

View File

@ -226,6 +226,8 @@ void GBAMapOptionsToContext(struct GBAOptions* opts, struct GBAThread* threadCon
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;

View File

@ -56,10 +56,7 @@ int main(int argc, char** argv) {
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) {
@ -72,6 +69,9 @@ int main(int argc, char** argv) {
GBAMapArgumentsToContext(&args, &context);
GBAMapOptionsToContext(&opts, &context);
context.sync.audioWait = false;
context.sync.videoFrameWait = false;
GBAThreadStart(&context);
GBAGetGameCode(context.gba, gameCode);

View File

@ -21,6 +21,9 @@ GBAApp::GBAApp(int& argc, char* argv[])
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);

View File

@ -39,6 +39,9 @@ public:
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*);

View File

@ -113,7 +113,10 @@ void Window::argumentsPassed(GBAArguments* args) {
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 @@ void Window::setupMenu(QMenuBar* menubar) {
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);

View File

@ -69,7 +69,11 @@ int main(int argc, char** argv) {
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 @@ int main(int argc, char** argv) {
struct GBAThread context = {
.renderer = &renderer.d.d,
.audioBuffers = 512,
.startCallback = _GBASDLStart,
.cleanCallback = _GBASDLClean,
.sync.videoFrameWait = false,
.sync.audioWait = true,
.userData = &renderer
};