fixes for all current headsets work

This commit is contained in:
Stephen Birarda 2013-12-16 15:31:05 -08:00
parent 6b644eb130
commit f7ed8cef8f

View file

@ -185,14 +185,16 @@ void linearResampling(int16_t* sourceSamples, int16_t* destinationSamples,
// we need to downsample from 48 to 24 // we need to downsample from 48 to 24
// for now this only supports a mono output - this would be the case for audio input // for now this only supports a mono output - this would be the case for audio input
for (int i = 2; i < numSourceSamples; i += 4) { for (int i = sourceAudioFormat.channelCount(); i < numSourceSamples; i += 2 * sourceAudioFormat.channelCount()) {
if (i + 2 >= numSourceSamples) { if (i + (sourceAudioFormat.channelCount()) >= numSourceSamples) {
destinationSamples[(i - 2) / 4] = (sourceSamples[i - 2] / 2) destinationSamples[(i - sourceAudioFormat.channelCount()) / (int) sourceToDestinationFactor] =
(sourceSamples[i - sourceAudioFormat.channelCount()] / 2)
+ (sourceSamples[i] / 2); + (sourceSamples[i] / 2);
} else { } else {
destinationSamples[(i - 2) / 4] = (sourceSamples[i - 2] / 4) destinationSamples[(i - sourceAudioFormat.channelCount()) / (int) sourceToDestinationFactor] =
(sourceSamples[i - sourceAudioFormat.channelCount()] / 4)
+ (sourceSamples[i] / 2) + (sourceSamples[i] / 2)
+ (sourceSamples[i + 2] / 4); + (sourceSamples[i + sourceAudioFormat.channelCount()] / 4);
} }
} }
@ -448,7 +450,8 @@ void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
// add output (@speakers) data just written to the scope // add output (@speakers) data just written to the scope
QMetaObject::invokeMethod(_scope, "addSamples", Qt::QueuedConnection, QMetaObject::invokeMethod(_scope, "addSamples", Qt::QueuedConnection,
Q_ARG(QByteArray, outputBuffer), Q_ARG(QByteArray, QByteArray((char*) ringBufferSamples,
NETWORK_BUFFER_LENGTH_BYTES_STEREO)),
Q_ARG(bool, true), Q_ARG(bool, false)); Q_ARG(bool, true), Q_ARG(bool, false));
} }
} }