diff options
author | Andreas Huber <andih@google.com> | 2010-04-12 09:57:05 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-04-12 09:57:05 -0700 |
commit | 9dcda21086608a52a579ac8254991fdde686823a (patch) | |
tree | 28fb9d2311ffbdd3d51a5ed4d0f1f47b97268196 | |
parent | 465d5a7f3517f11aaa819c8ae982e113ad5ec479 (diff) | |
download | frameworks_av-9dcda21086608a52a579ac8254991fdde686823a.zip frameworks_av-9dcda21086608a52a579ac8254991fdde686823a.tar.gz frameworks_av-9dcda21086608a52a579ac8254991fdde686823a.tar.bz2 |
Ignore corrupt aac audio frames and substitute silence.
Change-Id: I544f98a5c00d912061db7921fc4518435209b168
related-to-bug: 2575976
-rw-r--r-- | media/libstagefright/codecs/aacdec/AACDecoder.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/media/libstagefright/codecs/aacdec/AACDecoder.cpp b/media/libstagefright/codecs/aacdec/AACDecoder.cpp index 2ed8ef1..ae23691 100644 --- a/media/libstagefright/codecs/aacdec/AACDecoder.cpp +++ b/media/libstagefright/codecs/aacdec/AACDecoder.cpp @@ -203,25 +203,32 @@ status_t AACDecoder::read( Int decoderErr = PVMP4AudioDecodeFrame(mConfig, mDecoderBuf); + size_t numOutBytes = + mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels; + if (decoderErr != MP4AUDEC_SUCCESS) { - LOGE("AAC decoder returned error %d", decoderErr); + LOGW("AAC decoder returned error %d, substituting silence", decoderErr); - buffer->release(); - buffer = NULL; + memset(buffer->data(), 0, numOutBytes); - return ERROR_MALFORMED; + // Discard input buffer. + mInputBuffer->release(); + mInputBuffer = NULL; + + // fall through } - buffer->set_range( - 0, mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels); + buffer->set_range(0, numOutBytes); - mInputBuffer->set_range( - mInputBuffer->range_offset() + mConfig->inputBufferUsedLength, - mInputBuffer->range_length() - mConfig->inputBufferUsedLength); + if (mInputBuffer != NULL) { + mInputBuffer->set_range( + mInputBuffer->range_offset() + mConfig->inputBufferUsedLength, + mInputBuffer->range_length() - mConfig->inputBufferUsedLength); - if (mInputBuffer->range_length() == 0) { - mInputBuffer->release(); - mInputBuffer = NULL; + if (mInputBuffer->range_length() == 0) { + mInputBuffer->release(); + mInputBuffer = NULL; + } } buffer->meta_data()->setInt64( |