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

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

Issue 1972783003: Disable idle suspend for Chromecast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify suspend state logic, and rebase Created 4 years, 7 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
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::OnOpacityChanged))), 197 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))),
198 is_cdm_attached_(false), 198 is_cdm_attached_(false),
199 #if defined(OS_ANDROID) // WMPI_CAST 199 #if defined(OS_ANDROID) // WMPI_CAST
200 cast_impl_(this, client_, params.context_3d_cb()), 200 cast_impl_(this, client_, params.context_3d_cb()),
201 #endif 201 #endif
202 volume_(1.0), 202 volume_(1.0),
203 volume_multiplier_(1.0), 203 volume_multiplier_(1.0),
204 renderer_factory_(std::move(renderer_factory)), 204 renderer_factory_(std::move(renderer_factory)),
205 surface_manager_(params.surface_manager()), 205 surface_manager_(params.surface_manager()),
206 suppress_destruction_errors_(false), 206 suppress_destruction_errors_(false),
207 can_suspend_state_(CanSuspendState::UNKNOWN) { 207 can_suspend_state_(params.allow_idle_suspend() ? CanSuspendState::UNKNOWN
208 : CanSuspendState::NO) {
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 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 ReportMemoryUsage(); 1452 ReportMemoryUsage();
1452 } 1453 }
1453 } 1454 }
1454 1455
1455 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) { 1456 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) {
1456 // Do not change the state after an error has occurred. 1457 // Do not change the state after an error has occurred.
1457 // TODO(sandersd): Update PipelineController to remove the need for this. 1458 // TODO(sandersd): Update PipelineController to remove the need for this.
1458 if (IsNetworkStateError(network_state_)) 1459 if (IsNetworkStateError(network_state_))
1459 return; 1460 return;
1460 1461
1462 if (can_suspend_state_ == CanSuspendState::UNKNOWN) {
1461 #if defined(OS_MACOSX) || defined(OS_WIN) 1463 #if defined(OS_MACOSX) || defined(OS_WIN)
1462 // TODO(sandersd): Idle suspend is disabled on OSX and Windows for hardware 1464 // TODO(sandersd): Idle suspend is disabled on OSX and Windows for hardware
1463 // decoding / opaque video frames since these frames are owned by the decoder 1465 // decoding / opaque video frames since these frames are owned by the
1464 // in the GPU process. http://crbug.com/595716 and http://crbug.com/602708 1466 // decoder in the GPU process. http://crbug.com/595716 and
1465 if (can_suspend_state_ == CanSuspendState::UNKNOWN) { 1467 // http://crbug.com/602708
1466 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor(); 1468 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor();
1467 if (frame) { 1469 if (frame) {
1468 can_suspend_state_ = 1470 can_suspend_state_ =
1469 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME) 1471 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME)
1470 ? CanSuspendState::NO 1472 ? CanSuspendState::NO
1471 : CanSuspendState::YES; 1473 : CanSuspendState::YES;
1472 } 1474 }
1475 #else
1476 can_suspend_state_ = CanSuspendState::YES;
1477 #endif
1473 } 1478 }
1474 #else
1475 can_suspend_state_ = CanSuspendState::YES;
1476 #endif
1477 1479
1478 if (can_suspend_state_ == CanSuspendState::NO) 1480 if (can_suspend_state_ == CanSuspendState::NO)
1479 return; 1481 return;
1480 1482
1481 if (is_suspended) { 1483 if (is_suspended) {
1482 pipeline_controller_.Suspend(); 1484 pipeline_controller_.Suspend();
1483 } else { 1485 } else {
1484 pipeline_controller_.Resume(); 1486 pipeline_controller_.Resume();
1485 } 1487 }
1486 } 1488 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1600 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1599 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1601 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1600 << ", Demuxer: " << demuxer_memory_usage; 1602 << ", Demuxer: " << demuxer_memory_usage;
1601 1603
1602 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1604 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1603 last_reported_memory_usage_ = current_memory_usage; 1605 last_reported_memory_usage_ = current_memory_usage;
1604 adjust_allocated_memory_cb_.Run(delta); 1606 adjust_allocated_memory_cb_.Run(delta);
1605 } 1607 }
1606 1608
1607 } // namespace media 1609 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698