diff --git a/src/platform/qt/AudioProcessor.cpp b/src/platform/qt/AudioProcessor.cpp index 96f04d58b..d0b2b1f24 100644 --- a/src/platform/qt/AudioProcessor.cpp +++ b/src/platform/qt/AudioProcessor.cpp @@ -5,6 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "AudioProcessor.h" +#include "ConfigController.h" + #ifdef BUILD_SDL #include "AudioProcessorSDL.h" #endif @@ -51,8 +53,18 @@ AudioProcessor::~AudioProcessor() { stop(); } +void AudioProcessor::configure(ConfigController* config) { + const mCoreOptions* opts = config->options(); + setBufferSamples(opts->audioBuffers); + requestSampleRate(opts->sampleRate); +} + void AudioProcessor::setInput(std::shared_ptr input) { m_context = input; + connect(input.get(), &CoreController::stopping, this, &AudioProcessor::stop); + connect(input.get(), &CoreController::fastForwardChanged, this, &AudioProcessor::inputParametersChanged); + connect(input.get(), &CoreController::paused, this, &AudioProcessor::pause); + connect(input.get(), &CoreController::unpaused, this, &AudioProcessor::start); } void AudioProcessor::stop() { diff --git a/src/platform/qt/AudioProcessor.h b/src/platform/qt/AudioProcessor.h index 8043ad21c..50feb0a13 100644 --- a/src/platform/qt/AudioProcessor.h +++ b/src/platform/qt/AudioProcessor.h @@ -15,17 +15,15 @@ struct mCoreThread; namespace QGBA { +class ConfigController; + class AudioProcessor : public QObject { Q_OBJECT public: enum class Driver { -#ifdef BUILD_QT_MULTIMEDIA QT_MULTIMEDIA = 0, -#endif -#ifdef BUILD_SDL SDL = 1, -#endif }; static AudioProcessor* create(); @@ -37,6 +35,8 @@ public: int getBufferSamples() const { return m_samples; } virtual unsigned sampleRate() const = 0; + virtual void configure(ConfigController*); + public slots: virtual void setInput(std::shared_ptr); virtual void stop(); diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 76d308f19..a8e24fd0a 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -247,8 +247,7 @@ void Window::reloadConfig() { if (m_controller) { m_controller->loadConfig(m_config); if (m_audioProcessor) { - m_audioProcessor->setBufferSamples(opts->audioBuffers); - m_audioProcessor->requestSampleRate(opts->sampleRate); + m_audioProcessor->configure(m_config); } m_display->resizeContext(); } @@ -989,16 +988,10 @@ void Window::reloadAudioDriver() { m_audioProcessor.reset(); } - const mCoreOptions* opts = m_config->options(); m_audioProcessor = std::unique_ptr(AudioProcessor::create()); m_audioProcessor->setInput(m_controller); - m_audioProcessor->setBufferSamples(opts->audioBuffers); - m_audioProcessor->requestSampleRate(opts->sampleRate); + m_audioProcessor->configure(m_config); m_audioProcessor->start(); - connect(m_controller.get(), &CoreController::stopping, m_audioProcessor.get(), &AudioProcessor::stop); - connect(m_controller.get(), &CoreController::fastForwardChanged, m_audioProcessor.get(), &AudioProcessor::inputParametersChanged); - connect(m_controller.get(), &CoreController::paused, m_audioProcessor.get(), &AudioProcessor::pause); - connect(m_controller.get(), &CoreController::unpaused, m_audioProcessor.get(), &AudioProcessor::start); } void Window::changeRenderer() {