Qt: Support loading fpsTarget and audioBuffers
Jeffrey Pfau jeffrey@endrift.com
Sun, 02 Nov 2014 02:58:47 -0800
3 files changed,
31 insertions(+),
10 deletions(-)
M
src/platform/qt/AudioProcessor.cpp
→
src/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.cpp
→
src/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.cpp
→
src/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() {