Snap for 4832339 from 63a0662d03791460a6ba882851e95b3e9eaf8b3b to pi-release
Change-Id: I42d4beebb2f6a3cb8495f026ac108af2cfb8a877
diff --git a/media/libmedia/include/media/MediaProfiles.h b/media/libmedia/include/media/MediaProfiles.h
index 6975581..0feb4f3 100644
--- a/media/libmedia/include/media/MediaProfiles.h
+++ b/media/libmedia/include/media/MediaProfiles.h
@@ -83,6 +83,7 @@
* successful only when validation is successful.
*/
static constexpr char const * const xmlFiles[] = {
+ "odm/etc/media_profiles_V1_0.xml",
"vendor/etc/media_profiles_V1_0.xml",
"system/etc/media_profiles.xml"
};
diff --git a/media/libstagefright/codecs/xaacdec/SoftXAAC.cpp b/media/libstagefright/codecs/xaacdec/SoftXAAC.cpp
index e0d9662..f173e0f 100644
--- a/media/libstagefright/codecs/xaacdec/SoftXAAC.cpp
+++ b/media/libstagefright/codecs/xaacdec/SoftXAAC.cpp
@@ -23,43 +23,53 @@
#include <OMX_AudioExt.h>
#include <OMX_IndexExt.h>
#include <cutils/properties.h>
+#include <math.h>
+#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/hexdump.h>
-#include <media/stagefright/MediaErrors.h>
#include <utils/misc.h>
-#include <math.h>
-#define DRC_DEFAULT_MOBILE_REF_LEVEL 64 /* 64*-0.25dB = -16 dB below full scale for mobile conf */
-#define DRC_DEFAULT_MOBILE_DRC_CUT 127 /* maximum compression of dynamic range for mobile conf */
-#define DRC_DEFAULT_MOBILE_DRC_BOOST 127 /* maximum compression of dynamic range for mobile conf */
-#define DRC_DEFAULT_MOBILE_DRC_HEAVY 1 /* switch for heavy compression for mobile conf */
-#define DRC_DEFAULT_MOBILE_ENC_LEVEL (-1) /* encoder target level; -1 => the value is unknown, otherwise dB step value (e.g. 64 for -16 dB) */
-#define DRC_KEY_AAC_DRC_EFFECT_TYPE (3) /* Default Effect type is "Limited playback" */
+/* 64*-0.25dB = -16 dB below full scale for mobile conf */
+#define DRC_DEFAULT_MOBILE_REF_LEVEL 64
+/* maximum compression of dynamic range for mobile conf */
+#define DRC_DEFAULT_MOBILE_DRC_CUT 127
+/* maximum compression of dynamic range for mobile conf */
+#define DRC_DEFAULT_MOBILE_DRC_BOOST 127
+/* switch for heavy compression for mobile conf */
+#define DRC_DEFAULT_MOBILE_DRC_HEAVY 1
+/* encoder target level; -1 => the value is unknown,
+ * otherwise dB step value (e.g. 64 for -16 dB) */
+#define DRC_DEFAULT_MOBILE_ENC_LEVEL (-1)
+
+/* Default Effect type is "Limited playback" */
+#define DRC_KEY_AAC_DRC_EFFECT_TYPE (3)
+
/* REF_LEVEL of 64 pairs well with EFFECT_TYPE of 3. */
-#define DRC_DEFAULT_MOBILE_LOUDNESS_LEVEL (64) /* Default loudness value for MPEG-D DRC */
+/* Default loudness value for MPEG-D DRC */
+#define DRC_DEFAULT_MOBILE_LOUDNESS_LEVEL (64)
-#define PROP_DRC_OVERRIDE_REF_LEVEL "aac_drc_reference_level"
-#define PROP_DRC_OVERRIDE_CUT "aac_drc_cut"
-#define PROP_DRC_OVERRIDE_BOOST "aac_drc_boost"
-#define PROP_DRC_OVERRIDE_HEAVY "aac_drc_heavy"
+#define PROP_DRC_OVERRIDE_REF_LEVEL "aac_drc_reference_level"
+#define PROP_DRC_OVERRIDE_CUT "aac_drc_cut"
+#define PROP_DRC_OVERRIDE_BOOST "aac_drc_boost"
+#define PROP_DRC_OVERRIDE_HEAVY "aac_drc_heavy"
#define PROP_DRC_OVERRIDE_ENC_LEVEL "aac_drc_enc_target_level"
#define PROP_DRC_OVERRIDE_EFFECT_TYPE "ro.aac_drc_effect_type"
-#define MAX_CHANNEL_COUNT 8 /* maximum number of audio channels that can be decoded */
+/* maximum number of audio channels that can be decoded */
+#define MAX_CHANNEL_COUNT 8
-
-#define RETURN_IF_FATAL(retval, str) \
- if (retval & IA_FATAL_ERROR) { \
- ALOGE("Error in %s: Returned: %d", str, retval); \
- return retval; \
- } else if (retval != IA_NO_ERROR) { \
- ALOGW("Warning in %s: Returned: %d", str, retval); \
- }
+#define RETURN_IF_FATAL(retval, str) \
+ if (retval & IA_FATAL_ERROR) { \
+ ALOGE("Error in %s: Returned: %d", str, retval); \
+ return retval; \
+ } else if (retval != IA_NO_ERROR) { \
+ ALOGW("Warning in %s: Returned: %d", str, retval); \
+ }
namespace android {
-template<class T>
-static void InitOMXParams(T *params) {
+template <class T>
+static void InitOMXParams(T* params) {
params->nSize = sizeof(T);
params->nVersion.s.nVersionMajor = 1;
params->nVersion.s.nVersionMinor = 0;
@@ -68,41 +78,35 @@
}
static const OMX_U32 kSupportedProfiles[] = {
- OMX_AUDIO_AACObjectLC,
- OMX_AUDIO_AACObjectHE,
- OMX_AUDIO_AACObjectHE_PS,
- OMX_AUDIO_AACObjectLD,
- OMX_AUDIO_AACObjectELD,
+ OMX_AUDIO_AACObjectLC, OMX_AUDIO_AACObjectHE, OMX_AUDIO_AACObjectHE_PS,
+ OMX_AUDIO_AACObjectLD, OMX_AUDIO_AACObjectELD,
};
-SoftXAAC::SoftXAAC(
- const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component)
+SoftXAAC::SoftXAAC(const char* name, const OMX_CALLBACKTYPE* callbacks, OMX_PTR appData,
+ OMX_COMPONENTTYPE** component)
: SimpleSoftOMXComponent(name, callbacks, appData, component),
- mIsADTS(false),
- mInputBufferCount(0),
- mOutputBufferCount(0),
- mSignalledError(false),
- mLastInHeader(NULL),
- mPrevTimestamp(0),
- mCurrentTimestamp(0),
- mOutputPortSettingsChange(NONE),
- mXheaacCodecHandle(NULL),
- mMpegDDrcHandle(NULL),
- mInputBufferSize(0),
- mOutputFrameLength(1024),
- mInputBuffer(NULL),
- mOutputBuffer(NULL),
- mSampFreq(0),
- mNumChannels(0),
- mPcmWdSz(0),
- mChannelMask(0),
- mIsCodecInitialized(false),
- mIsCodecConfigFlushRequired(false),
- mMpegDDRCPresent(0),
- mDRCFlag(0)
+ mIsADTS(false),
+ mInputBufferCount(0),
+ mOutputBufferCount(0),
+ mSignalledError(false),
+ mLastInHeader(NULL),
+ mPrevTimestamp(0),
+ mCurrentTimestamp(0),
+ mOutputPortSettingsChange(NONE),
+ mXheaacCodecHandle(NULL),
+ mMpegDDrcHandle(NULL),
+ mInputBufferSize(0),
+ mOutputFrameLength(1024),
+ mInputBuffer(NULL),
+ mOutputBuffer(NULL),
+ mSampFreq(0),
+ mNumChannels(0),
+ mPcmWdSz(0),
+ mChannelMask(0),
+ mIsCodecInitialized(false),
+ mIsCodecConfigFlushRequired(false),
+ mMpegDDRCPresent(0),
+ mDRCFlag(0)
{
initPorts();
@@ -112,7 +116,7 @@
SoftXAAC::~SoftXAAC() {
int errCode = deInitXAACDecoder();
if (0 != errCode) {
- ALOGE("deInitXAACDecoder() failed %d",errCode);
+ ALOGE("deInitXAACDecoder() failed %d", errCode);
}
mIsCodecInitialized = false;
@@ -134,7 +138,7 @@
def.bBuffersContiguous = OMX_FALSE;
def.nBufferAlignment = 1;
- def.format.audio.cMIMEType = const_cast<char *>("audio/aac");
+ def.format.audio.cMIMEType = const_cast<char*>("audio/aac");
def.format.audio.pNativeRender = NULL;
def.format.audio.bFlagErrorConcealment = OMX_FALSE;
def.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
@@ -152,7 +156,7 @@
def.bBuffersContiguous = OMX_FALSE;
def.nBufferAlignment = 2;
- def.format.audio.cMIMEType = const_cast<char *>("audio/raw");
+ def.format.audio.cMIMEType = const_cast<char*>("audio/raw");
def.format.audio.pNativeRender = NULL;
def.format.audio.bFlagErrorConcealment = OMX_FALSE;
def.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
@@ -168,24 +172,23 @@
int loop = 0;
err_code = initXAACDecoder();
- if(err_code != IA_NO_ERROR) {
+ if (err_code != IA_NO_ERROR) {
if (NULL == mXheaacCodecHandle) {
ALOGE("AAC decoder handle is null");
}
if (NULL == mMpegDDrcHandle) {
ALOGE("MPEG-D DRC decoder handle is null");
}
- for(loop= 1; loop < mMallocCount; loop++) {
+ for (loop = 1; loop < mMallocCount; loop++) {
if (mMemoryArray[loop] == NULL) {
- ALOGE(" memory allocation error %d\n",loop);
+ ALOGE(" memory allocation error %d\n", loop);
break;
}
}
ALOGE("initXAACDecoder Failed");
- for(loop = 0; loop < mMallocCount; loop++) {
- if(mMemoryArray[loop])
- free(mMemoryArray[loop]);
+ for (loop = 0; loop < mMallocCount; loop++) {
+ if (mMemoryArray[loop]) free(mMemoryArray[loop]);
}
mMallocCount = 0;
return status;
@@ -197,105 +200,76 @@
mEndOfOutput = false;
char value[PROPERTY_VALUE_MAX];
- if (property_get(PROP_DRC_OVERRIDE_REF_LEVEL, value, NULL))
- {
+ if (property_get(PROP_DRC_OVERRIDE_REF_LEVEL, value, NULL)) {
ui_drc_val = atoi(value);
- ALOGV("AAC decoder using desired DRC target reference level of %d instead of %d",ui_drc_val,
- DRC_DEFAULT_MOBILE_REF_LEVEL);
- }
- else
- {
- ui_drc_val= DRC_DEFAULT_MOBILE_REF_LEVEL;
+ ALOGV("AAC decoder using desired DRC target reference level of %d instead of %d",
+ ui_drc_val, DRC_DEFAULT_MOBILE_REF_LEVEL);
+ } else {
+ ui_drc_val = DRC_DEFAULT_MOBILE_REF_LEVEL;
}
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL,
- &ui_drc_val);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL, &ui_drc_val);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL");
-#ifdef ENABLE_MPEG_D_DRC
-
+#ifdef ENABLE_MPEG_D_DRC
/* Use ui_drc_val from PROP_DRC_OVERRIDE_REF_LEVEL or DRC_DEFAULT_MOBILE_REF_LEVEL
* for IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS too */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS,
- &ui_drc_val);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS, &ui_drc_val);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS");
#endif
-
- if (property_get(PROP_DRC_OVERRIDE_CUT, value, NULL))
- {
+ if (property_get(PROP_DRC_OVERRIDE_CUT, value, NULL)) {
ui_drc_val = atoi(value);
ALOGV("AAC decoder using desired DRC attenuation factor of %d instead of %d", ui_drc_val,
- DRC_DEFAULT_MOBILE_DRC_CUT);
- }
- else
- {
- ui_drc_val=DRC_DEFAULT_MOBILE_DRC_CUT;
+ DRC_DEFAULT_MOBILE_DRC_CUT);
+ } else {
+ ui_drc_val = DRC_DEFAULT_MOBILE_DRC_CUT;
}
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT,
- &ui_drc_val);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT, &ui_drc_val);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT");
- if (property_get(PROP_DRC_OVERRIDE_BOOST, value, NULL))
- {
+ if (property_get(PROP_DRC_OVERRIDE_BOOST, value, NULL)) {
ui_drc_val = atoi(value);
ALOGV("AAC decoder using desired DRC boost factor of %d instead of %d", ui_drc_val,
- DRC_DEFAULT_MOBILE_DRC_BOOST);
- }
- else
- {
+ DRC_DEFAULT_MOBILE_DRC_BOOST);
+ } else {
ui_drc_val = DRC_DEFAULT_MOBILE_DRC_BOOST;
}
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST,
- &ui_drc_val);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST, &ui_drc_val);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST");
- if (property_get(PROP_DRC_OVERRIDE_HEAVY, value, NULL))
- {
+ if (property_get(PROP_DRC_OVERRIDE_HEAVY, value, NULL)) {
ui_drc_val = atoi(value);
ALOGV("AAC decoder using desired Heavy compression factor of %d instead of %d", ui_drc_val,
- DRC_DEFAULT_MOBILE_DRC_HEAVY);
- }
- else
- {
+ DRC_DEFAULT_MOBILE_DRC_HEAVY);
+ } else {
ui_drc_val = DRC_DEFAULT_MOBILE_DRC_HEAVY;
}
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP,
- &ui_drc_val);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP");
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP, &ui_drc_val);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP");
#ifdef ENABLE_MPEG_D_DRC
- if (property_get(PROP_DRC_OVERRIDE_EFFECT_TYPE, value, NULL))
- {
+ if (property_get(PROP_DRC_OVERRIDE_EFFECT_TYPE, value, NULL)) {
ui_drc_val = atoi(value);
ALOGV("AAC decoder using desired DRC effect type of %d instead of %d", ui_drc_val,
- DRC_KEY_AAC_DRC_EFFECT_TYPE);
- }
- else
- {
+ DRC_KEY_AAC_DRC_EFFECT_TYPE);
+ } else {
ui_drc_val = DRC_KEY_AAC_DRC_EFFECT_TYPE;
}
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE,
- &ui_drc_val);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE, &ui_drc_val);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE");
@@ -303,15 +277,10 @@
return status;
}
-OMX_ERRORTYPE SoftXAAC::internalGetParameter(
- OMX_INDEXTYPE index, OMX_PTR params) {
-
- switch ((OMX_U32) index) {
-
- case OMX_IndexParamAudioPortFormat:
- {
- OMX_AUDIO_PARAM_PORTFORMATTYPE *formatParams =
- (OMX_AUDIO_PARAM_PORTFORMATTYPE *)params;
+OMX_ERRORTYPE SoftXAAC::internalGetParameter(OMX_INDEXTYPE index, OMX_PTR params) {
+ switch ((OMX_U32)index) {
+ case OMX_IndexParamAudioPortFormat: {
+ OMX_AUDIO_PARAM_PORTFORMATTYPE* formatParams = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)params;
if (!isValidOMXParam(formatParams)) {
return OMX_ErrorBadParameter;
@@ -326,16 +295,13 @@
}
formatParams->eEncoding =
- (formatParams->nPortIndex == 0)
- ? OMX_AUDIO_CodingAAC : OMX_AUDIO_CodingPCM;
+ (formatParams->nPortIndex == 0) ? OMX_AUDIO_CodingAAC : OMX_AUDIO_CodingPCM;
return OMX_ErrorNone;
}
- case OMX_IndexParamAudioAac:
- {
- OMX_AUDIO_PARAM_AACPROFILETYPE *aacParams =
- (OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
+ case OMX_IndexParamAudioAac: {
+ OMX_AUDIO_PARAM_AACPROFILETYPE* aacParams = (OMX_AUDIO_PARAM_AACPROFILETYPE*)params;
if (!isValidOMXParam(aacParams)) {
return OMX_ErrorBadParameter;
@@ -352,9 +318,7 @@
aacParams->eAACProfile = OMX_AUDIO_AACObjectMain;
aacParams->eAACStreamFormat =
- mIsADTS
- ? OMX_AUDIO_AACStreamFormatMP4ADTS
- : OMX_AUDIO_AACStreamFormatMP4FF;
+ mIsADTS ? OMX_AUDIO_AACStreamFormatMP4ADTS : OMX_AUDIO_AACStreamFormatMP4FF;
aacParams->eChannelMode = OMX_AUDIO_ChannelModeStereo;
@@ -371,10 +335,8 @@
return OMX_ErrorNone;
}
- case OMX_IndexParamAudioPcm:
- {
- OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
- (OMX_AUDIO_PARAM_PCMMODETYPE *)params;
+ case OMX_IndexParamAudioPcm: {
+ OMX_AUDIO_PARAM_PCMMODETYPE* pcmParams = (OMX_AUDIO_PARAM_PCMMODETYPE*)params;
if (!isValidOMXParam(pcmParams)) {
return OMX_ErrorBadParameter;
@@ -407,10 +369,9 @@
return OMX_ErrorNone;
}
- case OMX_IndexParamAudioProfileQuerySupported:
- {
- OMX_AUDIO_PARAM_ANDROID_PROFILETYPE *profileParams =
- (OMX_AUDIO_PARAM_ANDROID_PROFILETYPE *)params;
+ case OMX_IndexParamAudioProfileQuerySupported: {
+ OMX_AUDIO_PARAM_ANDROID_PROFILETYPE* profileParams =
+ (OMX_AUDIO_PARAM_ANDROID_PROFILETYPE*)params;
if (!isValidOMXParam(profileParams)) {
return OMX_ErrorBadParameter;
@@ -424,8 +385,7 @@
return OMX_ErrorNoMore;
}
- profileParams->eProfile =
- kSupportedProfiles[profileParams->nProfileIndex];
+ profileParams->eProfile = kSupportedProfiles[profileParams->nProfileIndex];
return OMX_ErrorNone;
}
@@ -435,21 +395,17 @@
}
}
-OMX_ERRORTYPE SoftXAAC::internalSetParameter(
- OMX_INDEXTYPE index, const OMX_PTR params) {
-
+OMX_ERRORTYPE SoftXAAC::internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR params) {
switch ((int)index) {
- case OMX_IndexParamStandardComponentRole:
- {
- const OMX_PARAM_COMPONENTROLETYPE *roleParams =
- (const OMX_PARAM_COMPONENTROLETYPE *)params;
+ case OMX_IndexParamStandardComponentRole: {
+ const OMX_PARAM_COMPONENTROLETYPE* roleParams =
+ (const OMX_PARAM_COMPONENTROLETYPE*)params;
if (!isValidOMXParam(roleParams)) {
return OMX_ErrorBadParameter;
}
- if (strncmp((const char *)roleParams->cRole,
- "audio_decoder.aac",
+ if (strncmp((const char*)roleParams->cRole, "audio_decoder.aac",
OMX_MAX_STRINGNAME_SIZE - 1)) {
return OMX_ErrorUndefined;
}
@@ -457,10 +413,9 @@
return OMX_ErrorNone;
}
- case OMX_IndexParamAudioPortFormat:
- {
- const OMX_AUDIO_PARAM_PORTFORMATTYPE *formatParams =
- (const OMX_AUDIO_PARAM_PORTFORMATTYPE *)params;
+ case OMX_IndexParamAudioPortFormat: {
+ const OMX_AUDIO_PARAM_PORTFORMATTYPE* formatParams =
+ (const OMX_AUDIO_PARAM_PORTFORMATTYPE*)params;
if (!isValidOMXParam(formatParams)) {
return OMX_ErrorBadParameter;
@@ -470,20 +425,17 @@
return OMX_ErrorUndefined;
}
- if ((formatParams->nPortIndex == 0
- && formatParams->eEncoding != OMX_AUDIO_CodingAAC)
- || (formatParams->nPortIndex == 1
- && formatParams->eEncoding != OMX_AUDIO_CodingPCM)) {
+ if ((formatParams->nPortIndex == 0 && formatParams->eEncoding != OMX_AUDIO_CodingAAC) ||
+ (formatParams->nPortIndex == 1 && formatParams->eEncoding != OMX_AUDIO_CodingPCM)) {
return OMX_ErrorUndefined;
}
return OMX_ErrorNone;
}
- case OMX_IndexParamAudioAac:
- {
- const OMX_AUDIO_PARAM_AACPROFILETYPE *aacParams =
- (const OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
+ case OMX_IndexParamAudioAac: {
+ const OMX_AUDIO_PARAM_AACPROFILETYPE* aacParams =
+ (const OMX_AUDIO_PARAM_AACPROFILETYPE*)params;
if (!isValidOMXParam(aacParams)) {
return OMX_ErrorBadParameter;
@@ -495,8 +447,7 @@
if (aacParams->eAACStreamFormat == OMX_AUDIO_AACStreamFormatMP4FF) {
mIsADTS = false;
- } else if (aacParams->eAACStreamFormat
- == OMX_AUDIO_AACStreamFormatMP4ADTS) {
+ } else if (aacParams->eAACStreamFormat == OMX_AUDIO_AACStreamFormatMP4ADTS) {
mIsADTS = true;
} else {
return OMX_ErrorUndefined;
@@ -505,10 +456,9 @@
return OMX_ErrorNone;
}
- case OMX_IndexParamAudioAndroidAacDrcPresentation:
- {
- const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE *aacPresParams =
- (const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE *)params;
+ case OMX_IndexParamAudioAndroidAacDrcPresentation: {
+ const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE* aacPresParams =
+ (const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE*)params;
if (!isValidOMXParam(aacPresParams)) {
ALOGE("set OMX_ErrorBadParameter");
@@ -525,23 +475,26 @@
// nEncodedTargetLevel idem
if (aacPresParams->nMaxOutputChannels >= 0) {
int max;
- if (aacPresParams->nMaxOutputChannels >= 8) { max = 8; }
- else if (aacPresParams->nMaxOutputChannels >= 6) { max = 6; }
- else if (aacPresParams->nMaxOutputChannels >= 2) { max = 2; }
- else {
+ if (aacPresParams->nMaxOutputChannels >= 8) {
+ max = 8;
+ } else if (aacPresParams->nMaxOutputChannels >= 6) {
+ max = 6;
+ } else if (aacPresParams->nMaxOutputChannels >= 2) {
+ max = 2;
+ } else {
// -1 or 0: disable downmix, 1: mono
max = aacPresParams->nMaxOutputChannels;
}
}
/* Apply DRC Changes */
- IA_ERRORCODE err_code = setXAACDRCInfo(aacPresParams->nDrcCut,
- aacPresParams->nDrcBoost,
- aacPresParams->nTargetReferenceLevel,
- aacPresParams->nHeavyCompression
+ IA_ERRORCODE err_code = setXAACDRCInfo(aacPresParams->nDrcCut, aacPresParams->nDrcBoost,
+ aacPresParams->nTargetReferenceLevel,
+ aacPresParams->nHeavyCompression
#ifdef ENABLE_MPEG_D_DRC
- ,aacPresParams->nDrcEffectType
+ ,
+ aacPresParams->nDrcEffectType
#endif
- ); // TOD0 : Revert this change
+ ); // TOD0 : Revert this change
if (err_code != IA_NO_ERROR) {
ALOGE("Error in OMX_IndexParamAudioAndroidAacDrcPresentation");
return OMX_ErrorBadParameter;
@@ -550,10 +503,8 @@
return OMX_ErrorNone;
}
- case OMX_IndexParamAudioPcm:
- {
- const OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
- (OMX_AUDIO_PARAM_PCMMODETYPE *)params;
+ case OMX_IndexParamAudioPcm: {
+ const OMX_AUDIO_PARAM_PCMMODETYPE* pcmParams = (OMX_AUDIO_PARAM_PCMMODETYPE*)params;
if (!isValidOMXParam(pcmParams)) {
return OMX_ErrorBadParameter;
@@ -577,15 +528,15 @@
void SoftXAAC::onQueueFilled(OMX_U32 /* portIndex */) {
if (mSignalledError || mOutputPortSettingsChange != NONE) {
- ALOGE("onQueueFilled do not process %d %d",mSignalledError,mOutputPortSettingsChange);
+ ALOGE("onQueueFilled do not process %d %d", mSignalledError, mOutputPortSettingsChange);
return;
}
- uint8_t* inBuffer = NULL;
- uint32_t inBufferLength = 0;
+ uint8_t* inBuffer = NULL;
+ uint32_t inBufferLength = 0;
- List<BufferInfo *> &inQueue = getPortQueue(0);
- List<BufferInfo *> &outQueue = getPortQueue(1);
+ List<BufferInfo*>& inQueue = getPortQueue(0);
+ List<BufferInfo*>& outQueue = getPortQueue(1);
signed int numOutBytes = 0;
@@ -595,16 +546,16 @@
/* Note: entire buffer logic to save and retrieve assumes 2 bytes per*/
/* sample currently */
if (mIsCodecInitialized) {
- numOutBytes = mOutputFrameLength * (mPcmWdSz/8) * mNumChannels;
- if ((mPcmWdSz/8) != 2) {
- ALOGE("XAAC assumes 2 bytes per sample! mPcmWdSz %d",mPcmWdSz);
+ numOutBytes = mOutputFrameLength * (mPcmWdSz / 8) * mNumChannels;
+ if ((mPcmWdSz / 8) != 2) {
+ ALOGE("XAAC assumes 2 bytes per sample! mPcmWdSz %d", mPcmWdSz);
}
}
while ((!inQueue.empty() || mEndOfInput) && !outQueue.empty()) {
if (!inQueue.empty()) {
- BufferInfo *inInfo = *inQueue.begin();
- OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
+ BufferInfo* inInfo = *inQueue.begin();
+ OMX_BUFFERHEADERTYPE* inHeader = inInfo->mHeader;
/* No need to check inHeader != NULL, as inQueue is not empty */
mEndOfInput = (inHeader->nFlags & OMX_BUFFERFLAG_EOS) != 0;
@@ -618,7 +569,7 @@
inBufferLength = inHeader->nFilledLen;
/* GA header configuration sent to Decoder! */
- int err_code = configXAACDecoder(inBuffer,inBufferLength);
+ int err_code = configXAACDecoder(inBuffer, inBufferLength);
if (0 != err_code) {
ALOGW("configXAACDecoder err_code = %d", err_code);
mSignalledError = true;
@@ -626,7 +577,8 @@
return;
}
mInputBufferCount++;
- mOutputBufferCount++; // fake increase of outputBufferCount to keep the counters aligned
+ mOutputBufferCount++; // fake increase of outputBufferCount to keep the counters
+ // aligned
inInfo->mOwnedByUs = false;
inQueue.erase(inQueue.begin());
@@ -657,34 +609,35 @@
}
// Restore Offset and Length for Port reconfig case
- size_t tempOffset = inHeader->nOffset;
+ size_t tempOffset = inHeader->nOffset;
size_t tempFilledLen = inHeader->nFilledLen;
if (mIsADTS) {
- size_t adtsHeaderSize = 0;
+ size_t adtsHeaderSize = 0;
// skip 30 bits, aac_frame_length follows.
// ssssssss ssssiiip ppffffPc ccohCCll llllllll lll?????
- const uint8_t *adtsHeader = inHeader->pBuffer + inHeader->nOffset;
+ const uint8_t* adtsHeader = inHeader->pBuffer + inHeader->nOffset;
bool signalError = false;
if (inHeader->nFilledLen < 7) {
- ALOGE("Audio data too short to contain even the ADTS header. "
- "Got %d bytes.", inHeader->nFilledLen);
+ ALOGE(
+ "Audio data too short to contain even the ADTS header. "
+ "Got %d bytes.",
+ inHeader->nFilledLen);
hexdump(adtsHeader, inHeader->nFilledLen);
signalError = true;
} else {
bool protectionAbsent = (adtsHeader[1] & 1);
unsigned aac_frame_length =
- ((adtsHeader[3] & 3) << 11)
- | (adtsHeader[4] << 3)
- | (adtsHeader[5] >> 5);
+ ((adtsHeader[3] & 3) << 11) | (adtsHeader[4] << 3) | (adtsHeader[5] >> 5);
if (inHeader->nFilledLen < aac_frame_length) {
- ALOGE("Not enough audio data for the complete frame. "
- "Got %d bytes, frame size according to the ADTS "
- "header is %u bytes.",
- inHeader->nFilledLen, aac_frame_length);
+ ALOGE(
+ "Not enough audio data for the complete frame. "
+ "Got %d bytes, frame size according to the ADTS "
+ "header is %u bytes.",
+ inHeader->nFilledLen, aac_frame_length);
hexdump(adtsHeader, inHeader->nFilledLen);
signalError = true;
} else {
@@ -692,7 +645,7 @@
if (aac_frame_length < adtsHeaderSize) {
signalError = true;
} else {
- inBuffer = (uint8_t *)adtsHeader + adtsHeaderSize;
+ inBuffer = (uint8_t*)adtsHeader + adtsHeaderSize;
inBufferLength = aac_frame_length - adtsHeaderSize;
inHeader->nOffset += adtsHeaderSize;
@@ -712,8 +665,7 @@
mCurrentTimestamp = inHeader->nTimeStamp;
mLastInHeader = inHeader;
} else {
- mCurrentTimestamp = mPrevTimestamp +
- mOutputFrameLength * 1000000ll / mSampFreq;
+ mCurrentTimestamp = mPrevTimestamp + mOutputFrameLength * 1000000ll / mSampFreq;
}
} else {
inBuffer = inHeader->pBuffer + inHeader->nOffset;
@@ -730,7 +682,7 @@
/* which should initialize the codec. Once this state is reached, call the */
/* decodeXAACStream API with same frame to decode! */
if (!mIsCodecInitialized) {
- int err_code = configXAACDecoder(inBuffer,inBufferLength);
+ int err_code = configXAACDecoder(inBuffer, inBufferLength);
if (0 != err_code) {
ALOGW("configXAACDecoder Failed 2 err_code = %d", err_code);
mSignalledError = true;
@@ -743,15 +695,14 @@
if (!mSampFreq || !mNumChannels) {
if ((mInputBufferCount > 2) && (mOutputBufferCount <= 1)) {
ALOGW("Invalid AAC stream");
- ALOGW("mSampFreq %d mNumChannels %d ",mSampFreq,mNumChannels);
+ ALOGW("mSampFreq %d mNumChannels %d ", mSampFreq, mNumChannels);
mSignalledError = true;
notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
return;
}
- } else if ((mSampFreq != prevSampleRate) ||
- (mNumChannels != prevNumChannels)) {
- ALOGV("Reconfiguring decoder: %d->%d Hz, %d->%d channels",
- prevSampleRate, mSampFreq, prevNumChannels, mNumChannels);
+ } else if ((mSampFreq != prevSampleRate) || (mNumChannels != prevNumChannels)) {
+ ALOGV("Reconfiguring decoder: %d->%d Hz, %d->%d channels", prevSampleRate,
+ mSampFreq, prevNumChannels, mNumChannels);
inHeader->nOffset = tempOffset;
inHeader->nFilledLen = tempFilledLen;
notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
@@ -762,7 +713,8 @@
signed int bytesConsumed = 0;
int errorCode = 0;
if (mIsCodecInitialized) {
- errorCode = decodeXAACStream(inBuffer,inBufferLength, &bytesConsumed, &numOutBytes);
+ errorCode =
+ decodeXAACStream(inBuffer, inBufferLength, &bytesConsumed, &numOutBytes);
} else {
ALOGW("Assumption that first frame after header initializes decoder failed!");
}
@@ -775,7 +727,7 @@
/* In case of error, decoder would have given out empty buffer */
if ((0 != errorCode) && (0 == numOutBytes) && mIsCodecInitialized) {
- numOutBytes = mOutputFrameLength * (mPcmWdSz/8) * mNumChannels;
+ numOutBytes = mOutputFrameLength * (mPcmWdSz / 8) * mNumChannels;
}
numLoops++;
@@ -786,7 +738,7 @@
if (errorCode) {
/* Clear buffer for output buffer is done inside XAAC codec */
/* TODO - Check if below memset is on top of reset inside codec */
- memset(mOutputBuffer, 0, numOutBytes); // TODO: check for overflow, ASAN
+ memset(mOutputBuffer, 0, numOutBytes); // TODO: check for overflow, ASAN
// Discard input buffer.
inHeader->nFilledLen = 0;
// fall through
@@ -805,8 +757,8 @@
}
if (!outQueue.empty() && numOutBytes) {
- BufferInfo *outInfo = *outQueue.begin();
- OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
+ BufferInfo* outInfo = *outQueue.begin();
+ OMX_BUFFERHEADERTYPE* outHeader = outInfo->mHeader;
if (outHeader->nOffset != 0) {
ALOGE("outHeader->nOffset != 0 is not handled");
@@ -815,12 +767,10 @@
return;
}
- signed short *outBuffer =
- reinterpret_cast<signed short *>(outHeader->pBuffer + outHeader->nOffset);
+ signed short* outBuffer =
+ reinterpret_cast<signed short*>(outHeader->pBuffer + outHeader->nOffset);
int samplesize = mNumChannels * sizeof(int16_t);
- if (outHeader->nOffset
- + mOutputFrameLength * samplesize
- > outHeader->nAllocLen) {
+ if (outHeader->nOffset + mOutputFrameLength * samplesize > outHeader->nAllocLen) {
ALOGE("buffer overflow");
mSignalledError = true;
notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
@@ -853,12 +803,12 @@
ALOGV(" empty block signaling EOS");
// send partial or empty block signaling EOS
mEndOfOutput = true;
- BufferInfo *outInfo = *outQueue.begin();
- OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
+ BufferInfo* outInfo = *outQueue.begin();
+ OMX_BUFFERHEADERTYPE* outHeader = outInfo->mHeader;
outHeader->nFilledLen = 0;
outHeader->nFlags = OMX_BUFFERFLAG_EOS;
- outHeader->nTimeStamp = mPrevTimestamp ;
+ outHeader->nTimeStamp = mPrevTimestamp;
mOutputBufferCount++;
outInfo->mOwnedByUs = false;
@@ -867,7 +817,7 @@
notifyFillBufferDone(outHeader);
outHeader = NULL;
}
- break; // if outQueue not empty but no more output
+ break; // if outQueue not empty but no more output
}
}
}
@@ -895,48 +845,36 @@
int SoftXAAC::configflushDecode() {
IA_ERRORCODE err_code;
UWORD32 ui_init_done;
- uint32_t inBufferLength=8203;
+ uint32_t inBufferLength = 8203;
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_FLUSH_MEM,
- NULL);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT, IA_CMD_TYPE_FLUSH_MEM, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_FLUSH_MEM");
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_INPUT_BYTES,
- 0,
- &inBufferLength);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_INPUT_BYTES, 0, &inBufferLength);
RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES");
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_FLUSH_MEM,
- NULL);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT, IA_CMD_TYPE_FLUSH_MEM, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_FLUSH_MEM");
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_DONE_QUERY,
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_DONE_QUERY,
&ui_init_done);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_DONE_QUERY");
-
if (ui_init_done) {
err_code = getXAACStreamInfo();
RETURN_IF_FATAL(err_code, "getXAACStreamInfo");
- ALOGV("Found Codec with below config---\nsampFreq %d\nnumChannels %d\npcmWdSz %d\nchannelMask %d\noutputFrameLength %d",
- mSampFreq,mNumChannels,mPcmWdSz,mChannelMask,mOutputFrameLength);
- if(mNumChannels > MAX_CHANNEL_COUNT) {
+ ALOGV(
+ "Found Codec with below config---\nsampFreq %d\nnumChannels %d\npcmWdSz "
+ "%d\nchannelMask %d\noutputFrameLength %d",
+ mSampFreq, mNumChannels, mPcmWdSz, mChannelMask, mOutputFrameLength);
+ if (mNumChannels > MAX_CHANNEL_COUNT) {
ALOGE(" No of channels are more than max channels\n");
mIsCodecInitialized = false;
- }
- else
+ } else
mIsCodecInitialized = true;
}
return err_code;
-
}
int SoftXAAC::drainDecoder() {
return 0;
@@ -965,15 +903,13 @@
case NONE:
break;
- case AWAITING_DISABLED:
- {
+ case AWAITING_DISABLED: {
CHECK(!enabled);
mOutputPortSettingsChange = AWAITING_ENABLED;
break;
}
- default:
- {
+ default: {
CHECK_EQ((int)mOutputPortSettingsChange, (int)AWAITING_ENABLED);
CHECK(enabled);
mOutputPortSettingsChange = NONE;
@@ -1012,10 +948,7 @@
/* ******************************************************************/
/* Get the API size */
- err_code = ixheaacd_dec_api(NULL,
- IA_API_CMD_GET_API_SIZE,
- 0,
- &pui_api_size);
+ err_code = ixheaacd_dec_api(NULL, IA_API_CMD_GET_API_SIZE, 0, &pui_api_size);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_API_SIZE");
if (mMallocCount == MAX_MEM_ALLOCS) {
@@ -1026,19 +959,16 @@
/* Allocate memory for API */
mMemoryArray[mMallocCount] = memalign(4, pui_api_size);
if (mMemoryArray[mMallocCount] == NULL) {
- ALOGE("malloc for pui_api_size + 4 >> %d Failed",pui_api_size + 4);
+ ALOGE("malloc for pui_api_size + 4 >> %d Failed", pui_api_size + 4);
return IA_FATAL_ERROR;
}
/* Set API object with the memory allocated */
- mXheaacCodecHandle =
- (pVOID)((WORD8*)mMemoryArray[mMallocCount]);
+ mXheaacCodecHandle = (pVOID)((WORD8*)mMemoryArray[mMallocCount]);
mMallocCount++;
/* Set the config params to default values */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS,
- NULL);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS");
#ifdef ENABLE_MPEG_D_DRC
/* Get the API size */
@@ -1051,28 +981,22 @@
return IA_FATAL_ERROR;
}
- /* Allocate memory for API */
- mMemoryArray[mMallocCount] = memalign(4, pui_api_size);
+ /* Allocate memory for API */
+ mMemoryArray[mMallocCount] = memalign(4, pui_api_size);
- if(mMemoryArray[mMallocCount] == NULL)
- {
- ALOGE("malloc for drc api structure Failed");
- return IA_FATAL_ERROR;
- }
- memset(mMemoryArray[mMallocCount],0,pui_api_size);
+ if (mMemoryArray[mMallocCount] == NULL) {
+ ALOGE("malloc for drc api structure Failed");
+ return IA_FATAL_ERROR;
+ }
+ memset(mMemoryArray[mMallocCount], 0, pui_api_size);
- /* Set API object with the memory allocated */
- mMpegDDrcHandle =
- (pVOID)((WORD8*)mMemoryArray[mMallocCount]);
+ /* Set API object with the memory allocated */
+ mMpegDDrcHandle = (pVOID)((WORD8*)mMemoryArray[mMallocCount]);
mMallocCount++;
-
/* Set the config params to default values */
- err_code = ia_drc_dec_api(
- mMpegDDrcHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS,
- NULL);
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS");
#endif
@@ -1081,10 +1005,8 @@
/* Set config parameters */
/* ******************************************************************/
UWORD32 ui_mp4_flag = 1;
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4,
- &ui_mp4_flag);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4, &ui_mp4_flag);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4");
/* ******************************************************************/
@@ -1092,9 +1014,7 @@
/* ******************************************************************/
/* Get memory info tables size */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_MEMTABS_SIZE,
- 0,
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_MEMTABS_SIZE, 0,
&ui_proc_mem_tabs_size);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEMTABS_SIZE");
@@ -1105,23 +1025,20 @@
mMemoryArray[mMallocCount] = memalign(4, ui_proc_mem_tabs_size);
if (mMemoryArray[mMallocCount] == NULL) {
- ALOGE("Malloc for size (ui_proc_mem_tabs_size + 4) = %d failed!",ui_proc_mem_tabs_size + 4);
+ ALOGE("Malloc for size (ui_proc_mem_tabs_size + 4) = %d failed!",
+ ui_proc_mem_tabs_size + 4);
return IA_FATAL_ERROR;
}
mMallocCount++;
/* Set pointer for process memory tables */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_MEMTABS_PTR,
- 0,
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_MEMTABS_PTR, 0,
(pVOID)((WORD8*)mMemoryArray[mMallocCount - 1]));
RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEMTABS_PTR");
/* initialize the API, post config, fill memory tables */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS,
- NULL);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS");
/* ******************************************************************/
@@ -1129,75 +1046,59 @@
/* ******************************************************************/
/* There are four different types of memories, that needs to be allocated */
/* persistent,scratch,input and output */
- for(i = 0; i < 4; i++) {
+ for (i = 0; i < 4; i++) {
int ui_size = 0, ui_alignment = 0, ui_type = 0;
pVOID pv_alloc_ptr;
/* Get memory size */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_MEM_INFO_SIZE,
- i,
- &ui_size);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_MEM_INFO_SIZE, i, &ui_size);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_SIZE");
/* Get memory alignment */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_MEM_INFO_ALIGNMENT,
- i,
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_MEM_INFO_ALIGNMENT, i,
&ui_alignment);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_ALIGNMENT");
/* Get memory type */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_MEM_INFO_TYPE,
- i,
- &ui_type);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_MEM_INFO_TYPE, i, &ui_type);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_TYPE");
if (mMallocCount == MAX_MEM_ALLOCS) {
ALOGE("mMemoryArray is full");
return IA_FATAL_ERROR;
}
-
- mMemoryArray[mMallocCount] =
- memalign(ui_alignment , ui_size);
+ mMemoryArray[mMallocCount] = memalign(ui_alignment, ui_size);
if (mMemoryArray[mMallocCount] == NULL) {
- ALOGE("Malloc for size (ui_size + ui_alignment) = %d failed!",ui_size + ui_alignment);
+ ALOGE("Malloc for size (ui_size + ui_alignment) = %d failed!", ui_size + ui_alignment);
return IA_FATAL_ERROR;
}
- pv_alloc_ptr =
- (pVOID )((WORD8*)mMemoryArray[mMallocCount]);
+ pv_alloc_ptr = (pVOID)((WORD8*)mMemoryArray[mMallocCount]);
mMallocCount++;
/* Set the buffer pointer */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_MEM_PTR,
- i,
- pv_alloc_ptr);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_MEM_PTR, i, pv_alloc_ptr);
RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEM_PTR");
if (ui_type == IA_MEMTYPE_INPUT) {
mInputBuffer = (pWORD8)pv_alloc_ptr;
mInputBufferSize = ui_size;
-
}
if (ui_type == IA_MEMTYPE_OUTPUT) {
mOutputBuffer = (pWORD8)pv_alloc_ptr;
}
-
}
/* End first part */
- return IA_NO_ERROR;
+ return IA_NO_ERROR;
}
int SoftXAAC::configXAACDecoder(uint8_t* inBuffer, uint32_t inBufferLength) {
-
UWORD32 ui_init_done;
int32_t i_bytes_consumed;
if (mInputBufferSize < inBufferLength) {
- ALOGE("Cannot config AAC, input buffer size %d < inBufferLength %d",mInputBufferSize,inBufferLength);
+ ALOGE("Cannot config AAC, input buffer size %d < inBufferLength %d", mInputBufferSize,
+ inBufferLength);
return false;
}
@@ -1205,51 +1106,41 @@
memcpy(mInputBuffer, inBuffer, inBufferLength);
/* Set number of bytes to be processed */
- IA_ERRORCODE err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_INPUT_BYTES,
- 0,
- &inBufferLength);
+ IA_ERRORCODE err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_INPUT_BYTES, 0, &inBufferLength);
RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES");
if (mIsCodecConfigFlushRequired) {
/* If codec is already initialized, then GA header is passed again */
/* Need to call the Flush API instead of INIT_PROCESS */
mIsCodecInitialized = false; /* Codec needs to be Reinitialized after flush */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_GA_HDR,
- NULL);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT, IA_CMD_TYPE_GA_HDR, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_GA_HDR");
- }
- else {
+ } else {
/* Initialize the process */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_PROCESS,
- NULL);
+ err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_PROCESS, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_PROCESS");
}
/* Checking for end of initialization */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_DONE_QUERY,
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_DONE_QUERY,
&ui_init_done);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_DONE_QUERY");
/* How much buffer is used in input buffers */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CURIDX_INPUT_BUF,
- 0,
- &i_bytes_consumed);
+ err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, &i_bytes_consumed);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_CURIDX_INPUT_BUF");
- if(ui_init_done){
+ if (ui_init_done) {
err_code = getXAACStreamInfo();
RETURN_IF_FATAL(err_code, "getXAACStreamInfo");
- ALOGI("Found Codec with below config---\nsampFreq %d\nnumChannels %d\npcmWdSz %d\nchannelMask %d\noutputFrameLength %d",
- mSampFreq,mNumChannels,mPcmWdSz,mChannelMask,mOutputFrameLength);
+ ALOGI(
+ "Found Codec with below config---\nsampFreq %d\nnumChannels %d\npcmWdSz "
+ "%d\nchannelMask %d\noutputFrameLength %d",
+ mSampFreq, mNumChannels, mPcmWdSz, mChannelMask, mOutputFrameLength);
mIsCodecInitialized = true;
#ifdef ENABLE_MPEG_D_DRC
@@ -1260,452 +1151,366 @@
return IA_NO_ERROR;
}
-int SoftXAAC::configMPEGDDrc()
-{
- IA_ERRORCODE err_code = IA_NO_ERROR;
- int i_effect_type;
- int i_loud_norm;
- int i_target_loudness;
- unsigned int i_sbr_mode;
- int n_mems;
- int i;
+int SoftXAAC::configMPEGDDrc() {
+ IA_ERRORCODE err_code = IA_NO_ERROR;
+ int i_effect_type;
+ int i_loud_norm;
+ int i_target_loudness;
+ unsigned int i_sbr_mode;
+ int n_mems;
+ int i;
-#ifdef ENABLE_MPEG_D_DRC
+#ifdef ENABLE_MPEG_D_DRC
{
+ /* Sampling Frequency */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ, &mSampFreq);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ");
+ /* Total Number of Channels */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS, &mNumChannels);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS");
- /* Sampling Frequency */
- {
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ, &mSampFreq);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ");
- }
- /* Total Number of Channels */
- {
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS, &mNumChannels);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS");
- }
+ /* PCM word size */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ, &mPcmWdSz);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ");
- /* PCM word size */
- {
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ, &mPcmWdSz);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ");
- }
+ /*Set Effect Type*/
- /*Set Effect Type*/
-
- {
err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE, &i_effect_type);
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE, &i_effect_type);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE");
-
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE, &i_effect_type);
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE, &i_effect_type);
RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE");
- }
-
-/*Set target loudness */
-
- {
- err_code = ixheaacd_dec_api(
- mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS, &i_target_loudness);
+ /*Set target loudness */
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS,
+ &i_target_loudness);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS");
-
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS, &i_target_loudness);
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS, &i_target_loudness);
RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS");
- }
+ /*Set loud_norm_flag*/
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM, &i_loud_norm);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM");
- /*Set loud_norm_flag*/
- {
- err_code = ixheaacd_dec_api(
- mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM, &i_loud_norm);
- RETURN_IF_FATAL(err_code,"IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM");
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_DRC_LOUD_NORM, &i_loud_norm);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_LOUD_NORM");
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE, &i_sbr_mode);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE");
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_DRC_LOUD_NORM, &i_loud_norm);
- RETURN_IF_FATAL(err_code,"IA_DRC_DEC_CONFIG_DRC_LOUD_NORM");
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL);
- }
+ RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS");
+ for (i = 0; i < (WORD32)2; i++) {
+ WORD32 ui_size, ui_alignment, ui_type;
+ pVOID pv_alloc_ptr;
+ /* Get memory size */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_GET_MEM_INFO_SIZE, i, &ui_size);
- err_code = ixheaacd_dec_api(
- mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE, &i_sbr_mode);
- RETURN_IF_FATAL(err_code,"IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE");
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_SIZE");
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL);
+ /* Get memory alignment */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_GET_MEM_INFO_ALIGNMENT, i,
+ &ui_alignment);
- RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS");
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_ALIGNMENT");
+ /* Get memory type */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_GET_MEM_INFO_TYPE, i, &ui_type);
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_TYPE");
+ if (mMallocCount == MAX_MEM_ALLOCS) {
+ ALOGE("mMemoryArray is full");
+ return IA_FATAL_ERROR;
+ }
+ mMemoryArray[mMallocCount] = memalign(4, ui_size);
+ if (mMemoryArray[mMallocCount] == NULL) {
+ ALOGE(" Cannot create requested memory %d", ui_size);
+ return IA_FATAL_ERROR;
+ }
+ pv_alloc_ptr = (pVOID)((WORD8*)mMemoryArray[mMallocCount]);
+ mMallocCount++;
- for (i = 0; i < (WORD32)2; i++) {
- WORD32 ui_size, ui_alignment, ui_type;
- pVOID pv_alloc_ptr;
+ /* Set the buffer pointer */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_MEM_PTR, i, pv_alloc_ptr);
- /* Get memory size */
- err_code = ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_GET_MEM_INFO_SIZE, i, &ui_size);
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEM_PTR");
+ }
+ {
+ WORD32 ui_size;
+ ui_size = 8192 * 2;
+ if (mMallocCount == MAX_MEM_ALLOCS) {
+ ALOGE("mMemoryArray is full");
+ return IA_FATAL_ERROR;
+ }
- RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_SIZE");
+ mMemoryArray[mMallocCount] = memalign(4, ui_size);
+ if (mMemoryArray[mMallocCount] == NULL) {
+ ALOGE(" Cannot create requested memory %d", ui_size);
+ return IA_FATAL_ERROR;
+ }
- /* Get memory alignment */
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_GET_MEM_INFO_ALIGNMENT, i, &ui_alignment);
+ mDrcInBuf = (int8_t*)mMemoryArray[mMallocCount];
+ mMallocCount++;
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_MEM_PTR, 2,
+ /*mOutputBuffer*/ mDrcInBuf);
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEM_PTR");
- RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_ALIGNMENT");
+ if (mMallocCount == MAX_MEM_ALLOCS) {
+ ALOGE("mMemoryArray is full");
+ return IA_FATAL_ERROR;
+ }
+ mMemoryArray[mMallocCount] = memalign(4, ui_size);
+ if (mMemoryArray[mMallocCount] == NULL) {
+ ALOGE(" Cannot create requested memory %d", ui_size);
+ return IA_FATAL_ERROR;
+ }
- /* Get memory type */
- err_code = ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_GET_MEM_INFO_TYPE, i, &ui_type);
-
- RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_MEM_INFO_TYPE");
-
- if (mMallocCount == MAX_MEM_ALLOCS) {
- ALOGE("mMemoryArray is full");
- return IA_FATAL_ERROR;
- }
- mMemoryArray[mMallocCount] = memalign(4, ui_size);
- if (mMemoryArray[mMallocCount] == NULL) {
- ALOGE(" Cannot create requested memory %d",ui_size);
- return IA_FATAL_ERROR;
- }
- pv_alloc_ptr =
- (pVOID )((WORD8*)mMemoryArray[mMallocCount]);
- mMallocCount++;
-
- /* Set the buffer pointer */
- err_code = ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_SET_MEM_PTR, i, pv_alloc_ptr);
-
- RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEM_PTR");
- }
- {
- WORD32 ui_size;
- ui_size=8192*2;
- if (mMallocCount == MAX_MEM_ALLOCS) {
- ALOGE("mMemoryArray is full");
- return IA_FATAL_ERROR;
- }
-
- mMemoryArray[mMallocCount]=memalign(4, ui_size);
- if (mMemoryArray[mMallocCount] == NULL) {
- ALOGE(" Cannot create requested memory %d",ui_size);
- return IA_FATAL_ERROR;
- }
-
- mDrcInBuf=(int8_t *)mMemoryArray[mMallocCount];
- mMallocCount++;
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_MEM_PTR,
- 2, /*mOutputBuffer*/ mDrcInBuf);
- RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEM_PTR");
-
- if (mMallocCount == MAX_MEM_ALLOCS) {
- ALOGE("mMemoryArray is full");
- return IA_FATAL_ERROR;
- }
-
- mMemoryArray[mMallocCount]=memalign(4, ui_size);
- if (mMemoryArray[mMallocCount] == NULL) {
- ALOGE(" Cannot create requested memory %d",ui_size);
- return IA_FATAL_ERROR;
- }
-
- mDrcOutBuf=(int8_t *)mMemoryArray[mMallocCount];
- mMallocCount++;
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_MEM_PTR,
- 3, /*mOutputBuffer*/ mDrcOutBuf);
- RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEM_PTR");
- }
- /*ITTIAM: DRC buffers
+ mDrcOutBuf = (int8_t*)mMemoryArray[mMallocCount];
+ mMallocCount++;
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_MEM_PTR, 3,
+ /*mOutputBuffer*/ mDrcOutBuf);
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_MEM_PTR");
+ }
+ /* DRC buffers
buf[0] - contains extension element pay load loudness related
buf[1] - contains extension element pay load*/
- {
- VOID *p_array[2][16];
- WORD32 ii;
- WORD32 buf_sizes[2][16];
- WORD32 num_elements;
- WORD32 num_config_ext;
- WORD32 bit_str_fmt = 1;
-
-
-
- WORD32 uo_num_chan;
-
- memset(buf_sizes, 0, 32 * sizeof(WORD32));
-
- err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES, &buf_sizes[0][0]);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES");
-
- err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR, &p_array);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR");
-
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_SET_BUFF_PTR, 0);
- RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_SET_BUFF_PTR");
-
-
- err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE, &num_elements);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE");
-
- err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT, &num_config_ext);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT");
-
- for (ii = 0; ii < num_config_ext; ii++) {
- /*copy loudness bitstream*/
- if (buf_sizes[0][ii] > 0) {
- memcpy(mDrcInBuf, p_array[0][ii], buf_sizes[0][ii]);
-
- /*Set bitstream_split_format */
- err_code = ia_drc_dec_api(
- mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
-
- /* Set number of bytes to be processed */
- err_code = ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_SET_INPUT_BYTES_IL_BS, 0,
- &buf_sizes[0][ii]);
- RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES_IL_BS");
-
-
- /* Execute process */
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF, NULL);
- RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF");
-
-
- mDRCFlag = 1;
- }
- }
-
- for (ii = 0; ii < num_elements; ii++) {
- /*copy config bitstream*/
- if (buf_sizes[1][ii] > 0) {
- memcpy(mDrcInBuf, p_array[1][ii], buf_sizes[1][ii]);
- /* Set number of bytes to be processed */
-
- /*Set bitstream_split_format */
- err_code = ia_drc_dec_api(
- mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
-
- err_code = ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_SET_INPUT_BYTES_IC_BS, 0,
- &buf_sizes[1][ii]);
- RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES_IC_BS");
-
-
- /* Execute process */
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF, NULL);
-
- RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF");
-
- mDRCFlag = 1;
- }
- }
-
- if (mDRCFlag == 1) {
- mMpegDDRCPresent = 1;
- } else {
- mMpegDDRCPresent = 0;
- }
-
-
- /*Read interface buffer config file bitstream*/
- if(mMpegDDRCPresent==1){
-
- WORD32 interface_is_present = 1;
- WORD32 frame_length;
-
- if(i_sbr_mode != 0)
{
- if (i_sbr_mode == 1)
- {
- frame_length = 2048;
+ VOID* p_array[2][16];
+ WORD32 ii;
+ WORD32 buf_sizes[2][16];
+ WORD32 num_elements;
+ WORD32 num_config_ext;
+ WORD32 bit_str_fmt = 1;
+
+ WORD32 uo_num_chan;
+
+ memset(buf_sizes, 0, 32 * sizeof(WORD32));
+
+ err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES, &buf_sizes[0][0]);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES");
+
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR, &p_array);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR");
+
+ err_code =
+ ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_SET_BUFF_PTR, 0);
+ RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_SET_BUFF_PTR");
+
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE, &num_elements);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE");
+
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT, &num_config_ext);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT");
+
+ for (ii = 0; ii < num_config_ext; ii++) {
+ /*copy loudness bitstream*/
+ if (buf_sizes[0][ii] > 0) {
+ memcpy(mDrcInBuf, p_array[0][ii], buf_sizes[0][ii]);
+
+ /*Set bitstream_split_format */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
+
+ /* Set number of bytes to be processed */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_INPUT_BYTES_IL_BS, 0,
+ &buf_sizes[0][ii]);
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES_IL_BS");
+
+ /* Execute process */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF, NULL);
+ RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF");
+
+ mDRCFlag = 1;
+ }
}
- else if(i_sbr_mode == 3)
- {
- frame_length = 4096;
+
+ for (ii = 0; ii < num_elements; ii++) {
+ /*copy config bitstream*/
+ if (buf_sizes[1][ii] > 0) {
+ memcpy(mDrcInBuf, p_array[1][ii], buf_sizes[1][ii]);
+ /* Set number of bytes to be processed */
+
+ /*Set bitstream_split_format */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
+
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_INPUT_BYTES_IC_BS, 0,
+ &buf_sizes[1][ii]);
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES_IC_BS");
+
+ /* Execute process */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF, NULL);
+
+ RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF");
+
+ mDRCFlag = 1;
+ }
}
- else
- {
- frame_length = 1024;
+
+ if (mDRCFlag == 1) {
+ mMpegDDRCPresent = 1;
+ } else {
+ mMpegDDRCPresent = 0;
+ }
+
+ /*Read interface buffer config file bitstream*/
+ if (mMpegDDRCPresent == 1) {
+ WORD32 interface_is_present = 1;
+ WORD32 frame_length;
+
+ if (i_sbr_mode != 0) {
+ if (i_sbr_mode == 1) {
+ frame_length = 2048;
+ } else if (i_sbr_mode == 3) {
+ frame_length = 4096;
+ } else {
+ frame_length = 1024;
+ }
+ } else {
+ frame_length = 4096;
+ }
+
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE, &frame_length);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE");
+
+ err_code =
+ ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT, &interface_is_present);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT");
+
+ /* Execute process */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF, NULL);
+ RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF");
+
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_PROCESS, NULL);
+ RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_PROCESS");
+
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS, &uo_num_chan);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS");
}
}
- else
- {
- frame_length = 4096;
- }
-
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE, &frame_length);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE");
-
-
-
- err_code = ia_drc_dec_api(
- mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT, &interface_is_present);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT");
-
-
- /* Execute process */
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF, NULL);
- RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF");
-
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_PROCESS, NULL);
- RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_INIT_PROCESS");
-
- err_code = ia_drc_dec_api(
- mMpegDDrcHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS, &uo_num_chan);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS");
- }
}
- }
#endif
-return err_code;
-
+ return err_code;
}
-int SoftXAAC::decodeXAACStream(uint8_t* inBuffer,
- uint32_t inBufferLength,
- int32_t *bytesConsumed,
- int32_t *outBytes) {
+int SoftXAAC::decodeXAACStream(uint8_t* inBuffer, uint32_t inBufferLength, int32_t* bytesConsumed,
+ int32_t* outBytes) {
if (mInputBufferSize < inBufferLength) {
- ALOGE("Cannot config AAC, input buffer size %d < inBufferLength %d",mInputBufferSize,inBufferLength);
+ ALOGE("Cannot config AAC, input buffer size %d < inBufferLength %d", mInputBufferSize,
+ inBufferLength);
return -1;
}
/* Copy the buffer passed by Android plugin to codec input buffer */
- memcpy(mInputBuffer,inBuffer,inBufferLength);
+ memcpy(mInputBuffer, inBuffer, inBufferLength);
/* Set number of bytes to be processed */
- IA_ERRORCODE err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_INPUT_BYTES,
- 0,
- &inBufferLength);
+ IA_ERRORCODE err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_INPUT_BYTES, 0, &inBufferLength);
RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES");
/* Execute process */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_EXECUTE,
- IA_CMD_TYPE_DO_EXECUTE,
- NULL);
+ err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_EXECUTE, IA_CMD_TYPE_DO_EXECUTE, NULL);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_DO_EXECUTE");
UWORD32 ui_exec_done;
/* Checking for end of processing */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_EXECUTE,
- IA_CMD_TYPE_DONE_QUERY,
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_EXECUTE, IA_CMD_TYPE_DONE_QUERY,
&ui_exec_done);
RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_DONE_QUERY");
#ifdef ENABLE_MPEG_D_DRC
- {
- if (ui_exec_done != 1) {
- VOID *p_array; // ITTIAM:buffer to handle gain payload
- WORD32 buf_size = 0; // ITTIAM:gain payload length
- WORD32 bit_str_fmt = 1;
- WORD32 gain_stream_flag = 1;
+ {
+ if (ui_exec_done != 1) {
+ VOID* p_array; // ITTIAM:buffer to handle gain payload
+ WORD32 buf_size = 0; // ITTIAM:gain payload length
+ WORD32 bit_str_fmt = 1;
+ WORD32 gain_stream_flag = 1;
- err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN, &buf_size);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN");
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN, &buf_size);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN");
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF, &p_array);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF");
- err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF, &p_array);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF");
+ if (buf_size > 0) {
+ /*Set bitstream_split_format */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
+ memcpy(mDrcInBuf, p_array, buf_size);
+ /* Set number of bytes to be processed */
+ err_code =
+ ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_INPUT_BYTES_BS, 0, &buf_size);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
- if (buf_size > 0) {
- /*Set bitstream_split_format */
- err_code = ia_drc_dec_api(
- mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT, &bit_str_fmt);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG, &gain_stream_flag);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
- memcpy(mDrcInBuf, p_array, buf_size);
- /* Set number of bytes to be processed */
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_SET_INPUT_BYTES_BS, 0, &buf_size);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
+ /* Execute process */
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
+ IA_CMD_TYPE_INIT_CPY_BSF_BUFF, NULL);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
- err_code = ia_drc_dec_api(
- mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG, &gain_stream_flag);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
-
-
- /* Execute process */
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_INIT,
- IA_CMD_TYPE_INIT_CPY_BSF_BUFF, NULL);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT");
-
-
- mMpegDDRCPresent = 1;
+ mMpegDDRCPresent = 1;
+ }
}
- }
}
#endif
/* How much buffer is used in input buffers */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CURIDX_INPUT_BUF,
- 0,
- bytesConsumed);
+ err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, bytesConsumed);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_CURIDX_INPUT_BUF");
/* Get the output bytes */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_OUTPUT_BYTES,
- 0,
- outBytes);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_OUTPUT_BYTES, 0, outBytes);
RETURN_IF_FATAL(err_code, "IA_API_CMD_GET_OUTPUT_BYTES");
#ifdef ENABLE_MPEG_D_DRC
if (mMpegDDRCPresent == 1) {
- memcpy(mDrcInBuf, mOutputBuffer, *outBytes);
- err_code = ia_drc_dec_api(mMpegDDrcHandle,
- IA_API_CMD_SET_INPUT_BYTES, 0, outBytes);
- RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES");
+ memcpy(mDrcInBuf, mOutputBuffer, *outBytes);
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_INPUT_BYTES, 0, outBytes);
+ RETURN_IF_FATAL(err_code, "IA_API_CMD_SET_INPUT_BYTES");
+ err_code =
+ ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_EXECUTE, IA_CMD_TYPE_DO_EXECUTE, NULL);
+ RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_DO_EXECUTE");
- err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_EXECUTE,
- IA_CMD_TYPE_DO_EXECUTE, NULL);
- RETURN_IF_FATAL(err_code, "IA_CMD_TYPE_DO_EXECUTE");
-
- memcpy(mOutputBuffer, mDrcOutBuf, *outBytes);
+ memcpy(mOutputBuffer, mDrcOutBuf, *outBytes);
}
#endif
return err_code;
@@ -1715,16 +1520,11 @@
ALOGI("deInitXAACDecoder");
/* Tell that the input is over in this buffer */
- IA_ERRORCODE err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_INPUT_OVER,
- 0,
- NULL);
+ IA_ERRORCODE err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_INPUT_OVER, 0, NULL);
RETURN_IF_FATAL(err_code, "IA_API_CMD_INPUT_OVER");
- for(int i = 0; i < mMallocCount; i++)
- {
- if(mMemoryArray[i])
- free(mMemoryArray[i]);
+ for (int i = 0; i < mMallocCount; i++) {
+ if (mMemoryArray[i]) free(mMemoryArray[i]);
}
mMallocCount = 0;
@@ -1735,59 +1535,47 @@
IA_ERRORCODE err_code = IA_NO_ERROR;
/* Sampling frequency */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ,
- &mSampFreq);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ, &mSampFreq);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQ");
/* Total Number of Channels */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_NUM_CHANNELS,
- &mNumChannels);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_NUM_CHANNELS, &mNumChannels);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_NUM_CHANNELS");
/* PCM word size */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ,
- &mPcmWdSz);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ, &mPcmWdSz);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZ");
/* channel mask to tell the arrangement of channels in bit stream */
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASK,
- &mChannelMask);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASK, &mChannelMask);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASK");
/* Channel mode to tell MONO/STEREO/DUAL-MONO/NONE_OF_THESE */
UWORD32 ui_channel_mode;
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODE,
- &ui_channel_mode);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODE, &ui_channel_mode);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODE");
- if(ui_channel_mode == 0)
+ if (ui_channel_mode == 0)
ALOGV("Channel Mode: MONO_OR_PS\n");
- else if(ui_channel_mode == 1)
+ else if (ui_channel_mode == 1)
ALOGV("Channel Mode: STEREO\n");
- else if(ui_channel_mode == 2)
+ else if (ui_channel_mode == 2)
ALOGV("Channel Mode: DUAL-MONO\n");
else
ALOGV("Channel Mode: NONE_OF_THESE or MULTICHANNEL\n");
/* Channel mode to tell SBR PRESENT/NOT_PRESENT */
UWORD32 ui_sbr_mode;
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE,
- &ui_sbr_mode);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE, &ui_sbr_mode);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE");
- if(ui_sbr_mode == 0)
+ if (ui_sbr_mode == 0)
ALOGV("SBR Mode: NOT_PRESENT\n");
- else if(ui_sbr_mode == 1)
+ else if (ui_sbr_mode == 1)
ALOGV("SBR Mode: PRESENT\n");
else
ALOGV("SBR Mode: ILLEGAL\n");
@@ -1797,132 +1585,103 @@
/* not yet added in codec */
mOutputFrameLength = 1024 * (1 + ui_sbr_mode);
- ALOGI("mOutputFrameLength %d ui_sbr_mode %d",mOutputFrameLength,ui_sbr_mode);
+ ALOGI("mOutputFrameLength %d ui_sbr_mode %d", mOutputFrameLength, ui_sbr_mode);
return IA_NO_ERROR;
}
-IA_ERRORCODE SoftXAAC::setXAACDRCInfo(int32_t drcCut,
- int32_t drcBoost,
- int32_t drcRefLevel,
+IA_ERRORCODE SoftXAAC::setXAACDRCInfo(int32_t drcCut, int32_t drcBoost, int32_t drcRefLevel,
int32_t drcHeavyCompression
- #ifdef ENABLE_MPEG_D_DRC
- ,int32_t drEffectType
- #endif
- ) {
+#ifdef ENABLE_MPEG_D_DRC
+ ,
+ int32_t drEffectType
+#endif
+) {
IA_ERRORCODE err_code = IA_NO_ERROR;
int32_t ui_drc_enable = 1;
int32_t i_effect_type, i_target_loudness, i_loud_norm;
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE,
- &ui_drc_enable);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE");
- if (drcCut !=-1) {
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT,
- &drcCut);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE, &ui_drc_enable);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE");
+ if (drcCut != -1) {
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT, &drcCut);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT");
}
- if (drcBoost !=-1) {
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST,
- &drcBoost);
+ if (drcBoost != -1) {
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST, &drcBoost);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST");
}
if (drcRefLevel != -1) {
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL,
- &drcRefLevel);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL, &drcRefLevel);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL");
}
#ifdef ENABLE_MPEG_D_DRC
if (drcRefLevel != -1) {
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS,
- &drcRefLevel);
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS, &drcRefLevel);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS");
}
#endif
if (drcHeavyCompression != -1) {
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP,
- &drcHeavyCompression);
+ err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP, &drcHeavyCompression);
RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP");
}
#ifdef ENABLE_MPEG_D_DRC
- err_code = ixheaacd_dec_api(mXheaacCodecHandle,
- IA_API_CMD_SET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE,
- &drEffectType);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE");
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE, &drEffectType);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE");
#endif
#ifdef ENABLE_MPEG_D_DRC
/*Set Effect Type*/
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE, &i_effect_type);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE");
- {
- err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE, &i_effect_type);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE");
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE, &i_effect_type);
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE, &i_effect_type);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE");
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE");
+ /*Set target loudness */
+ err_code =
+ ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS, &i_target_loudness);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS");
- }
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS, &i_target_loudness);
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS");
-/*Set target loudness */
-
- {
- err_code = ixheaacd_dec_api(
- mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS, &i_target_loudness);
- RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS");
-
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS, &i_target_loudness);
- RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS");
-
- }
/*Set loud_norm_flag*/
- {
- err_code = ixheaacd_dec_api(
- mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
- IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM, &i_loud_norm);
- RETURN_IF_FATAL(err_code,"IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM");
+ err_code = ixheaacd_dec_api(mXheaacCodecHandle, IA_API_CMD_GET_CONFIG_PARAM,
+ IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM, &i_loud_norm);
+ RETURN_IF_FATAL(err_code, "IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM");
- err_code =
- ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
- IA_DRC_DEC_CONFIG_DRC_LOUD_NORM, &i_loud_norm);
+ err_code = ia_drc_dec_api(mMpegDDrcHandle, IA_API_CMD_SET_CONFIG_PARAM,
+ IA_DRC_DEC_CONFIG_DRC_LOUD_NORM, &i_loud_norm);
- RETURN_IF_FATAL(err_code,"IA_DRC_DEC_CONFIG_DRC_LOUD_NORM");
-
- }
+ RETURN_IF_FATAL(err_code, "IA_DRC_DEC_CONFIG_DRC_LOUD_NORM");
#endif
-
return IA_NO_ERROR;
}
} // namespace android
-android::SoftOMXComponent *createSoftOMXComponent(
- const char *name, const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData, OMX_COMPONENTTYPE **component) {
+android::SoftOMXComponent* createSoftOMXComponent(const char* name,
+ const OMX_CALLBACKTYPE* callbacks,
+ OMX_PTR appData, OMX_COMPONENTTYPE** component) {
ALOGI("createSoftOMXComponent for SoftXAACDEC");
return new android::SoftXAAC(name, callbacks, appData, component);
}
diff --git a/media/libstagefright/codecs/xaacdec/SoftXAAC.h b/media/libstagefright/codecs/xaacdec/SoftXAAC.h
index 0b3a612..6176082 100644
--- a/media/libstagefright/codecs/xaacdec/SoftXAAC.h
+++ b/media/libstagefright/codecs/xaacdec/SoftXAAC.h
@@ -35,59 +35,49 @@
#define MAX_MEM_ALLOCS 100
-extern "C" IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_module_obj,
- WORD32 i_cmd, WORD32 i_idx, pVOID pv_value);
-extern "C" IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_module_obj,
- WORD32 i_cmd, WORD32 i_idx, pVOID pv_value);
-extern "C" IA_ERRORCODE ixheaacd_get_config_param(pVOID p_ia_process_api_obj,
- pWORD32 pi_samp_freq,
- pWORD32 pi_num_chan,
- pWORD32 pi_pcm_wd_sz,
- pWORD32 pi_channel_mask);
+extern "C" IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx,
+ pVOID pv_value);
+extern "C" IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx,
+ pVOID pv_value);
+extern "C" IA_ERRORCODE ixheaacd_get_config_param(pVOID p_ia_process_api_obj, pWORD32 pi_samp_freq,
+ pWORD32 pi_num_chan, pWORD32 pi_pcm_wd_sz,
+ pWORD32 pi_channel_mask);
namespace android {
struct SoftXAAC : public SimpleSoftOMXComponent {
- SoftXAAC(const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component);
+ SoftXAAC(const char* name, const OMX_CALLBACKTYPE* callbacks, OMX_PTR appData,
+ OMX_COMPONENTTYPE** component);
-protected:
+ protected:
virtual ~SoftXAAC();
- virtual OMX_ERRORTYPE internalGetParameter(
- OMX_INDEXTYPE index, OMX_PTR params);
+ virtual OMX_ERRORTYPE internalGetParameter(OMX_INDEXTYPE index, OMX_PTR params);
- virtual OMX_ERRORTYPE internalSetParameter(
- OMX_INDEXTYPE index, const OMX_PTR params);
+ virtual OMX_ERRORTYPE internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR params);
virtual void onQueueFilled(OMX_U32 portIndex);
virtual void onPortFlushCompleted(OMX_U32 portIndex);
virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
virtual void onReset();
-private:
+ private:
enum {
- kNumInputBuffers = 4,
- kNumOutputBuffers = 4,
- kNumDelayBlocksMax = 8,
+ kNumInputBuffers = 4,
+ kNumOutputBuffers = 4,
+ kNumDelayBlocksMax = 8,
};
bool mIsADTS;
size_t mInputBufferCount;
size_t mOutputBufferCount;
bool mSignalledError;
- OMX_BUFFERHEADERTYPE *mLastInHeader;
+ OMX_BUFFERHEADERTYPE* mLastInHeader;
int64_t mPrevTimestamp;
int64_t mCurrentTimestamp;
uint32_t mBufSize;
- enum {
- NONE,
- AWAITING_DISABLED,
- AWAITING_ENABLED
- } mOutputPortSettingsChange;
+ enum { NONE, AWAITING_DISABLED, AWAITING_ENABLED } mOutputPortSettingsChange;
void initPorts();
status_t initDecoder();
@@ -98,48 +88,43 @@
int configXAACDecoder(uint8_t* inBuffer, uint32_t inBufferLength);
int configMPEGDDrc();
- int decodeXAACStream(uint8_t* inBuffer,
- uint32_t inBufferLength,
- int32_t *bytesConsumed,
- int32_t *outBytes);
+ int decodeXAACStream(uint8_t* inBuffer, uint32_t inBufferLength, int32_t* bytesConsumed,
+ int32_t* outBytes);
int configflushDecode();
IA_ERRORCODE getXAACStreamInfo();
- IA_ERRORCODE setXAACDRCInfo(int32_t drcCut,
- int32_t drcBoost,
- int32_t drcRefLevel,
+ IA_ERRORCODE setXAACDRCInfo(int32_t drcCut, int32_t drcBoost, int32_t drcRefLevel,
int32_t drcHeavyCompression
#ifdef ENABLE_MPEG_D_DRC
- ,int32_t drEffectType
+ ,
+ int32_t drEffectType
#endif
- );
+ );
bool mEndOfInput;
bool mEndOfOutput;
- void* mXheaacCodecHandle;
- void* mMpegDDrcHandle;
- uint32_t mInputBufferSize;
- uint32_t mOutputFrameLength;
- int8_t* mInputBuffer;
- int8_t* mOutputBuffer;
- int32_t mSampFreq;
- int32_t mNumChannels;
- int32_t mPcmWdSz;
- int32_t mChannelMask;
- bool mIsCodecInitialized;
- bool mIsCodecConfigFlushRequired;
- int8_t *mDrcInBuf;
- int8_t *mDrcOutBuf;
+ void* mXheaacCodecHandle;
+ void* mMpegDDrcHandle;
+ uint32_t mInputBufferSize;
+ uint32_t mOutputFrameLength;
+ int8_t* mInputBuffer;
+ int8_t* mOutputBuffer;
+ int32_t mSampFreq;
+ int32_t mNumChannels;
+ int32_t mPcmWdSz;
+ int32_t mChannelMask;
+ bool mIsCodecInitialized;
+ bool mIsCodecConfigFlushRequired;
+ int8_t* mDrcInBuf;
+ int8_t* mDrcOutBuf;
int32_t mMpegDDRCPresent;
int32_t mDRCFlag;
-
- void* mMemoryArray[MAX_MEM_ALLOCS];
- int32_t mMallocCount;
+ void* mMemoryArray[MAX_MEM_ALLOCS];
+ int32_t mMallocCount;
DISALLOW_EVIL_CONSTRUCTORS(SoftXAAC);
-
};
} // namespace android
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 282871b..c41de82 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -55,6 +55,7 @@
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/String16.h>
+#include <utils/SystemClock.h>
#include <utils/Trace.h>
#include <private/android_filesystem_config.h>
#include <system/camera_vendor_tags.h>
@@ -2433,6 +2434,8 @@
return isUidActiveLocked(uid, callingPackage);
}
+static const int kPollUidActiveTimeoutMillis = 50;
+
bool CameraService::UidPolicy::isUidActiveLocked(uid_t uid, String16 callingPackage) {
// Non-app UIDs are considered always active
// If activity manager is unreachable, assume everything is active
@@ -2452,7 +2455,28 @@
ActivityManager am;
// Okay to access with a lock held as UID changes are dispatched without
// a lock and we are a higher level component.
- active = am.isUidActive(uid, callingPackage);
+ int64_t startTimeMillis = 0;
+ do {
+ // TODO: Fix this b/109950150!
+ // Okay this is a hack. There is a race between the UID turning active and
+ // activity being resumed. The proper fix is very risky, so we temporary add
+ // some polling which should happen pretty rarely anyway as the race is hard
+ // to hit.
+ active = am.isUidActive(uid, callingPackage);
+ if (active) {
+ break;
+ }
+ if (startTimeMillis <= 0) {
+ startTimeMillis = uptimeMillis();
+ }
+ int64_t ellapsedTimeMillis = uptimeMillis() - startTimeMillis;
+ int64_t remainingTimeMillis = kPollUidActiveTimeoutMillis - ellapsedTimeMillis;
+ if (remainingTimeMillis <= 0) {
+ break;
+ }
+ usleep(remainingTimeMillis * 1000);
+ } while (true);
+
if (active) {
// Now that we found out the UID is actually active, cache that
mActiveUids.insert(uid);