mirror of https://github.com/mgba-emu/mgba.git
Qt: AudioProcessor refactoring
This commit is contained in:
parent
d1d9e796af
commit
9f099eab0b
|
@ -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<CoreController> 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() {
|
||||
|
|
|
@ -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<CoreController>);
|
||||
virtual void stop();
|
||||
|
|
|
@ -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>(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() {
|
||||
|
|
Loading…
Reference in New Issue