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

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

Issue 1879253002: Disable idle suspend for GpuVideoDecoder produced frames on OSX, Win. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Relocate. 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), 200 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged),
201 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), 201 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))),
202 is_cdm_attached_(false), 202 is_cdm_attached_(false),
203 #if defined(OS_ANDROID) // WMPI_CAST 203 #if defined(OS_ANDROID) // WMPI_CAST
204 cast_impl_(this, client_, params.context_3d_cb()), 204 cast_impl_(this, client_, params.context_3d_cb()),
205 #endif 205 #endif
206 volume_(1.0), 206 volume_(1.0),
207 volume_multiplier_(1.0), 207 volume_multiplier_(1.0),
208 renderer_factory_(std::move(renderer_factory)), 208 renderer_factory_(std::move(renderer_factory)),
209 surface_manager_(params.surface_manager()), 209 surface_manager_(params.surface_manager()),
210 suppress_destruction_errors_(false) { 210 suppress_destruction_errors_(false),
211 can_suspend_state_(CanSuspendState::UNKNOWN) {
211 DCHECK(!adjust_allocated_memory_cb_.is_null()); 212 DCHECK(!adjust_allocated_memory_cb_.is_null());
212 DCHECK(renderer_factory_); 213 DCHECK(renderer_factory_);
213 DCHECK(client_); 214 DCHECK(client_);
214 215
215 if (delegate_) 216 if (delegate_)
216 delegate_id_ = delegate_->AddObserver(this); 217 delegate_id_ = delegate_->AddObserver(this);
217 218
218 media_log_->AddEvent( 219 media_log_->AddEvent(
219 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 220 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED));
220 221
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 1073
1073 void WebMediaPlayerImpl::OnShown() { 1074 void WebMediaPlayerImpl::OnShown() {
1074 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1075 DCHECK(main_task_runner_->BelongsToCurrentThread());
1075 must_suspend_ = false; 1076 must_suspend_ = false;
1076 UpdatePlayState(); 1077 UpdatePlayState();
1077 } 1078 }
1078 1079
1079 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) { 1080 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) {
1080 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1081 DCHECK(main_task_runner_->BelongsToCurrentThread());
1081 1082
1082 #if defined(OS_MACOSX)
1083 // TODO(sandersd): Idle suspend is disabled on OSX since hardware decoded
1084 // frames are owned by the video decoder in the GPU process. A mechanism for
1085 // detaching ownership from the decoder is needed. http://crbug.com/595716.
1086 return;
1087 #endif
1088
1089 if (must_suspend) { 1083 if (must_suspend) {
1090 must_suspend_ = true; 1084 must_suspend_ = true;
1091 } else { 1085 } else {
1092 // TODO(sandersd): Remove this when idleness is separate from play state. 1086 // TODO(sandersd): Remove this when idleness is separate from play state.
1093 if (delegate_state_ == DelegateState::PAUSED_BUT_NOT_IDLE) 1087 if (delegate_state_ == DelegateState::PAUSED_BUT_NOT_IDLE)
1094 return; 1088 return;
1095 is_idle_ = true; 1089 is_idle_ = true;
1096 } 1090 }
1097 1091
1098 UpdatePlayState(); 1092 UpdatePlayState();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 ReportMemoryUsage(); 1459 ReportMemoryUsage();
1466 } 1460 }
1467 } 1461 }
1468 1462
1469 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) { 1463 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) {
1470 // Do not change the state after an error has occurred. 1464 // Do not change the state after an error has occurred.
1471 // TODO(sandersd): Update PipelineController to remove the need for this. 1465 // TODO(sandersd): Update PipelineController to remove the need for this.
1472 if (IsNetworkStateError(network_state_)) 1466 if (IsNetworkStateError(network_state_))
1473 return; 1467 return;
1474 1468
1469 #if defined(OS_MACOSX) || defined(OS_WIN)
1470 // TODO(sandersd): Idle suspend is disabled on OSX and Windows for hardware
1471 // decoding / opaque video frames since these frames are owned by the decoder
1472 // in the GPU process. http://crbug.com/595716 and http://crbug.com/602708
1473 if (can_suspend_state_ == CanSuspendState::UNKNOWN) {
1474 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor();
1475 if (frame) {
1476 can_suspend_state_ =
1477 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME)
1478 ? CanSuspendState::NO
1479 : CanSuspendState::YES;
1480 }
1481 }
1482 #else
1483 can_suspend_state_ = CanSuspendState::YES;
1484 #endif
1485
1486 if (can_suspend_state_ == CanSuspendState::NO)
1487 return;
1488
1475 if (is_suspended) { 1489 if (is_suspended) {
1476 pipeline_controller_.Suspend(); 1490 pipeline_controller_.Suspend();
1477 } else { 1491 } else {
1478 pipeline_controller_.Resume(); 1492 pipeline_controller_.Resume();
1479 } 1493 }
1480 } 1494 }
1481 1495
1482 WebMediaPlayerImpl::PlayState 1496 WebMediaPlayerImpl::PlayState
1483 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote, 1497 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote,
1484 bool is_backgrounded) { 1498 bool is_backgrounded) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1606 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1593 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1607 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1594 << ", Demuxer: " << demuxer_memory_usage; 1608 << ", Demuxer: " << demuxer_memory_usage;
1595 1609
1596 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1610 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1597 last_reported_memory_usage_ = current_memory_usage; 1611 last_reported_memory_usage_ = current_memory_usage;
1598 adjust_allocated_memory_cb_.Run(delta); 1612 adjust_allocated_memory_cb_.Run(delta);
1599 } 1613 }
1600 1614
1601 } // namespace media 1615 } // 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