| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 // Close all idle streams immediately. The |close_timer_| will handle | 124 // Close all idle streams immediately. The |close_timer_| will handle |
| 125 // invalidating any outstanding tasks upon its destruction. | 125 // invalidating any outstanding tasks upon its destruction. |
| 126 CloseAllIdleStreams(); | 126 CloseAllIdleStreams(); |
| 127 | 127 |
| 128 // No AudioOutputProxy objects should hold a reference to us when we get | 128 // No AudioOutputProxy objects should hold a reference to us when we get |
| 129 // to this stage. | 129 // to this stage. |
| 130 DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference"; | 130 DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference"; |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool AudioOutputDispatcherImpl::HasOutputProxies() const { |
| 134 return idle_proxies_ || !proxy_to_physical_map_.empty(); |
| 135 } |
| 136 |
| 133 bool AudioOutputDispatcherImpl::CreateAndOpenStream() { | 137 bool AudioOutputDispatcherImpl::CreateAndOpenStream() { |
| 134 DCHECK(task_runner_->BelongsToCurrentThread()); | 138 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 135 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream( | 139 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream( |
| 136 params_, device_id_); | 140 params_, device_id_); |
| 137 if (!stream) | 141 if (!stream) |
| 138 return false; | 142 return false; |
| 139 | 143 |
| 140 if (!stream->Open()) { | 144 if (!stream->Open()) { |
| 141 stream->Close(); | 145 stream->Close(); |
| 142 return false; | 146 return false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 166 | 170 |
| 167 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); | 171 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); |
| 168 DCHECK(it != audio_stream_ids_.end()); | 172 DCHECK(it != audio_stream_ids_.end()); |
| 169 audio_log_->OnClosed(it->second); | 173 audio_log_->OnClosed(it->second); |
| 170 audio_stream_ids_.erase(it); | 174 audio_stream_ids_.erase(it); |
| 171 } | 175 } |
| 172 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); | 176 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); |
| 173 } | 177 } |
| 174 | 178 |
| 175 } // namespace media | 179 } // namespace media |
| OLD | NEW |