mirror of https://github.com/qTox/qTox.git
Browse Source
Can hear, but can't talk Uses a hardwired tox_do() interval of 50ms until to_do_interval() gets fixedpull/9/merge
5 changed files with 94 additions and 19 deletions
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
#include "audiobuffer.h" |
||||
|
||||
AudioBuffer::AudioBuffer() : |
||||
QIODevice(0) |
||||
{ |
||||
open(QIODevice::ReadOnly); |
||||
} |
||||
|
||||
AudioBuffer::~AudioBuffer() |
||||
{ |
||||
close(); |
||||
} |
||||
|
||||
qint64 AudioBuffer::readData(char *data, qint64 len) |
||||
{ |
||||
const qint64 total = qMin((qint64)buffer.size(), len); |
||||
memcpy(data, buffer.constData(), total); |
||||
buffer = buffer.mid(total); |
||||
return total; |
||||
} |
||||
|
||||
qint64 AudioBuffer::writeData(const char* data, qint64 len) |
||||
{ |
||||
buffer.append(data, len); |
||||
return 0; |
||||
} |
||||
|
||||
qint64 AudioBuffer::bytesAvailable() const |
||||
{ |
||||
return buffer.size() + QIODevice::bytesAvailable(); |
||||
} |
||||
|
||||
qint64 AudioBuffer::bufferSize() const |
||||
{ |
||||
return buffer.size(); |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
#ifndef AUDIOBUFFER_H |
||||
#define AUDIOBUFFER_H |
||||
|
||||
#include <QIODevice> |
||||
#include <QByteArray> |
||||
|
||||
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; |
||||
|
||||
private: |
||||
QByteArray buffer; |
||||
}; |
||||
|
||||
#endif // AUDIOBUFFER_H
|
Loading…
Reference in new issue