-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathQAudioDecoderStream.h
54 lines (39 loc) · 1.05 KB
/
QAudioDecoderStream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef QAUDIODECODERSTREAM_H
#define QAUDIODECODERSTREAM_H
#include <QBuffer>
#include <QAudioDecoder>
#include <QAudioFormat>
#include <QFile>
#include "QAbstractMixerStream.h"
class QAudioDecoderStream : public QAbstractMixerStream
{
public:
QAudioDecoderStream(const QString &fileName, const QAudioFormat &format);
bool atEnd() const override;
void play() override;
void pause() override;
void stop() override;
QtMixer::State state() const override;
int loops() const override;
void setLoops(int loops) override;
int position() const override;
void setPosition(int position) override;
int length() override;
protected:
qint64 readData(char *data, qint64 maxlen) override;
qint64 writeData(const char *data, qint64 len) override;
private:
void rewind();
void bufferReady();
void finished();
QFile m_file;
QBuffer m_input;
QBuffer m_output;
QByteArray m_data;
QAudioDecoder m_decoder;
QAudioFormat m_format;
QtMixer::State m_state;
int m_loops;
int m_remainingLoops;
};
#endif // QAUDIODECODERSTREAM_H