| OLD | NEW |
| 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 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 ReportMemoryUsage(); | 1463 ReportMemoryUsage(); |
| 1464 } | 1464 } |
| 1465 } | 1465 } |
| 1466 | 1466 |
| 1467 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) { | 1467 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) { |
| 1468 // Do not change the state after an error has occurred. | 1468 // Do not change the state after an error has occurred. |
| 1469 // TODO(sandersd): Update PipelineController to remove the need for this. | 1469 // TODO(sandersd): Update PipelineController to remove the need for this. |
| 1470 if (IsNetworkStateError(network_state_)) | 1470 if (IsNetworkStateError(network_state_)) |
| 1471 return; | 1471 return; |
| 1472 | 1472 |
| 1473 #if defined(OS_MACOSX) || defined(OS_WIN) | 1473 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 1474 // TODO(sandersd): Idle suspend is disabled on OSX and Windows for hardware | 1474 // TODO(sandersd): idle suspend is disabled if decoder owns video frame. |
| 1475 // decoding / opaque video frames since these frames are owned by the decoder | 1475 // Used on OSX,Windows+Chromecast. Since GetCurrentFrameFromCompositor is |
| 1476 // in the GPU process. http://crbug.com/595716 and http://crbug.com/602708 | 1476 // a synchronous cross-thread post, avoid the cost on platforms that |
| 1477 // always allow suspend. Need to find a better mechanism for this. See |
| 1478 // http://crbug.com/595716 and http://crbug.com/602708 |
| 1477 if (can_suspend_state_ == CanSuspendState::UNKNOWN) { | 1479 if (can_suspend_state_ == CanSuspendState::UNKNOWN) { |
| 1478 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor(); | 1480 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor(); |
| 1479 if (frame) { | 1481 if (frame) { |
| 1480 can_suspend_state_ = | 1482 can_suspend_state_ = |
| 1481 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME) | 1483 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME) |
| 1482 ? CanSuspendState::NO | 1484 ? CanSuspendState::NO |
| 1483 : CanSuspendState::YES; | 1485 : CanSuspendState::YES; |
| 1484 } | 1486 } |
| 1485 } | 1487 } |
| 1486 #else | 1488 #else |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1612 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
| 1611 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1613 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
| 1612 << ", Demuxer: " << demuxer_memory_usage; | 1614 << ", Demuxer: " << demuxer_memory_usage; |
| 1613 | 1615 |
| 1614 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1616 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
| 1615 last_reported_memory_usage_ = current_memory_usage; | 1617 last_reported_memory_usage_ = current_memory_usage; |
| 1616 adjust_allocated_memory_cb_.Run(delta); | 1618 adjust_allocated_memory_cb_.Run(delta); |
| 1617 } | 1619 } |
| 1618 | 1620 |
| 1619 } // namespace media | 1621 } // namespace media |
| OLD | NEW |