| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, | 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, |
| 6 // potential deadlocks, etc... | 6 // potential deadlocks, etc... |
| 7 | 7 |
| 8 #include "media/base/pipeline_impl.h" | 8 #include "media/base/pipeline_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 // We use audio stream to update the clock. So if there is such a stream, | 1039 // We use audio stream to update the clock. So if there is such a stream, |
| 1040 // we pause the clock until we receive a valid timestamp. | 1040 // we pause the clock until we receive a valid timestamp. |
| 1041 waiting_for_clock_update_ = has_audio_; | 1041 waiting_for_clock_update_ = has_audio_; |
| 1042 if (!waiting_for_clock_update_) | 1042 if (!waiting_for_clock_update_) |
| 1043 clock_->Play(); | 1043 clock_->Play(); |
| 1044 | 1044 |
| 1045 // Start monitoring rate of downloading. | 1045 // Start monitoring rate of downloading. |
| 1046 int bitrate = 0; | 1046 int bitrate = 0; |
| 1047 if (demuxer_.get()) | 1047 if (demuxer_.get()) |
| 1048 bitrate = demuxer_->GetBitrate(); | 1048 bitrate = demuxer_->GetBitrate(); |
| 1049 // Needs to be locked because most other calls to |download_rate_monitor_| | 1049 |
| 1050 // occur on the renderer thread. | 1050 if (bitrate == 0) { |
| 1051 download_rate_monitor_.Start( | 1051 OnCanPlayThrough(); |
| 1052 base::Bind(&PipelineImpl::OnCanPlayThrough, this), bitrate); | 1052 } else { |
| 1053 download_rate_monitor_.SetBufferedBytes(buffered_bytes_, base::Time::Now()); | 1053 // Needs to be locked because most other calls to |download_rate_monitor_| |
| 1054 // occur on the renderer thread. |
| 1055 download_rate_monitor_.Start( |
| 1056 base::Bind(&PipelineImpl::OnCanPlayThrough, this), bitrate); |
| 1057 download_rate_monitor_.SetBufferedBytes(buffered_bytes_, |
| 1058 base::Time::Now()); |
| 1059 } |
| 1054 | 1060 |
| 1055 if (IsPipelineStopPending()) { | 1061 if (IsPipelineStopPending()) { |
| 1056 // We had a pending stop request need to be honored right now. | 1062 // We had a pending stop request need to be honored right now. |
| 1057 TearDownPipeline(); | 1063 TearDownPipeline(); |
| 1058 } | 1064 } |
| 1059 } else { | 1065 } else { |
| 1060 NOTREACHED() << "Unexpected state: " << state_; | 1066 NOTREACHED() << "Unexpected state: " << state_; |
| 1061 } | 1067 } |
| 1062 } | 1068 } |
| 1063 | 1069 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 message_loop_->PostTask(FROM_HERE, | 1437 message_loop_->PostTask(FROM_HERE, |
| 1432 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); | 1438 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); |
| 1433 } | 1439 } |
| 1434 | 1440 |
| 1435 void PipelineImpl::NotifyCanPlayThrough() { | 1441 void PipelineImpl::NotifyCanPlayThrough() { |
| 1436 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1442 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 1437 NotifyNetworkEventTask(CAN_PLAY_THROUGH); | 1443 NotifyNetworkEventTask(CAN_PLAY_THROUGH); |
| 1438 } | 1444 } |
| 1439 | 1445 |
| 1440 } // namespace media | 1446 } // namespace media |
| OLD | NEW |