2014-07-14 05:03:36 +08:00
|
|
|
#ifndef AUDIOOUTPUTPROXY_H
|
|
|
|
#define AUDIOOUTPUTPROXY_H
|
|
|
|
|
|
|
|
#include <QIODevice>
|
|
|
|
#include "memring.h"
|
|
|
|
|
|
|
|
class AudioOutputProxy : public QIODevice
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit AudioOutputProxy(QObject *parent = 0);
|
|
|
|
virtual ~AudioOutputProxy();
|
|
|
|
|
2014-07-19 00:36:02 +08:00
|
|
|
inline size_t pull(int16_t *data, size_t len) { return ring_buffer->pull(data, len); }
|
|
|
|
inline size_t push(int16_t *data, size_t len) { return ring_buffer->push(data, len); }
|
|
|
|
inline size_t readSpace() { return ring_buffer->readSpace(); }
|
|
|
|
inline size_t writeSpace() { return ring_buffer->writeSpace(); }
|
|
|
|
|
2014-07-14 05:03:36 +08:00
|
|
|
protected:
|
|
|
|
qint64 readData(char *data, qint64 maxlen);
|
|
|
|
qint64 writeData(const char *data, qint64 len);
|
|
|
|
qint64 bytesAvailable() const;
|
2014-07-14 21:16:44 +08:00
|
|
|
bool isSequential() const;
|
2014-07-14 05:03:36 +08:00
|
|
|
|
|
|
|
private:
|
2014-07-14 21:16:44 +08:00
|
|
|
MemRing<int16_t> *ring_buffer;
|
2014-07-14 05:03:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AUDIOOUTPUTPROXY_H
|