1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/audiobuffer.cpp

42 lines
699 B
C++
Raw Normal View History

#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();
}