| 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 #include "media/audio/audio_output_dispatcher.h" | 5 #include "media/audio/audio_output_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
| 11 | 11 |
| 12 AudioOutputDispatcher::AudioOutputDispatcher( | 12 AudioOutputDispatcher::AudioOutputDispatcher( |
| 13 AudioManager* audio_manager, const AudioParameters& params, | 13 AudioManager* audio_manager, const AudioParameters& params, |
| 14 int close_delay_ms) | 14 int close_delay_ms) |
| 15 : audio_manager_(audio_manager), | 15 : audio_manager_(audio_manager), |
| 16 message_loop_(audio_manager->GetMessageLoop()), | 16 message_loop_(audio_manager->GetMessageLoop()), |
| 17 params_(params), | 17 params_(params), |
| 18 pause_delay_milliseconds_(2 * params.samples_per_packet * | 18 pause_delay_milliseconds_(2 * params.samples_per_packet * |
| 19 base::Time::kMillisecondsPerSecond / params.sample_rate), | 19 base::Time::kMillisecondsPerSecond / params.sample_rate), |
| 20 paused_proxies_(0), | 20 paused_proxies_(0), |
| 21 ALLOW_THIS_IN_INITIALIZER_LIST(close_timer_(FROM_HERE, | 21 ALLOW_THIS_IN_INITIALIZER_LIST(close_timer_( |
| 22 base::TimeDelta::FromMilliseconds(close_delay_ms), | 22 base::TimeDelta::FromMilliseconds(close_delay_ms), |
| 23 this, &AudioOutputDispatcher::ClosePendingStreams)) { | 23 this, &AudioOutputDispatcher::ClosePendingStreams)) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 AudioOutputDispatcher::~AudioOutputDispatcher() { | 26 AudioOutputDispatcher::~AudioOutputDispatcher() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool AudioOutputDispatcher::StreamOpened() { | 29 bool AudioOutputDispatcher::StreamOpened() { |
| 30 DCHECK_EQ(MessageLoop::current(), message_loop_); | 30 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 31 paused_proxies_++; | 31 paused_proxies_++; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 close_timer_.Reset(); | 131 close_timer_.Reset(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // This method is called by |close_timer_|. | 134 // This method is called by |close_timer_|. |
| 135 void AudioOutputDispatcher::ClosePendingStreams() { | 135 void AudioOutputDispatcher::ClosePendingStreams() { |
| 136 while (!idle_streams_.empty()) { | 136 while (!idle_streams_.empty()) { |
| 137 idle_streams_.back()->Close(); | 137 idle_streams_.back()->Close(); |
| 138 idle_streams_.pop_back(); | 138 idle_streams_.pop_back(); |
| 139 } | 139 } |
| 140 } | 140 } |
| OLD | NEW |