| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "extensions/browser/api/audio/audio_service.h" | 5 #include "extensions/browser/api/audio/audio_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 void AudioServiceImpl::OnActiveOutputNodeChanged() { | 216 void AudioServiceImpl::OnActiveOutputNodeChanged() { |
| 217 NotifyDeviceChanged(); | 217 NotifyDeviceChanged(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void AudioServiceImpl::OnActiveInputNodeChanged() { | 220 void AudioServiceImpl::OnActiveInputNodeChanged() { |
| 221 NotifyDeviceChanged(); | 221 NotifyDeviceChanged(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void AudioServiceImpl::NotifyDeviceChanged() { | 224 void AudioServiceImpl::NotifyDeviceChanged() { |
| 225 FOR_EACH_OBSERVER(AudioService::Observer, observer_list_, OnDeviceChanged()); | 225 for (auto& observer : observer_list_) |
| 226 observer.OnDeviceChanged(); |
| 226 } | 227 } |
| 227 | 228 |
| 228 void AudioServiceImpl::NotifyLevelChanged(uint64_t id, int level) { | 229 void AudioServiceImpl::NotifyLevelChanged(uint64_t id, int level) { |
| 229 FOR_EACH_OBSERVER(AudioService::Observer, observer_list_, | 230 for (auto& observer : observer_list_) |
| 230 OnLevelChanged(base::Uint64ToString(id), level)); | 231 observer.OnLevelChanged(base::Uint64ToString(id), level); |
| 231 | 232 |
| 232 // Notify DeviceChanged event for backward compatibility. | 233 // Notify DeviceChanged event for backward compatibility. |
| 233 // TODO(jennyz): remove this code when the old version of hotrod retires. | 234 // TODO(jennyz): remove this code when the old version of hotrod retires. |
| 234 NotifyDeviceChanged(); | 235 NotifyDeviceChanged(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 void AudioServiceImpl::NotifyMuteChanged(bool is_input, bool is_muted) { | 238 void AudioServiceImpl::NotifyMuteChanged(bool is_input, bool is_muted) { |
| 238 FOR_EACH_OBSERVER(AudioService::Observer, observer_list_, | 239 for (auto& observer : observer_list_) |
| 239 OnMuteChanged(is_input, is_muted)); | 240 observer.OnMuteChanged(is_input, is_muted); |
| 240 | 241 |
| 241 // Notify DeviceChanged event for backward compatibility. | 242 // Notify DeviceChanged event for backward compatibility. |
| 242 // TODO(jennyz): remove this code when the old version of hotrod retires. | 243 // TODO(jennyz): remove this code when the old version of hotrod retires. |
| 243 NotifyDeviceChanged(); | 244 NotifyDeviceChanged(); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void AudioServiceImpl::NotifyDevicesChanged() { | 247 void AudioServiceImpl::NotifyDevicesChanged() { |
| 247 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 248 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 248 DCHECK(cras_audio_handler_); | 249 DCHECK(cras_audio_handler_); |
| 249 | 250 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 266 devices[i].is_input | 267 devices[i].is_input |
| 267 ? cras_audio_handler_->GetOutputVolumePercentForDevice( | 268 ? cras_audio_handler_->GetOutputVolumePercentForDevice( |
| 268 devices[i].id) | 269 devices[i].id) |
| 269 : cras_audio_handler_->GetInputGainPercentForDevice(devices[i].id); | 270 : cras_audio_handler_->GetInputGainPercentForDevice(devices[i].id); |
| 270 info.stable_device_id.reset( | 271 info.stable_device_id.reset( |
| 271 new std::string(base::Uint64ToString(devices[i].stable_device_id))); | 272 new std::string(base::Uint64ToString(devices[i].stable_device_id))); |
| 272 | 273 |
| 273 devices_info_list.push_back(std::move(info)); | 274 devices_info_list.push_back(std::move(info)); |
| 274 } | 275 } |
| 275 | 276 |
| 276 FOR_EACH_OBSERVER(AudioService::Observer, observer_list_, | 277 for (auto& observer : observer_list_) |
| 277 OnDevicesChanged(devices_info_list)); | 278 observer.OnDevicesChanged(devices_info_list); |
| 278 | 279 |
| 279 // Notify DeviceChanged event for backward compatibility. | 280 // Notify DeviceChanged event for backward compatibility. |
| 280 // TODO(jennyz): remove this code when the old version of hotrod retires. | 281 // TODO(jennyz): remove this code when the old version of hotrod retires. |
| 281 NotifyDeviceChanged(); | 282 NotifyDeviceChanged(); |
| 282 } | 283 } |
| 283 | 284 |
| 284 AudioService* AudioService::CreateInstance() { | 285 AudioService* AudioService::CreateInstance() { |
| 285 return new AudioServiceImpl; | 286 return new AudioServiceImpl; |
| 286 } | 287 } |
| 287 | 288 |
| 288 } // namespace extensions | 289 } // namespace extensions |
| OLD | NEW |