Chromium Code Reviews| Index: media/base/android/media_source_player.cc |
| diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc |
| index 3d51a4a3dd163afb875dd8b8d365850ec967c468..1de2b2174844c6f9bad09edaabf4291d650b71a1 100644 |
| --- a/media/base/android/media_source_player.cc |
| +++ b/media/base/android/media_source_player.cc |
| @@ -73,8 +73,8 @@ MediaSourcePlayer::MediaSourcePlayer( |
| video_codec_(kUnknownVideoCodec), |
| num_channels_(0), |
| sampling_rate_(0), |
| - audio_finished_(true), |
| - video_finished_(true), |
| + audio_finished_(false), |
| + video_finished_(false), |
| playing_(false), |
| is_audio_encrypted_(false), |
| is_video_encrypted_(false), |
| @@ -318,8 +318,6 @@ void MediaSourcePlayer::StartInternal() { |
| return; |
| } |
| - audio_finished_ = false; |
| - video_finished_ = false; |
| SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING); |
| ProcessPendingEvents(); |
| } |
| @@ -404,8 +402,8 @@ void MediaSourcePlayer::SetDrmBridge(MediaDrmBridge* drm_bridge) { |
| // TODO(qinmin): support DRM change after playback has started. |
| // http://crbug.com/253792. |
| if (GetCurrentTime() > base::TimeDelta()) { |
| - LOG(INFO) << "Setting DRM bridge after playback has started. " |
| - << "This is not well supported!"; |
| + VLOG(0) << "Setting DRM bridge after playback has started. " |
| + << "This is not well supported!"; |
| } |
| drm_bridge_ = drm_bridge; |
| @@ -451,6 +449,9 @@ void MediaSourcePlayer::OnDemuxerSeekDone( |
| audio_timestamp_helper_->SetBaseTimestamp(actual_browser_seek_time); |
| } |
| + audio_finished_ = false; |
| + video_finished_ = false; |
| + |
| base::TimeDelta current_time = GetCurrentTime(); |
| // TODO(qinmin): Simplify the logic by using |start_presentation_timestamp_| |
| // to preroll media decoder jobs. Currently |start_presentation_timestamp_| |
| @@ -530,15 +531,16 @@ void MediaSourcePlayer::ProcessPendingEvents() { |
| if (IsEventPending(PREFETCH_REQUEST_EVENT_PENDING)) { |
| DVLOG(1) << __FUNCTION__ << " : Handling PREFETCH_REQUEST_EVENT."; |
| - int count = (audio_decoder_job_ ? 1 : 0) + (video_decoder_job_ ? 1 : 0); |
| + int count = ((audio_decoder_job_ && !audio_finished_) ? 1 : 0) + |
|
acolwell GONE FROM CHROMIUM
2013/11/25 21:43:59
I think the audio_decoder_ && !audio_finished_ con
wolenetz
2013/12/04 00:13:29
Done, with ternary swapped, as AudioFinishedOrNoAu
|
| + ((video_decoder_job_ && !video_finished_) ? 1 : 0); |
| base::Closure barrier = BarrierClosure(count, base::Bind( |
| &MediaSourcePlayer::OnPrefetchDone, weak_this_.GetWeakPtr())); |
| - if (audio_decoder_job_) |
| + if (audio_decoder_job_ && !audio_finished_) |
| audio_decoder_job_->Prefetch(barrier); |
| - if (video_decoder_job_) |
| + if (video_decoder_job_ && !video_finished_) |
| video_decoder_job_->Prefetch(barrier); |
| SetPendingEvent(PREFETCH_DONE_EVENT_PENDING); |
| @@ -643,6 +645,7 @@ void MediaSourcePlayer::MediaDecoderCallback( |
| void MediaSourcePlayer::DecodeMoreAudio() { |
| DVLOG(1) << __FUNCTION__; |
| DCHECK(!audio_decoder_job_->is_decoding()); |
| + DCHECK(!audio_finished_); |
| if (audio_decoder_job_->Decode( |
| start_time_ticks_, start_presentation_timestamp_, base::Bind( |
| @@ -672,6 +675,7 @@ void MediaSourcePlayer::DecodeMoreAudio() { |
| void MediaSourcePlayer::DecodeMoreVideo() { |
| DVLOG(1) << __FUNCTION__; |
| DCHECK(!video_decoder_job_->is_decoding()); |
| + DCHECK(!video_finished_); |
| if (video_decoder_job_->Decode( |
| start_time_ticks_, start_presentation_timestamp_, base::Bind( |
| @@ -916,9 +920,9 @@ void MediaSourcePlayer::OnPrefetchDone() { |
| if (!clock_.IsPlaying()) |
| clock_.Play(); |
| - if (audio_decoder_job_) |
| + if (audio_decoder_job_ && !audio_finished_) |
| DecodeMoreAudio(); |
| - if (video_decoder_job_) |
| + if (video_decoder_job_ && !video_finished_) |
| DecodeMoreVideo(); |
| } |