Skip to content

Commit 2723e09

Browse files
theandi666Android (Google) Code Review
authored andcommitted
Merge "Better handling of codec initialization failure in the player and thumbnail extractor. Return a runtime error instead of asserting if the software MPEG4/H.263 decoder fails to initialize." into froyo
2 parents 0690679 + 1919e5a commit 2723e09

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

cmds/stagefright/stagefright.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ static void playSource(OMXClient *client, const sp<MediaSource> &source) {
7575
}
7676
}
7777

78-
rawSource->start();
78+
status_t err = rawSource->start();
79+
80+
if (err != OK) {
81+
fprintf(stderr, "rawSource returned error %d (0x%08x)\n", err, err);
82+
return;
83+
}
7984

8085
if (gPlaybackAudio) {
8186
AudioPlayer *player = new AudioPlayer(NULL);

media/libstagefright/AwesomePlayer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,12 @@ status_t AwesomePlayer::initVideoDecoder() {
822822
CHECK(mVideoTrack->getFormat()->findInt32(kKeyWidth, &mVideoWidth));
823823
CHECK(mVideoTrack->getFormat()->findInt32(kKeyHeight, &mVideoHeight));
824824

825-
mVideoSource->start();
825+
status_t err = mVideoSource->start();
826+
827+
if (err != OK) {
828+
mVideoSource.clear();
829+
return err;
830+
}
826831
}
827832

828833
return mVideoSource != NULL ? OK : UNKNOWN_ERROR;

media/libstagefright/StagefrightMetadataRetriever.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
120120
return NULL;
121121
}
122122

123-
decoder->start();
123+
status_t err = decoder->start();
124+
if (err != OK) {
125+
LOGW("OMXCodec::start returned error %d (0x%08x)\n", err, err);
126+
return NULL;
127+
}
124128

125129
// Read one output buffer, ignore format change notifications
126130
// and spurious empty buffers.
@@ -134,7 +138,6 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
134138
}
135139

136140
MediaBuffer *buffer = NULL;
137-
status_t err;
138141
do {
139142
if (buffer != NULL) {
140143
buffer->release();

media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,16 @@ status_t M4vH263Decoder::start(MetaData *) {
120120
vol_size = 0;
121121

122122
}
123-
CHECK_EQ(PV_TRUE, PVInitVideoDecoder(
124-
mHandle, vol_data, &vol_size, 1, mWidth, mHeight, mode));
123+
124+
Bool success = PVInitVideoDecoder(
125+
mHandle, vol_data, &vol_size, 1, mWidth, mHeight, mode);
125126
if (vol_data[0]) free(vol_data[0]);
127+
128+
if (success != PV_TRUE) {
129+
LOGW("PVInitVideoDecoder failed. Unsupported content?");
130+
return ERROR_UNSUPPORTED;
131+
}
132+
126133
MP4DecodingMode actualMode = PVGetDecBitstreamMode(mHandle);
127134
CHECK_EQ(mode, actualMode);
128135

0 commit comments

Comments
 (0)