| 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..3dae525f29d947c69695fdb2b87a90592a2697f0 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;
|
| }
|
|
|
| @@ -507,6 +517,9 @@ void MediaSourcePlayer::MediaDecoderCallback(
|
| DVLOG(2) << __FUNCTION__ << ": Key was added during decoding.";
|
| ResumePlaybackAfterKeyAdded();
|
| } else {
|
| + if (is_audio)
|
| + SetAudible(false);
|
| +
|
| is_waiting_for_key_ = true;
|
| manager()->OnWaitingForDecryptionKey(player_id());
|
| }
|
| @@ -526,8 +539,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 +553,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_->volume() > 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 +671,14 @@ 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())
|
| + SetAudible(false);
|
| + }
|
| +
|
| SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING);
|
| ProcessPendingEvents();
|
| }
|
|
|