all repos — mgba @ b691c93416d44b89e16df3f700c00198deb7cf1f

mGBA Game Boy Advance Emulator

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

 1#ifndef QGBA_AUDIO_DEVICE
 2#define QGBA_AUDIO_DEVICE
 3
 4#include <QAudioFormat>
 5#include <QAudioOutput>
 6#include <QIODevice>
 7#include <QThread>
 8
 9struct GBAThread;
10
11namespace QGBA {
12
13class AudioDevice : public QIODevice {
14Q_OBJECT
15
16public:
17	AudioDevice(GBAThread* threadContext, QObject* parent = nullptr);
18
19	void setFormat(const QAudioFormat& format);
20
21protected:
22	virtual qint64 readData(char* data, qint64 maxSize) override;
23	virtual qint64 writeData(const char* data, qint64 maxSize) override;
24
25private:
26	GBAThread* m_context;
27	float m_drift;
28	float m_ratio;
29};
30
31class AudioThread : public QThread {
32Q_OBJECT
33
34public:
35	AudioThread(QObject* parent = nullptr);
36
37	void setInput(GBAThread* input);
38
39public slots:
40	void shutdown();
41	void pause();
42	void resume();
43
44protected:
45	void run();
46
47private:
48	GBAThread* m_input;
49	QAudioOutput* m_audioOutput;
50	AudioDevice* m_device;
51};
52
53}
54
55#endif