Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 1885073004: Merge M51: "Disable idle suspend for GpuVideoDecoder produced frames on OSX, Win." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/filters/gpu_video_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), 197 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged),
198 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), 198 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))),
199 is_cdm_attached_(false), 199 is_cdm_attached_(false),
200 #if defined(OS_ANDROID) // WMPI_CAST 200 #if defined(OS_ANDROID) // WMPI_CAST
201 cast_impl_(this, client_, params.context_3d_cb()), 201 cast_impl_(this, client_, params.context_3d_cb()),
202 #endif 202 #endif
203 volume_(1.0), 203 volume_(1.0),
204 volume_multiplier_(1.0), 204 volume_multiplier_(1.0),
205 renderer_factory_(std::move(renderer_factory)), 205 renderer_factory_(std::move(renderer_factory)),
206 surface_manager_(params.surface_manager()), 206 surface_manager_(params.surface_manager()),
207 suppress_destruction_errors_(false) { 207 suppress_destruction_errors_(false),
208 can_suspend_state_(CanSuspendState::UNKNOWN) {
208 DCHECK(!adjust_allocated_memory_cb_.is_null()); 209 DCHECK(!adjust_allocated_memory_cb_.is_null());
209 DCHECK(renderer_factory_); 210 DCHECK(renderer_factory_);
210 DCHECK(client_); 211 DCHECK(client_);
211 212
212 if (delegate_) 213 if (delegate_)
213 delegate_id_ = delegate_->AddObserver(this); 214 delegate_id_ = delegate_->AddObserver(this);
214 215
215 media_log_->AddEvent( 216 media_log_->AddEvent(
216 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 217 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED));
217 218
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 1056
1056 void WebMediaPlayerImpl::OnShown() { 1057 void WebMediaPlayerImpl::OnShown() {
1057 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1058 DCHECK(main_task_runner_->BelongsToCurrentThread());
1058 must_suspend_ = false; 1059 must_suspend_ = false;
1059 UpdatePlayState(); 1060 UpdatePlayState();
1060 } 1061 }
1061 1062
1062 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) { 1063 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) {
1063 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1064 DCHECK(main_task_runner_->BelongsToCurrentThread());
1064 1065
1065 #if defined(OS_MACOSX)
1066 // TODO(sandersd): Idle suspend is disabled on OSX since hardware decoded
1067 // frames are owned by the video decoder in the GPU process. A mechanism for
1068 // detaching ownership from the decoder is needed. http://crbug.com/595716.
1069 return;
1070 #endif
1071
1072 if (must_suspend) { 1066 if (must_suspend) {
1073 must_suspend_ = true; 1067 must_suspend_ = true;
1074 } else { 1068 } else {
1075 // TODO(sandersd): Remove this when idleness is separate from play state. 1069 // TODO(sandersd): Remove this when idleness is separate from play state.
1076 if (delegate_state_ == DelegateState::PAUSED_BUT_NOT_IDLE) 1070 if (delegate_state_ == DelegateState::PAUSED_BUT_NOT_IDLE)
1077 return; 1071 return;
1078 is_idle_ = true; 1072 is_idle_ = true;
1079 } 1073 }
1080 1074
1081 UpdatePlayState(); 1075 UpdatePlayState();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 ReportMemoryUsage(); 1442 ReportMemoryUsage();
1449 } 1443 }
1450 } 1444 }
1451 1445
1452 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) { 1446 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) {
1453 // Do not change the state after an error has occurred. 1447 // Do not change the state after an error has occurred.
1454 // TODO(sandersd): Update PipelineController to remove the need for this. 1448 // TODO(sandersd): Update PipelineController to remove the need for this.
1455 if (IsNetworkStateError(network_state_)) 1449 if (IsNetworkStateError(network_state_))
1456 return; 1450 return;
1457 1451
1452 #if defined(OS_MACOSX) || defined(OS_WIN)
1453 // TODO(sandersd): Idle suspend is disabled on OSX and Windows for hardware
1454 // decoding / opaque video frames since these frames are owned by the decoder
1455 // in the GPU process. http://crbug.com/595716 and http://crbug.com/602708
1456 if (can_suspend_state_ == CanSuspendState::UNKNOWN) {
1457 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor();
1458 if (frame) {
1459 can_suspend_state_ =
1460 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME)
1461 ? CanSuspendState::NO
1462 : CanSuspendState::YES;
1463 }
1464 }
1465 #else
1466 can_suspend_state_ = CanSuspendState::YES;
1467 #endif
1468
1469 if (can_suspend_state_ == CanSuspendState::NO)
1470 return;
1471
1458 if (is_suspended) { 1472 if (is_suspended) {
1459 pipeline_controller_.Suspend(); 1473 pipeline_controller_.Suspend();
1460 } else { 1474 } else {
1461 pipeline_controller_.Resume(); 1475 pipeline_controller_.Resume();
1462 } 1476 }
1463 } 1477 }
1464 1478
1465 WebMediaPlayerImpl::PlayState 1479 WebMediaPlayerImpl::PlayState
1466 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote, 1480 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote,
1467 bool is_backgrounded) { 1481 bool is_backgrounded) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1589 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1576 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1590 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1577 << ", Demuxer: " << demuxer_memory_usage; 1591 << ", Demuxer: " << demuxer_memory_usage;
1578 1592
1579 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1593 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1580 last_reported_memory_usage_ = current_memory_usage; 1594 last_reported_memory_usage_ = current_memory_usage;
1581 adjust_allocated_memory_cb_.Run(delta); 1595 adjust_allocated_memory_cb_.Run(delta);
1582 } 1596 }
1583 1597
1584 } // namespace media 1598 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/filters/gpu_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698