mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-28 02:19:54 +02:00
fixed wrapped read of samples from end of buffer
This commit is contained in:
parent
cff4994c01
commit
96fd73a766
2 changed files with 3 additions and 4 deletions
|
@ -495,12 +495,11 @@ void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
|
|||
_desiredOutputFormat, _outputFormat);
|
||||
|
||||
if (_outputDevice) {
|
||||
|
||||
_outputDevice->write(outputBuffer);
|
||||
|
||||
// add output (@speakers) data just written to the scope
|
||||
QMetaObject::invokeMethod(_scope, "addSamples", Qt::QueuedConnection,
|
||||
Q_ARG(QByteArray, QByteArray((char*) ringBufferSamples, numDeviceOutputSamples)),
|
||||
Q_ARG(QByteArray, QByteArray((char*) ringBufferSamples, numNetworkOutputSamples)),
|
||||
Q_ARG(bool, true), Q_ARG(bool, false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@ qint64 AudioRingBuffer::readData(char *data, qint64 maxSize) {
|
|||
// read to the end of the buffer
|
||||
int numSamplesToEnd = (_buffer + _sampleCapacity) - _nextOutput;
|
||||
memcpy(data, _nextOutput, numSamplesToEnd * sizeof(int16_t));
|
||||
|
||||
|
||||
// read the rest from the beginning of the buffer
|
||||
memcpy(data + numSamplesToEnd, _buffer, (numReadSamples - numSamplesToEnd) * sizeof(int16_t));
|
||||
memcpy(data + (numSamplesToEnd * sizeof(int16_t)), _buffer, (numReadSamples - numSamplesToEnd) * sizeof(int16_t));
|
||||
} else {
|
||||
// read the data
|
||||
memcpy(data, _nextOutput, numReadSamples * sizeof(int16_t));
|
||||
|
|
Loading…
Reference in a new issue