maintain network audio in int16_t

This commit is contained in:
Zach Pomerantz 2017-01-20 18:37:46 -05:00
parent 685483b924
commit df051ff8df
2 changed files with 11 additions and 11 deletions

View file

@ -1248,23 +1248,24 @@ void AudioClient::processReceivedSamples(const QByteArray& decodedBuffer, QByteA
outputBuffer.resize(_outputFrameSize * AudioConstants::SAMPLE_SIZE); outputBuffer.resize(_outputFrameSize * AudioConstants::SAMPLE_SIZE);
int16_t* outputSamples = reinterpret_cast<int16_t*>(outputBuffer.data()); int16_t* outputSamples = reinterpret_cast<int16_t*>(outputBuffer.data());
convertToMix(_networkMixBuffer, decodedSamples, AudioConstants::NETWORK_FRAME_SAMPLES_STEREO);
// apply stereo reverb
bool hasReverb = _reverb || _receivedAudioStream.hasReverb(); bool hasReverb = _reverb || _receivedAudioStream.hasReverb();
// apply stereo reverb
if (hasReverb) { if (hasReverb) {
updateReverbOptions(); updateReverbOptions();
_listenerReverb.render(_networkMixBuffer, _networkMixBuffer, AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL); int16_t* reverbSamples = _networkToOutputResampler ? _networkScratchBuffer : outputSamples;
_listenerReverb.render(decodedSamples, reverbSamples, AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL);
} }
// resample to output sample rate
if (_networkToOutputResampler) { if (_networkToOutputResampler) {
convertToScratch(_networkScratchBuffer, _networkMixBuffer, AudioConstants::NETWORK_FRAME_SAMPLES_STEREO); const int16_t* inputSamples = hasReverb ? _networkScratchBuffer : decodedSamples;
_networkToOutputResampler->render(inputSamples, outputSamples, AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL);
}
// resample to output sample rate // if no transformations were applied, we still need to copy the buffer
_networkToOutputResampler->render(_networkScratchBuffer, outputSamples, AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL); if (!hasReverb && !_networkToOutputResampler) {
memcpy(outputSamples, decodedSamples, decodedBuffer.size());
} else {
convertToScratch(outputSamples, _networkMixBuffer, AudioConstants::NETWORK_FRAME_SAMPLES_STEREO);
} }
} }

View file

@ -318,7 +318,6 @@ private:
AudioSRC* _localToOutputResampler; AudioSRC* _localToOutputResampler;
// for network audio (used by network audio thread) // for network audio (used by network audio thread)
float _networkMixBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_STEREO];
int16_t _networkScratchBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_AMBISONIC]; int16_t _networkScratchBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_AMBISONIC];
// for local audio (used by audio injectors thread) // for local audio (used by audio injectors thread)