| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "content/browser/renderer_host/media/audio_output_device_enumerator.h" | 5 #include "content/browser/renderer_host/media/audio_output_device_enumerator.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "media/audio/audio_manager_base.h" | 12 #include "media/audio/audio_device_description.h" |
| 13 #include "media/audio/audio_manager.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 AudioOutputDeviceEnumeration EnumerateDevicesOnDeviceThread( | 19 AudioOutputDeviceEnumeration EnumerateDevicesOnDeviceThread( |
| 19 media::AudioManager* audio_manager) { | 20 media::AudioManager* audio_manager) { |
| 20 DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread()); | 21 DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread()); |
| 21 | 22 |
| 22 AudioOutputDeviceEnumeration snapshot; | 23 AudioOutputDeviceEnumeration snapshot; |
| 23 media::AudioDeviceNames device_names; | 24 media::AudioDeviceNames device_names; |
| 24 audio_manager->GetAudioOutputDeviceNames(&device_names); | 25 audio_manager->GetAudioOutputDeviceNames(&device_names); |
| 25 | 26 |
| 26 snapshot.has_actual_devices = !device_names.empty(); | 27 snapshot.has_actual_devices = !device_names.empty(); |
| 27 | 28 |
| 28 // If no devices in enumeration, return a list with a default device | 29 // If no devices in enumeration, return a list with a default device |
| 29 if (!snapshot.has_actual_devices) { | 30 if (!snapshot.has_actual_devices) { |
| 30 snapshot.devices.push_back( | 31 snapshot.devices.push_back( |
| 31 {media::AudioManagerBase::kDefaultDeviceId, | 32 {media::AudioDeviceDescription::kDefaultDeviceId, |
| 32 media::AudioManager::GetDefaultDeviceName(), | 33 media::AudioDeviceDescription::GetDefaultDeviceName(), |
| 33 audio_manager->GetDefaultOutputStreamParameters()}); | 34 audio_manager->GetDefaultOutputStreamParameters()}); |
| 34 return snapshot; | 35 return snapshot; |
| 35 } | 36 } |
| 36 | 37 |
| 37 for (const media::AudioDeviceName& name : device_names) { | 38 for (const media::AudioDeviceName& name : device_names) { |
| 38 snapshot.devices.push_back( | 39 snapshot.devices.push_back( |
| 39 {name.unique_id, name.device_name, | 40 {name.unique_id, name.device_name, |
| 40 name.unique_id == media::AudioManagerBase::kDefaultDeviceId | 41 name.unique_id == media::AudioDeviceDescription::kDefaultDeviceId |
| 41 ? audio_manager->GetDefaultOutputStreamParameters() | 42 ? audio_manager->GetDefaultOutputStreamParameters() |
| 42 : audio_manager->GetOutputStreamParameters(name.unique_id)}); | 43 : audio_manager->GetOutputStreamParameters(name.unique_id)}); |
| 43 } | 44 } |
| 44 return snapshot; | 45 return snapshot; |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace | 48 } // namespace |
| 48 | 49 |
| 49 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration( | 50 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration( |
| 50 const std::vector<AudioOutputDeviceInfo>& devices, | 51 const std::vector<AudioOutputDeviceInfo>& devices, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return ++current_event_sequence_; | 147 return ++current_event_sequence_; |
| 147 } | 148 } |
| 148 | 149 |
| 149 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { | 150 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { |
| 150 DCHECK(thread_checker_.CalledOnValidThread()); | 151 DCHECK(thread_checker_.CalledOnValidThread()); |
| 151 return seq_last_enumeration_ > seq_last_invalidation_ && | 152 return seq_last_enumeration_ > seq_last_invalidation_ && |
| 152 !is_enumeration_ongoing_; | 153 !is_enumeration_ongoing_; |
| 153 } | 154 } |
| 154 | 155 |
| 155 } // namespace content | 156 } // namespace content |
| OLD | NEW |