Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/pipeline.h" | 5 #include "media/base/pipeline.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 base::AutoLock auto_lock(lock_); | 152 base::AutoLock auto_lock(lock_); |
| 153 volume_ = volume; | 153 volume_ = volume; |
| 154 if (running_) { | 154 if (running_) { |
| 155 task_runner_->PostTask( | 155 task_runner_->PostTask( |
| 156 FROM_HERE, | 156 FROM_HERE, |
| 157 base::Bind( | 157 base::Bind( |
| 158 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); | 158 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 void Pipeline::SwitchAudioOutputDevice( | |
| 163 const std::string& device_id, | |
| 164 const GURL& security_origin, | |
| 165 const base::Callback<void(int)>& callback) { | |
| 166 DVLOG(1) << __FUNCTION__; | |
| 167 base::AutoLock auto_lock(lock_); | |
| 168 if (running_) { | |
| 169 task_runner_->PostTask( | |
| 170 FROM_HERE, | |
| 171 base::Bind(&Pipeline::AudioOutputDeviceSwitchedTask, | |
| 172 weak_factory_.GetWeakPtr(), | |
| 173 device_id, | |
| 174 security_origin, | |
| 175 callback)); | |
| 176 } | |
| 177 } | |
| 178 | |
| 162 TimeDelta Pipeline::GetMediaTime() const { | 179 TimeDelta Pipeline::GetMediaTime() const { |
| 163 base::AutoLock auto_lock(lock_); | 180 base::AutoLock auto_lock(lock_); |
| 164 return renderer_ ? std::min(renderer_->GetMediaTime(), duration_) | 181 return renderer_ ? std::min(renderer_->GetMediaTime(), duration_) |
| 165 : TimeDelta(); | 182 : TimeDelta(); |
| 166 } | 183 } |
| 167 | 184 |
| 168 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { | 185 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { |
| 169 base::AutoLock auto_lock(lock_); | 186 base::AutoLock auto_lock(lock_); |
| 170 return buffered_time_ranges_; | 187 return buffered_time_ranges_; |
| 171 } | 188 } |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 void Pipeline::VolumeChangedTask(float volume) { | 582 void Pipeline::VolumeChangedTask(float volume) { |
| 566 DCHECK(task_runner_->BelongsToCurrentThread()); | 583 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 567 | 584 |
| 568 // Volume changes are only carried out while playing. | 585 // Volume changes are only carried out while playing. |
| 569 if (state_ != kPlaying) | 586 if (state_ != kPlaying) |
| 570 return; | 587 return; |
| 571 | 588 |
| 572 renderer_->SetVolume(volume); | 589 renderer_->SetVolume(volume); |
| 573 } | 590 } |
| 574 | 591 |
| 592 void Pipeline::AudioOutputDeviceSwitchedTask( | |
| 593 const std::string& device_id, | |
| 594 const GURL& security_origin, | |
| 595 const base::Callback<void(int)>& callback) { | |
| 596 DCHECK(task_runner_->BelongsToCurrentThread()); | |
| 597 DVLOG(1) << __FUNCTION__ << "(" << device_id << ", " | |
| 598 << security_origin << ")"; | |
| 599 | |
| 600 // TODO(guidou): Check if there are any values of state_ for which switching | |
|
miu
2015/06/03 21:01:01
Please do this in the current CL, or submit a crbu
| |
| 601 // audio output device makes no sense. | |
| 602 renderer_->SwitchAudioOutputDevice(device_id, security_origin, callback); | |
| 603 } | |
| 604 | |
| 575 void Pipeline::SeekTask(TimeDelta time, const PipelineStatusCB& seek_cb) { | 605 void Pipeline::SeekTask(TimeDelta time, const PipelineStatusCB& seek_cb) { |
| 576 DCHECK(task_runner_->BelongsToCurrentThread()); | 606 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 577 DCHECK(stop_cb_.is_null()); | 607 DCHECK(stop_cb_.is_null()); |
| 578 | 608 |
| 579 // Suppress seeking if we're not fully started. | 609 // Suppress seeking if we're not fully started. |
| 580 if (state_ != kPlaying) { | 610 if (state_ != kPlaying) { |
| 581 DCHECK(state_ == kStopping || state_ == kStopped) | 611 DCHECK(state_ == kStopping || state_ == kStopped) |
| 582 << "Receive extra seek in unexpected state: " << state_; | 612 << "Receive extra seek in unexpected state: " << state_; |
| 583 | 613 |
| 584 // TODO(scherkus): should we run the callback? I'm tempted to say the API | 614 // TODO(scherkus): should we run the callback? I'm tempted to say the API |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 732 metadata_cb_.Run(metadata); | 762 metadata_cb_.Run(metadata); |
| 733 } | 763 } |
| 734 | 764 |
| 735 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { | 765 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { |
| 736 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; | 766 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; |
| 737 DCHECK(task_runner_->BelongsToCurrentThread()); | 767 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 738 buffering_state_cb_.Run(new_buffering_state); | 768 buffering_state_cb_.Run(new_buffering_state); |
| 739 } | 769 } |
| 740 | 770 |
| 741 } // namespace media | 771 } // namespace media |
| OLD | NEW |