diff --git a/src/platform/qt/AudioProcessor.cpp b/src/platform/qt/AudioProcessor.cpp index 9c522134d..8e15b769b 100644 --- a/src/platform/qt/AudioProcessor.cpp +++ b/src/platform/qt/AudioProcessor.cpp @@ -58,10 +58,14 @@ void AudioProcessor::pause() { } 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()); + } } diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 08ae04c42..8305520f0 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -243,17 +243,26 @@ void GameController::keyReleased(int key) { } 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"); } diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 83eed7ccc..c678b1cc7 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -118,6 +118,14 @@ void Window::setOptions(GBAOptions* opts) { 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() {