| 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/audio/audio_output_dispatcher_impl.h" | 5 #include "media/audio/audio_output_dispatcher_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 close_timer_.Reset(); | 54 close_timer_.Reset(); |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool AudioOutputDispatcherImpl::StartStream( | 58 bool AudioOutputDispatcherImpl::StartStream( |
| 59 AudioOutputStream::AudioSourceCallback* callback, | 59 AudioOutputStream::AudioSourceCallback* callback, |
| 60 AudioOutputProxy* stream_proxy) { | 60 AudioOutputProxy* stream_proxy) { |
| 61 DCHECK(message_loop_->BelongsToCurrentThread()); | 61 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 62 DCHECK(proxy_to_physical_map_.find(stream_proxy) == | |
| 63 proxy_to_physical_map_.end()); | |
| 64 | 62 |
| 65 if (idle_streams_.empty() && !CreateAndOpenStream()) | 63 if (idle_streams_.empty() && !CreateAndOpenStream()) |
| 66 return false; | 64 return false; |
| 67 | 65 |
| 68 AudioOutputStream* physical_stream = idle_streams_.back(); | 66 AudioOutputStream* physical_stream = idle_streams_.back(); |
| 69 DCHECK(physical_stream); | 67 DCHECK(physical_stream); |
| 70 idle_streams_.pop_back(); | 68 idle_streams_.pop_back(); |
| 71 | 69 |
| 72 DCHECK_GT(paused_proxies_, 0u); | 70 DCHECK_GT(paused_proxies_, 0u); |
| 73 --paused_proxies_; | 71 --paused_proxies_; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 179 |
| 182 // This method is called by |close_timer_|. | 180 // This method is called by |close_timer_|. |
| 183 void AudioOutputDispatcherImpl::ClosePendingStreams() { | 181 void AudioOutputDispatcherImpl::ClosePendingStreams() { |
| 184 DCHECK(message_loop_->BelongsToCurrentThread()); | 182 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 185 while (!idle_streams_.empty()) { | 183 while (!idle_streams_.empty()) { |
| 186 idle_streams_.back()->Close(); | 184 idle_streams_.back()->Close(); |
| 187 idle_streams_.pop_back(); | 185 idle_streams_.pop_back(); |
| 188 } | 186 } |
| 189 } | 187 } |
| 190 | 188 |
| 191 void AudioOutputDispatcherImpl::CloseStreamsForWedgeFix() { | |
| 192 DCHECK(message_loop_->BelongsToCurrentThread()); | |
| 193 while (!pausing_streams_.empty()) { | |
| 194 idle_streams_.push_back(pausing_streams_.back()); | |
| 195 pausing_streams_.pop_back(); | |
| 196 } | |
| 197 ClosePendingStreams(); | |
| 198 } | |
| 199 | |
| 200 void AudioOutputDispatcherImpl::RestartStreamsForWedgeFix() { | |
| 201 DCHECK(message_loop_->BelongsToCurrentThread()); | |
| 202 | |
| 203 // Should only be called when the dispatcher is used with fake streams which | |
| 204 // don't need to be shutdown or restarted. | |
| 205 CHECK_EQ(params_.format(), AudioParameters::AUDIO_FAKE); | |
| 206 } | |
| 207 | |
| 208 } // namespace media | 189 } // namespace media |
| OLD | NEW |