Add audio resizing in injector

This commit is contained in:
Ryan Huffman 2016-01-27 13:47:09 -08:00
parent 8764eda479
commit 4de8e7a3c8

View file

@ -181,6 +181,15 @@ int64_t AudioInjector::injectNextFrame() {
// make sure we actually have samples downloaded to inject
if (_audioData.size()) {
auto sampleSize = (_options.stereo ? 2 : 1) * sizeof(AudioConstants::AudioSample);
auto numSamples = static_cast<int>(_audioData.size() / sampleSize);
auto targetSize = numSamples * sampleSize;
if (targetSize != _audioData.size()) {
qDebug() << "Resizing audio that doesn't end at multiple of sample size, resizing from "
<< _audioData.size() << " to " << targetSize;
_audioData.resize(targetSize);
}
_outgoingSequenceNumber = 0;
_nextFrame = 0;