Skip to content
Snippets Groups Projects
Commit 8c5a8be8 authored by Adrien Béraud's avatar Adrien Béraud Committed by Tristan Matthews
Browse files

audiortp: use AudioBuffer::resize instead of std::vector::resize

Removes the dependency on AudioBuffer implementation details :
AudioBuffer provides a resize() method that resizes all channels at once,
with zero padding if the new size is larger.

Refs #49181

Change-Id: Ib0b6e6e7fef6fffa89b545a11940439022d5b150
parent 44285fd7
No related branches found
No related tags found
No related merge requests found
...@@ -344,13 +344,11 @@ size_t AudioRtpStream::processDataEncode() ...@@ -344,13 +344,11 @@ size_t AudioRtpStream::processDataEncode()
return 0; return 0;
} }
const auto frameSize = out->frames();
const auto codecFrameSize = codec->getFrameSize(); const auto codecFrameSize = codec->getFrameSize();
if (codecFrameSize > frameSize) { if (codecFrameSize > out->frames()) {
// PCM too small (underflow), add zero padding to avoid reading past // PCM too small (underflow), add zero padding to avoid reading past
// end of buffer when encoding, for every channel // end of buffer when encoding, for every channel
for (auto &c : out->getData()) out->resize(codecFrameSize);
c.resize(codecFrameSize, 0);
} }
size_t encoded = codec->encode(out->getData(), encodedData_.data(), encodedData_.size()); size_t encoded = codec->encode(out->getData(), encodedData_.data(), encodedData_.size());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment