| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 << "Active proxy streams during shutdown: " | 139 << "Active proxy streams during shutdown: " |
| 140 << proxy_to_physical_map_.size(); | 140 << proxy_to_physical_map_.size(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool AudioOutputDispatcherImpl::HasOutputProxies() const { | 143 bool AudioOutputDispatcherImpl::HasOutputProxies() const { |
| 144 return idle_proxies_ || !proxy_to_physical_map_.empty(); | 144 return idle_proxies_ || !proxy_to_physical_map_.empty(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool AudioOutputDispatcherImpl::CreateAndOpenStream() { | 147 bool AudioOutputDispatcherImpl::CreateAndOpenStream() { |
| 148 DCHECK(task_runner_->BelongsToCurrentThread()); | 148 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 149 | |
| 150 const int stream_id = audio_stream_id_++; | |
| 151 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream( | 149 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream( |
| 152 params_, device_id_, | 150 params_, device_id_); |
| 153 base::Bind(&AudioLog::OnLogMessage, base::Unretained(audio_log_.get()), | |
| 154 stream_id)); | |
| 155 if (!stream) | 151 if (!stream) |
| 156 return false; | 152 return false; |
| 157 | 153 |
| 158 if (!stream->Open()) { | 154 if (!stream->Open()) { |
| 159 stream->Close(); | 155 stream->Close(); |
| 160 return false; | 156 return false; |
| 161 } | 157 } |
| 162 | 158 |
| 159 const int stream_id = audio_stream_id_++; |
| 163 audio_stream_ids_[stream] = stream_id; | 160 audio_stream_ids_[stream] = stream_id; |
| 164 audio_log_->OnCreated( | 161 audio_log_->OnCreated( |
| 165 stream_id, params_, device_id_); | 162 stream_id, params_, device_id_); |
| 166 | 163 |
| 167 idle_streams_.push_back(stream); | 164 idle_streams_.push_back(stream); |
| 168 return true; | 165 return true; |
| 169 } | 166 } |
| 170 | 167 |
| 171 void AudioOutputDispatcherImpl::CloseAllIdleStreams() { | 168 void AudioOutputDispatcherImpl::CloseAllIdleStreams() { |
| 172 DCHECK(task_runner_->BelongsToCurrentThread()); | 169 DCHECK(task_runner_->BelongsToCurrentThread()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 183 | 180 |
| 184 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); | 181 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); |
| 185 DCHECK(it != audio_stream_ids_.end()); | 182 DCHECK(it != audio_stream_ids_.end()); |
| 186 audio_log_->OnClosed(it->second); | 183 audio_log_->OnClosed(it->second); |
| 187 audio_stream_ids_.erase(it); | 184 audio_stream_ids_.erase(it); |
| 188 } | 185 } |
| 189 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); | 186 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); |
| 190 } | 187 } |
| 191 | 188 |
| 192 } // namespace media | 189 } // namespace media |
| OLD | NEW |