Skip to content

Commit cb52d01

Browse files
theandi666Android (Google) Code Review
authored andcommitted
Merge "Gracefuly return on detecting wrong AAC format from corrupted files"
2 parents d42825f + 9a6ed36 commit cb52d01

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

include/media/stagefright/OMXCodec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ struct OMXCodec : public MediaSource,
228228
void setComponentRole();
229229

230230
void setAMRFormat(bool isWAMR, int32_t bitRate);
231-
void setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bitRate);
231+
status_t setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bitRate);
232232
void setG711Format(int32_t numChannels);
233233

234234
status_t setVideoPortFormatType(

media/libstagefright/OMXCodec.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,11 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
625625
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
626626
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
627627

628-
setAACFormat(numChannels, sampleRate, bitRate);
628+
status_t err = setAACFormat(numChannels, sampleRate, bitRate);
629+
if (err != OK) {
630+
CODEC_LOGE("setAACFormat() failed (err = %d)", err);
631+
return err;
632+
}
629633
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_G711_ALAW, mMIME)
630634
|| !strcasecmp(MEDIA_MIMETYPE_AUDIO_G711_MLAW, mMIME)) {
631635
// These are PCM-like formats with a fixed sample rate but
@@ -3358,8 +3362,10 @@ void OMXCodec::setAMRFormat(bool isWAMR, int32_t bitRate) {
33583362
}
33593363
}
33603364

3361-
void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bitRate) {
3362-
CHECK(numChannels == 1 || numChannels == 2);
3365+
status_t OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bitRate) {
3366+
if (numChannels > 2)
3367+
LOGW("Number of channels: (%d) \n", numChannels);
3368+
33633369
if (mIsEncoder) {
33643370
//////////////// input port ////////////////////
33653371
setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
@@ -3410,9 +3416,13 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bit
34103416
profile.nAACERtools = OMX_AUDIO_AACERNone;
34113417
profile.eAACProfile = OMX_AUDIO_AACObjectLC;
34123418
profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4FF;
3413-
CHECK_EQ(mOMX->setParameter(mNode, OMX_IndexParamAudioAac,
3414-
&profile, sizeof(profile)), (status_t)OK);
3419+
err = mOMX->setParameter(mNode, OMX_IndexParamAudioAac,
3420+
&profile, sizeof(profile));
34153421

3422+
if (err != OK) {
3423+
CODEC_LOGE("setParameter('OMX_IndexParamAudioAac') failed (err = %d)", err);
3424+
return err;
3425+
}
34163426
} else {
34173427
OMX_AUDIO_PARAM_AACPROFILETYPE profile;
34183428
InitOMXParams(&profile);
@@ -3428,8 +3438,14 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bit
34283438

34293439
err = mOMX->setParameter(
34303440
mNode, OMX_IndexParamAudioAac, &profile, sizeof(profile));
3431-
CHECK_EQ(err, (status_t)OK);
3441+
3442+
if (err != OK) {
3443+
CODEC_LOGE("setParameter('OMX_IndexParamAudioAac') failed (err = %d)", err);
3444+
return err;
3445+
}
34323446
}
3447+
3448+
return OK;
34333449
}
34343450

34353451
void OMXCodec::setG711Format(int32_t numChannels) {

0 commit comments

Comments
 (0)