Chromium Code Reviews| 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 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream( | 149 AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream( |
|
DaleCurtis
2016/05/19 20:34:37
Just bind this directly to the audio log, since it
Henrik Grunell
2016/05/23 17:13:55
Good point, done.
| |
| 150 params_, device_id_); | 150 params_, device_id_, |
| 151 base::Bind(&AudioOutputDispatcherImpl::OnStatistics, this)); | |
| 151 if (!stream) | 152 if (!stream) |
| 152 return false; | 153 return false; |
| 153 | 154 |
| 154 if (!stream->Open()) { | 155 if (!stream->Open()) { |
| 155 stream->Close(); | 156 stream->Close(); |
| 156 return false; | 157 return false; |
| 157 } | 158 } |
| 158 | 159 |
| 159 const int stream_id = audio_stream_id_++; | 160 const int stream_id = audio_stream_id_++; |
| 160 audio_stream_ids_[stream] = stream_id; | 161 audio_stream_ids_[stream] = stream_id; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 179 stream->Close(); | 180 stream->Close(); |
| 180 | 181 |
| 181 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); | 182 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); |
| 182 DCHECK(it != audio_stream_ids_.end()); | 183 DCHECK(it != audio_stream_ids_.end()); |
| 183 audio_log_->OnClosed(it->second); | 184 audio_log_->OnClosed(it->second); |
| 184 audio_stream_ids_.erase(it); | 185 audio_stream_ids_.erase(it); |
| 185 } | 186 } |
| 186 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); | 187 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); |
| 187 } | 188 } |
| 188 | 189 |
| 190 void AudioOutputDispatcherImpl::OnStatistics(AudioOutputStream* physical_stream, | |
| 191 const std::string& name, | |
| 192 int value) { | |
| 193 auto it = audio_stream_ids_.find(physical_stream); | |
|
o1ka
2016/05/18 14:00:17
Is there a guarantee that access to |audio_stream_
Henrik Grunell
2016/05/23 17:13:55
This function has been removed.
| |
| 194 DCHECK(it != audio_stream_ids_.end()); | |
| 195 audio_log_->OnStatistics(it->second, name, value); | |
| 196 } | |
| 197 | |
| 189 } // namespace media | 198 } // namespace media |
| OLD | NEW |