| Index: media/audio/audio_output_dispatcher_impl.cc
|
| diff --git a/media/audio/audio_output_dispatcher_impl.cc b/media/audio/audio_output_dispatcher_impl.cc
|
| index eaac8a4daae98c4e0167fe57da5c5d147aecf78a..53c9ce7fa9350e49c92ff196236fb8dcb5591507 100644
|
| --- a/media/audio/audio_output_dispatcher_impl.cc
|
| +++ b/media/audio/audio_output_dispatcher_impl.cc
|
| @@ -8,7 +8,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/compiler_specific.h"
|
| -#include "base/message_loop/message_loop.h"
|
| +#include "base/single_thread_task_runner.h"
|
| #include "base/time/time.h"
|
| #include "media/audio/audio_io.h"
|
| #include "media/audio/audio_output_proxy.h"
|
| @@ -21,8 +21,10 @@ AudioOutputDispatcherImpl::AudioOutputDispatcherImpl(
|
| const std::string& output_device_id,
|
| const std::string& input_device_id,
|
| const base::TimeDelta& close_delay)
|
| - : AudioOutputDispatcher(audio_manager, params, output_device_id,
|
| - input_device_id),
|
| + : AudioOutputDispatcher(audio_manager,
|
| + params,
|
| + output_device_id,
|
| + input_device_id),
|
| pause_delay_(base::TimeDelta::FromMicroseconds(
|
| 2 * params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
|
| static_cast<float>(params.sample_rate()))),
|
| @@ -31,8 +33,7 @@ AudioOutputDispatcherImpl::AudioOutputDispatcherImpl(
|
| close_timer_(FROM_HERE,
|
| close_delay,
|
| this,
|
| - &AudioOutputDispatcherImpl::ClosePendingStreams) {
|
| -}
|
| + &AudioOutputDispatcherImpl::ClosePendingStreams) {}
|
|
|
| AudioOutputDispatcherImpl::~AudioOutputDispatcherImpl() {
|
| DCHECK(proxy_to_physical_map_.empty());
|
| @@ -41,7 +42,7 @@ AudioOutputDispatcherImpl::~AudioOutputDispatcherImpl() {
|
| }
|
|
|
| bool AudioOutputDispatcherImpl::OpenStream() {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| paused_proxies_++;
|
|
|
| @@ -58,7 +59,7 @@ bool AudioOutputDispatcherImpl::OpenStream() {
|
| bool AudioOutputDispatcherImpl::StartStream(
|
| AudioOutputStream::AudioSourceCallback* callback,
|
| AudioOutputProxy* stream_proxy) {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| if (idle_streams_.empty() && !CreateAndOpenStream())
|
| return false;
|
| @@ -81,7 +82,7 @@ bool AudioOutputDispatcherImpl::StartStream(
|
| }
|
|
|
| void AudioOutputDispatcherImpl::StopStream(AudioOutputProxy* stream_proxy) {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| AudioStreamMap::iterator it = proxy_to_physical_map_.find(stream_proxy);
|
| DCHECK(it != proxy_to_physical_map_.end());
|
| @@ -95,7 +96,7 @@ void AudioOutputDispatcherImpl::StopStream(AudioOutputProxy* stream_proxy) {
|
| pausing_streams_.push_front(physical_stream);
|
|
|
| // Don't recycle stream until two buffers worth of time has elapsed.
|
| - message_loop_->PostDelayedTask(
|
| + task_runner_->PostDelayedTask(
|
| FROM_HERE,
|
| base::Bind(&AudioOutputDispatcherImpl::StopStreamTask,
|
| weak_this_.GetWeakPtr()),
|
| @@ -104,7 +105,7 @@ void AudioOutputDispatcherImpl::StopStream(AudioOutputProxy* stream_proxy) {
|
|
|
| void AudioOutputDispatcherImpl::StreamVolumeSet(AudioOutputProxy* stream_proxy,
|
| double volume) {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| AudioStreamMap::iterator it = proxy_to_physical_map_.find(stream_proxy);
|
| if (it != proxy_to_physical_map_.end()) {
|
| AudioOutputStream* physical_stream = it->second;
|
| @@ -113,7 +114,7 @@ void AudioOutputDispatcherImpl::StreamVolumeSet(AudioOutputProxy* stream_proxy,
|
| }
|
|
|
| void AudioOutputDispatcherImpl::StopStreamTask() {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| if (pausing_streams_.empty())
|
| return;
|
| @@ -125,7 +126,7 @@ void AudioOutputDispatcherImpl::StopStreamTask() {
|
| }
|
|
|
| void AudioOutputDispatcherImpl::CloseStream(AudioOutputProxy* stream_proxy) {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| while (!pausing_streams_.empty()) {
|
| idle_streams_.push_back(pausing_streams_.back());
|
| @@ -142,7 +143,7 @@ void AudioOutputDispatcherImpl::CloseStream(AudioOutputProxy* stream_proxy) {
|
| }
|
|
|
| void AudioOutputDispatcherImpl::Shutdown() {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| // Cancel any pending tasks to close paused streams or create new ones.
|
| weak_this_.InvalidateWeakPtrs();
|
| @@ -163,7 +164,7 @@ void AudioOutputDispatcherImpl::Shutdown() {
|
| }
|
|
|
| bool AudioOutputDispatcherImpl::CreateAndOpenStream() {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream(
|
| params_, output_device_id_, input_device_id_);
|
| if (!stream)
|
| @@ -179,7 +180,7 @@ bool AudioOutputDispatcherImpl::CreateAndOpenStream() {
|
|
|
| // This method is called by |close_timer_|.
|
| void AudioOutputDispatcherImpl::ClosePendingStreams() {
|
| - DCHECK(message_loop_->BelongsToCurrentThread());
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| while (!idle_streams_.empty()) {
|
| idle_streams_.back()->Close();
|
| idle_streams_.pop_back();
|
|
|