mirror of https://github.com/qTox/qTox.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
699 B
41 lines
699 B
#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(); |
|
} |
|
|
|
void AudioBuffer::clear() |
|
{ |
|
buffer.clear(); |
|
}
|
|
|