From 5f4ae9c1f8f2b9263cbc68a2e451ff6c13f8296c Mon Sep 17 00:00:00 2001 From: "acolwell@chromium.org" Date: Thu, 23 May 2013 14:27:19 +0000 Subject: Fix various MediaSource related crashes on Android. This change fixes several issues that were causing crashes. - MediaPlayerHostMsg_DemuxerReady_Params was not initializing the xxx_codec member variables so audio-only or video-only content would randomly be flagged as A/V content with a random codec ID. - ChunkDemuxer::Stop() was not being called which could cause the delegate to be accessed after it was destroyed. - MediaSourceDelegate was signalling that it had metadata before the ChunkDemuxer was even initialized. This caused the HTMLMediaElement to signal that the load completed way too early and caused play() to be called when the delegate wasn't ready. BUG=233420 TEST=webkitmediasource-play.html LayoutTest reliably runs w/o crashing now. Review URL: https://chromiumcodereview.appspot.com/15754004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201791 0039d316-1c4b-4281-b951-d872f2087c98 --- media/base/android/demuxer_stream_player_params.cc | 4 +++- media/base/android/media_source_player.cc | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'media/base') diff --git a/media/base/android/demuxer_stream_player_params.cc b/media/base/android/demuxer_stream_player_params.cc index ab9fcaf..3ed1a8c 100644 --- a/media/base/android/demuxer_stream_player_params.cc +++ b/media/base/android/demuxer_stream_player_params.cc @@ -8,9 +8,11 @@ namespace media { MediaPlayerHostMsg_DemuxerReady_Params:: MediaPlayerHostMsg_DemuxerReady_Params() - : audio_channels(0), + : audio_codec(kUnknownAudioCodec), + audio_channels(0), audio_sampling_rate(0), is_audio_encrypted(false), + video_codec(kUnknownVideoCodec), is_video_encrypted(false), duration_ms(0) {} diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc index b29d182..f6cbd48 100644 --- a/media/base/android/media_source_player.cc +++ b/media/base/android/media_source_player.cc @@ -208,7 +208,6 @@ MediaSourcePlayer::MediaSourcePlayer( waiting_for_audio_data_(false), waiting_for_video_data_(false), weak_this_(this) { - OnMediaMetadataChanged(duration_, width_, height_, false); } MediaSourcePlayer::~MediaSourcePlayer() { @@ -221,9 +220,11 @@ void MediaSourcePlayer::SetVideoSurface(jobject surface) { return; } - video_decoder_job_.reset(new VideoDecoderJob( - base::MessageLoopProxy::current(), video_codec_, - gfx::Size(width_, height_), surface)); + if (HasVideo()) { + video_decoder_job_.reset(new VideoDecoderJob( + base::MessageLoopProxy::current(), video_codec_, + gfx::Size(width_, height_), surface)); + } if (pending_play_) StartInternal(); -- cgit v1.1