all repos — mgba @ 3227d74e4d434d497673e5a77589b674e811c969

mGBA Game Boy Advance Emulator

src/platform/qt/AudioProcessor.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#pragma once
 7
 8#include <QObject>
 9
10#include <memory>
11
12#include "CoreController.h"
13
14struct mCoreThread;
15
16namespace QGBA {
17
18class AudioProcessor : public QObject {
19Q_OBJECT
20
21public:
22	enum class Driver {
23#ifdef BUILD_QT_MULTIMEDIA
24		QT_MULTIMEDIA = 0,
25#endif
26#ifdef BUILD_SDL
27		SDL = 1,
28#endif
29	};
30
31	static AudioProcessor* create();
32	static void setDriver(Driver driver) { s_driver = driver; }
33
34	AudioProcessor(QObject* parent = nullptr);
35	~AudioProcessor();
36
37	int getBufferSamples() const { return m_samples; }
38	virtual unsigned sampleRate() const = 0;
39
40public slots:
41	virtual void setInput(std::shared_ptr<CoreController>);
42	virtual void stop();
43
44	virtual bool start() = 0;
45	virtual void pause() = 0;
46
47	virtual void setBufferSamples(int samples) = 0;
48	virtual void inputParametersChanged() = 0;
49
50	virtual void requestSampleRate(unsigned) = 0;
51
52protected:
53	mCoreThread* input() { return m_context->thread(); }
54
55private:
56	std::shared_ptr<CoreController> m_context;
57	int m_samples = 2048;
58	static Driver s_driver;
59};
60
61}