all repos — mgba @ 67880084187c309ca7049f7e8a22859006172f8d

mGBA Game Boy Advance Emulator

Qt: Support loading fpsTarget and audioBuffers
Jeffrey Pfau jeffrey@endrift.com
Sun, 02 Nov 2014 02:58:47 -0800
commit

67880084187c309ca7049f7e8a22859006172f8d

parent

776c64b0c84a0da699e5bfb7aaba22b0876632d2

3 files changed, 31 insertions(+), 10 deletions(-)

jump to
M src/platform/qt/AudioProcessor.cppsrc/platform/qt/AudioProcessor.cpp

@@ -58,10 +58,14 @@ }

} void AudioProcessor::setBufferSamples(int samples) { - QAudioFormat format = m_audioOutput->format(); - m_audioOutput->setBufferSize(samples * format.channelCount() * format.sampleSize() / 8); + if (m_audioOutput) { + QAudioFormat format = m_audioOutput->format(); + m_audioOutput->setBufferSize(samples * format.channelCount() * format.sampleSize() / 8); + } } void AudioProcessor::inputParametersChanged() { - m_device->setFormat(m_audioOutput->format()); + if (m_device) { + m_device->setFormat(m_audioOutput->format()); + } }
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -243,17 +243,26 @@ updateKeys();

} void GameController::setAudioBufferSamples(int samples) { - GBAThreadInterrupt(&m_threadContext); - m_threadContext.audioBuffers = samples; - GBAAudioResizeBuffer(&m_threadContext.gba->audio, samples); - GBAThreadContinue(&m_threadContext); + if (m_gameOpen) { + GBAThreadInterrupt(&m_threadContext); + m_threadContext.audioBuffers = samples; + GBAAudioResizeBuffer(&m_threadContext.gba->audio, samples); + GBAThreadContinue(&m_threadContext); + } else { + m_threadContext.audioBuffers = samples; + + } QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples)); } void GameController::setFPSTarget(float fps) { - GBAThreadInterrupt(&m_threadContext); - m_threadContext.fpsTarget = fps; - GBAThreadContinue(&m_threadContext); + if (m_gameOpen) { + GBAThreadInterrupt(&m_threadContext); + m_threadContext.fpsTarget = fps; + GBAThreadContinue(&m_threadContext); + } else { + m_threadContext.fpsTarget = fps; + } QMetaObject::invokeMethod(m_audioProcessor, "inputParametersChanged"); }
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -118,6 +118,14 @@

if (opts->bios) { m_controller->loadBIOS(opts->bios); } + + if (opts->fpsTarget) { + emit fpsTargetChanged(opts->fpsTarget); + } + + if (opts->audioBuffers) { + emit audioBufferSamplesChanged(opts->audioBuffers); + } } void Window::selectROM() {