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
Branches
No related tags found
No related merge requests found
......@@ -344,13 +344,11 @@ size_t AudioRtpStream::processDataEncode()
return 0;
}
const auto frameSize = out->frames();
const auto codecFrameSize = codec->getFrameSize();
if (codecFrameSize > frameSize) {
if (codecFrameSize > out->frames()) {
// PCM too small (underflow), add zero padding to avoid reading past
// end of buffer when encoding, for every channel
for (auto &c : out->getData())
c.resize(codecFrameSize, 0);
out->resize(codecFrameSize);
}
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