diff --git a/daemon/src/audio/audiortp/audio_rtp_stream.cpp b/daemon/src/audio/audiortp/audio_rtp_stream.cpp
index f79b0d7cb551de5741e8d1dee9f526c2770728a6..00e8c1770880661554158794ca47c7836258fc1f 100644
--- a/daemon/src/audio/audiortp/audio_rtp_stream.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_stream.cpp
@@ -343,6 +343,16 @@ size_t AudioRtpStream::processDataEncode()
             ERROR("Audio codec already destroyed");
             return 0;
         }
+
+        const auto frameSize = out->frames();
+        const auto codecFrameSize = codec->getFrameSize();
+        if (codecFrameSize > frameSize) {
+            // 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);
+        }
+
         size_t encoded = codec->encode(out->getData(), encodedData_.data(), encodedData_.size());
         return encoded;
     }