2014-06-28 00:51:08 +08:00
|
|
|
#ifndef AUDIOBUFFER_H
|
|
|
|
#define AUDIOBUFFER_H
|
|
|
|
|
|
|
|
#include <QIODevice>
|
|
|
|
#include <QByteArray>
|
2014-07-02 04:04:19 +08:00
|
|
|
#include <QMutex>
|
2014-06-28 00:51:08 +08:00
|
|
|
|
|
|
|
class AudioBuffer : public QIODevice
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit AudioBuffer();
|
|
|
|
~AudioBuffer();
|
|
|
|
|
|
|
|
qint64 readData(char *data, qint64 maxlen);
|
|
|
|
qint64 writeData(const char *data, qint64 len);
|
|
|
|
qint64 bytesAvailable() const;
|
|
|
|
qint64 bufferSize() const;
|
2014-06-28 02:24:00 +08:00
|
|
|
void clear();
|
2014-06-28 00:51:08 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QByteArray buffer;
|
2014-07-02 04:04:19 +08:00
|
|
|
mutable QMutex bufferMutex;
|
2014-06-28 00:51:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AUDIOBUFFER_H
|