From 8c5a8be8b5ece9283f67b4e122a6099c1d883144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Thu, 10 Jul 2014 18:44:22 +0200 Subject: [PATCH] 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 --- daemon/src/audio/audiortp/audio_rtp_stream.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/daemon/src/audio/audiortp/audio_rtp_stream.cpp b/daemon/src/audio/audiortp/audio_rtp_stream.cpp index 00e8c17708..a364c47603 100644 --- a/daemon/src/audio/audiortp/audio_rtp_stream.cpp +++ b/daemon/src/audio/audiortp/audio_rtp_stream.cpp @@ -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()); -- GitLab