summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorDave Burke <daveburke@google.com>2012-05-18 14:21:47 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-18 14:21:47 -0700
commite40d461e4826a8515aaa74779a1705ff1b1997ef (patch)
tree0e6af37d199bf9c145122e0853be3bd29cb6f545 /media/libstagefright
parent4e11a1ffa708965cf91ea210daa5675a82149213 (diff)
parentbf2461ecc71c0aacf8c03fcdaf0dc46bc8285c7f (diff)
downloadframeworks_av-e40d461e4826a8515aaa74779a1705ff1b1997ef.zip
frameworks_av-e40d461e4826a8515aaa74779a1705ff1b1997ef.tar.gz
frameworks_av-e40d461e4826a8515aaa74779a1705ff1b1997ef.tar.bz2
am bf2461ec: Don\'t reconfigure stream after outputing data.
* commit 'bf2461ecc71c0aacf8c03fcdaf0dc46bc8285c7f': Don't reconfigure stream after outputing data.
Diffstat (limited to 'media/libstagefright')
-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;
}