Handle malformed audio packets received during RTSP stream switching
During RTSP stream switching (for example channel switching in a
Mobile TV application) we occasionally receive packets that
don't contain valid data, so we cannot remove LATM framing (as per
the MPEG4 Audio Assembler). This fix allows the frame remover
to exit gracefully (instead of crashing), when such frames are
encountered, and as a consequence, Mobile TV apps can change
channels properly.
Change-Id: Ie4c3d2766c87b43f31624192de96bc47180ca514
diff --git a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
index a1a6576..82a0631 100644
--- a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
+++ b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
@@ -379,7 +379,10 @@
unsigned muxSlotLengthBytes = 0;
unsigned tmp;
do {
- CHECK_LT(offset, buffer->size());
+ if (offset >= buffer->size()) {
+ ALOGW("Malformed buffer received");
+ return out;
+ }
tmp = ptr[offset++];
muxSlotLengthBytes += tmp;
} while (tmp == 0xff);