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 85ffd545d87877f787ca8d3a13fc55c1408460bd..1bcec5fa66dbea77feba05448a63d3747912b9c3 100644 |
| --- a/media/base/android/media_source_player.cc |
| +++ b/media/base/android/media_source_player.cc |
| @@ -194,6 +194,8 @@ void MediaSourcePlayer::Release() { |
| playing_ = false; |
| decoder_starvation_callback_.Cancel(); |
| + |
| + SetAudible(false); |
| DetachListener(); |
| } |
| @@ -238,6 +240,7 @@ void MediaSourcePlayer::OnDemuxerConfigsAvailable( |
| const DemuxerConfigs& configs) { |
| DVLOG(1) << __FUNCTION__; |
| DCHECK(!HasAudio() && !HasVideo()); |
| + |
| duration_ = configs.duration; |
| audio_decoder_job_->SetDemuxerConfigs(configs); |
| @@ -399,6 +402,7 @@ void MediaSourcePlayer::ProcessPendingEvents() { |
| if (IsEventPending(PREFETCH_REQUEST_EVENT_PENDING)) { |
| DVLOG(1) << __FUNCTION__ << " : Handling PREFETCH_REQUEST_EVENT."; |
| + |
| int count = (AudioFinished() ? 0 : 1) + (VideoFinished() ? 0 : 1); |
| // It is possible that all streams have finished decode, yet starvation |
| @@ -493,12 +497,18 @@ void MediaSourcePlayer::MediaDecoderCallback( |
| return; |
| } |
| - if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) |
| + if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) { |
| + if (is_audio) |
| + SetAudible(false); |
| return; |
| + } |
| if (!playing_) { |
| if (is_clock_manager) |
| interpolator_.StopInterpolating(); |
| + |
| + if (is_audio) |
| + SetAudible(false); |
| return; |
| } |
| @@ -526,8 +536,11 @@ void MediaSourcePlayer::MediaDecoderCallback( |
| // If the status is MEDIA_CODEC_ABORT, stop decoding new data. The player is |
| // in the middle of a seek or stop event and needs to wait for the IPCs to |
| // come. |
| - if (status == MEDIA_CODEC_ABORT) |
| + if (status == MEDIA_CODEC_ABORT) { |
| + if (is_audio) |
| + SetAudible(false); |
| return; |
| + } |
| if (prerolling_ && IsPrerollFinished(is_audio)) { |
| if (IsPrerollFinished(!is_audio)) { |
| @@ -537,6 +550,13 @@ void MediaSourcePlayer::MediaDecoderCallback( |
| return; |
| } |
| + // We successfully decoded a frame and going to the next one. |
| + // Set the audible state. |
| + if (is_audio) { |
| + bool is_audible = !prerolling_ && audio_decoder_job_->GetVolume() > 0; |
| + SetAudible(is_audible); |
| + } |
| + |
| if (is_clock_manager) { |
| // If we have a valid timestamp, start the starvation callback. Otherwise, |
| // reset the |start_time_ticks_| so that the next frame will not suffer |
| @@ -648,6 +668,15 @@ bool MediaSourcePlayer::VideoFinished() { |
| void MediaSourcePlayer::OnDecoderStarved() { |
| DVLOG(1) << __FUNCTION__; |
| + |
| + if (HasAudio()) { |
| + // If the starvation timer fired but there are no encoded frames |
| + // in the queue we believe the demuxer (i.e. renderer process) froze. |
| + if (!audio_decoder_job_->HasData()) { |
|
qinmin
2015/03/24 21:38:37
no {} needed
Tima Vaisburd
2015/03/24 22:24:50
Done.
|
| + SetAudible(false); |
| + } |
| + } |
| + |
| SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING); |
| ProcessPendingEvents(); |
| } |