summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/aacdec
diff options
context:
space:
mode:
authorDave Burke <daveburke@google.com>2012-05-18 10:46:11 -0700
committerDave Burke <daveburke@google.com>2012-05-18 10:46:11 -0700
commitbf2461ecc71c0aacf8c03fcdaf0dc46bc8285c7f (patch)
tree43e7c72981aff2896d845bd366a74622312d3e00 /media/libstagefright/codecs/aacdec
parent874a897f09dc7b06679bb273506d7e0fa0152220 (diff)
downloadframeworks_av-bf2461ecc71c0aacf8c03fcdaf0dc46bc8285c7f.zip
frameworks_av-bf2461ecc71c0aacf8c03fcdaf0dc46bc8285c7f.tar.gz
frameworks_av-bf2461ecc71c0aacf8c03fcdaf0dc46bc8285c7f.tar.bz2
Don't reconfigure stream after outputing data.
Handle invalid configuration. Bug: 6519161 Change-Id: Ib2d38bee769e63e627c93d7f3839c3a55de694e9
Diffstat (limited to 'media/libstagefright/codecs/aacdec')
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.cpp57
1 files changed, 40 insertions, 17 deletions
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index 96277e2..b5a8da8 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -136,7 +136,7 @@ OMX_ERRORTYPE SoftAAC2::internalGetParameter(
aacParams->eChannelMode = OMX_AUDIO_ChannelModeStereo;
- if (!isConfigured() || !mStreamInfo->numChannels || !mStreamInfo->sampleRate) {
+ if (!isConfigured()) {
aacParams->nChannels = 1;
aacParams->nSampleRate = 44100;
aacParams->nFrameLength = 0;
@@ -170,7 +170,7 @@ OMX_ERRORTYPE SoftAAC2::internalGetParameter(
pcmParams->eChannelMapping[4] = OMX_AUDIO_ChannelLS;
pcmParams->eChannelMapping[5] = OMX_AUDIO_ChannelRS;
- if (!isConfigured() || !mStreamInfo->numChannels || !mStreamInfo->sampleRate) {
+ if (!isConfigured()) {
pcmParams->nChannels = 1;
pcmParams->nSamplingRate = 44100;
} else {
@@ -280,6 +280,9 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
info->mOwnedByUs = false;
notifyEmptyBufferDone(header);
+ ALOGI("Configuring decoder: %d Hz, %d channels",
+ mStreamInfo->sampleRate,
+ mStreamInfo->numChannels);
notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
mOutputPortSettingsChange = AWAITING_DISABLED;
return;
@@ -377,21 +380,41 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
}
- // Check if stream info has changed
- if (mStreamInfo->sampleRate != prevSampleRate ||
- mStreamInfo->numChannels != prevNumChannels) {
- ALOGI("Reconfiguring decoder: %d Hz, %d channels",
- mStreamInfo->sampleRate,
- mStreamInfo->numChannels);
-
- // We're going to want to revisit this input buffer, but
- // may have already advanced the offset. Undo that if
- // necessary.
- inHeader->nOffset -= adtsHeaderSize;
- inHeader->nFilledLen += adtsHeaderSize;
-
- notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
- mOutputPortSettingsChange = AWAITING_DISABLED;
+ /*
+ * AAC+/eAAC+ streams can be signalled in two ways: either explicitly
+ * or implicitly, according to MPEG4 spec. AAC+/eAAC+ is a dual
+ * rate system and the sampling rate in the final output is actually
+ * doubled compared with the core AAC decoder sampling rate.
+ *
+ * Explicit signalling is done by explicitly defining SBR audio object
+ * type in the bitstream. Implicit signalling is done by embedding
+ * SBR content in AAC extension payload specific to SBR, and hence
+ * requires an AAC decoder to perform pre-checks on actual audio frames.
+ *
+ * Thus, we could not say for sure whether a stream is
+ * AAC+/eAAC+ until the first data frame is decoded.
+ */
+ if (mInputBufferCount <= 2) {
+ if (mStreamInfo->sampleRate != prevSampleRate ||
+ mStreamInfo->numChannels != prevNumChannels) {
+ ALOGI("Reconfiguring decoder: %d Hz, %d channels",
+ mStreamInfo->sampleRate,
+ mStreamInfo->numChannels);
+
+ // We're going to want to revisit this input buffer, but
+ // may have already advanced the offset. Undo that if
+ // necessary.
+ inHeader->nOffset -= adtsHeaderSize;
+ inHeader->nFilledLen += adtsHeaderSize;
+
+ notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
+ mOutputPortSettingsChange = AWAITING_DISABLED;
+ return;
+ }
+ } else if (!mStreamInfo->sampleRate || !mStreamInfo->numChannels) {
+ ALOGW("Invalid AAC stream");
+ mSignalledError = true;
+ notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL);
return;
}