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 GBAAudio;
10
11namespace QGBA {
12
13
14
15class AudioThread : public QThread {
16Q_OBJECT
17
18public:
19 AudioThread(QObject* parent = 0);
20
21 void setInput(GBAAudio* input);
22
23public slots:
24 void shutdown();
25
26protected:
27 void run();
28
29private:
30 GBAAudio* m_input;
31 QAudioOutput* m_audioOutput;
32};
33
34class AudioDevice : public QIODevice {
35Q_OBJECT
36
37public:
38 AudioDevice(GBAAudio* audio, QObject* parent = 0);
39
40 void setFormat(const QAudioFormat& format);
41
42protected:
43 virtual qint64 readData(char* data, qint64 maxSize);
44 virtual qint64 writeData(const char* data, qint64 maxSize);
45
46private:
47 GBAAudio* m_audio;
48 float m_drift;
49 float m_ratio;
50};
51
52}
53
54#endif