1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/audiobuffer.cpp
Tux3 / Mlkj / !Lev.uXFMLA f5a628fafb Audio call reception
Can hear, but can't talk

Uses a hardwired tox_do() interval of 50ms until to_do_interval() gets fixed
2014-06-27 19:01:10 +02:00

37 lines
648 B
C++

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