Skip to content

Commit

Permalink
capture a top java exception on certain Samsung devices
Browse files Browse the repository at this point in the history
This is one of the top crasher on some samsung devices
https://crash.corp.google.com/search?query=android.media.MediaCodec.flush
Capture some exceptions while we are trying to look into the problem

BUG=278464

Review URL: https://chromiumcodereview.appspot.com/23321004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221858 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
qinmin@chromium.org committed Sep 7, 2013
1 parent 7064131 commit f011974
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,18 @@ private DequeueInputResult dequeueInputBuffer(long timeoutUs) {
}

@CalledByNative
private void flush() {
mMediaCodec.flush();
mFlushed = true;
if (mAudioTrack != null) {
mAudioTrack.flush();
private int flush() {
try {
mFlushed = true;
if (mAudioTrack != null) {
mAudioTrack.flush();
}
mMediaCodec.flush();
} catch(IllegalStateException e) {
Log.e(TAG, "Failed to flush MediaCodec " + e.toString());
return MEDIA_CODEC_ERROR;
}
return MEDIA_CODEC_OK;
}

@CalledByNative
Expand Down
5 changes: 3 additions & 2 deletions media/base/android/media_codec_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ void MediaCodecBridge::StartInternal() {
GetOutputBuffers();
}

void MediaCodecBridge::Reset() {
MediaCodecStatus MediaCodecBridge::Reset() {
JNIEnv* env = AttachCurrentThread();
Java_MediaCodecBridge_flush(env, j_media_codec_.obj());
return static_cast<MediaCodecStatus>(
Java_MediaCodecBridge_flush(env, j_media_codec_.obj()));
}

void MediaCodecBridge::Stop() {
Expand Down
4 changes: 3 additions & 1 deletion media/base/android/media_codec_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class MEDIA_EXPORT MediaCodecBridge {
// DequeueInputBuffer() and DequeueOutputBuffer() become invalid.
// Please note that this clears all the inputs in the media codec. In other
// words, there will be no outputs until new input is provided.
void Reset();
// Returns MEDIA_CODEC_ERROR if an unexpected error happens, or Media_CODEC_OK
// otherwise.
MediaCodecStatus Reset();

// Finishes the decode/encode session. The instance remains active
// and ready to be StartAudio/Video()ed again. HOWEVER, due to the buggy
Expand Down
6 changes: 5 additions & 1 deletion media/base/android/media_decoder_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ void MediaDecoderJob::DecodeInternal(
if (needs_flush) {
DVLOG(1) << "DecodeInternal needs flush.";
input_eos_encountered_ = false;
media_codec_bridge_->Reset();
MediaCodecStatus reset_status = media_codec_bridge_->Reset();
if (MEDIA_CODEC_OK != reset_status) {
callback.Run(reset_status, start_presentation_timestamp, 0);
return;
}
}

MediaCodecStatus input_status = MEDIA_CODEC_INPUT_END_OF_STREAM;
Expand Down

0 comments on commit f011974

Please sign in to comment.