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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 media::AudioDeviceNames device_names; | 24 media::AudioDeviceNames device_names; |
25 audio_manager->GetAudioOutputDeviceNames(&device_names); | 25 audio_manager->GetAudioOutputDeviceNames(&device_names); |
26 | 26 |
27 snapshot.has_actual_devices = !device_names.empty(); | 27 snapshot.has_actual_devices = !device_names.empty(); |
28 | 28 |
29 // 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 |
30 if (!snapshot.has_actual_devices) { | 30 if (!snapshot.has_actual_devices) { |
31 snapshot.devices.push_back( | 31 snapshot.devices.push_back( |
32 {media::AudioDeviceDescription::kDefaultDeviceId, | 32 {media::AudioDeviceDescription::kDefaultDeviceId, |
33 media::AudioDeviceDescription::GetDefaultDeviceName(), | 33 media::AudioDeviceDescription::GetDefaultDeviceName(), |
| 34 audio_manager->GetGroupIDOutput( |
| 35 media::AudioDeviceDescription::kDefaultDeviceId), |
34 audio_manager->GetDefaultOutputStreamParameters()}); | 36 audio_manager->GetDefaultOutputStreamParameters()}); |
35 return snapshot; | 37 return snapshot; |
36 } | 38 } |
37 | 39 |
38 for (const media::AudioDeviceName& name : device_names) { | 40 for (const media::AudioDeviceName& name : device_names) { |
39 snapshot.devices.push_back( | 41 snapshot.devices.push_back( |
40 {name.unique_id, name.device_name, | 42 {name.unique_id, name.device_name, |
| 43 audio_manager->GetGroupIDOutput(name.unique_id), |
41 name.unique_id == media::AudioDeviceDescription::kDefaultDeviceId | 44 name.unique_id == media::AudioDeviceDescription::kDefaultDeviceId |
42 ? audio_manager->GetDefaultOutputStreamParameters() | 45 ? audio_manager->GetDefaultOutputStreamParameters() |
43 : audio_manager->GetOutputStreamParameters(name.unique_id)}); | 46 : audio_manager->GetOutputStreamParameters(name.unique_id)}); |
44 } | 47 } |
45 return snapshot; | 48 return snapshot; |
46 } | 49 } |
47 | 50 |
48 } // namespace | 51 } // namespace |
49 | 52 |
| 53 AudioOutputDeviceInfo::AudioOutputDeviceInfo() {} |
| 54 |
| 55 AudioOutputDeviceInfo::~AudioOutputDeviceInfo() {} |
| 56 |
| 57 AudioOutputDeviceInfo::AudioOutputDeviceInfo( |
| 58 const std::string& unique_id, |
| 59 const std::string& device_name, |
| 60 const std::string& group_id, |
| 61 media::AudioParameters output_params) |
| 62 : unique_id(unique_id), |
| 63 device_name(device_name), |
| 64 group_id(group_id), |
| 65 output_params(output_params) {} |
| 66 |
| 67 AudioOutputDeviceInfo::AudioOutputDeviceInfo( |
| 68 const AudioOutputDeviceInfo& audio_output_device_info) = default; |
| 69 |
| 70 AudioOutputDeviceInfo::AudioOutputDeviceInfo( |
| 71 AudioOutputDeviceInfo&& audio_output_device_info) = default; |
| 72 |
| 73 AudioOutputDeviceInfo& AudioOutputDeviceInfo::operator=( |
| 74 const AudioOutputDeviceInfo& audio_output_device_info) = default; |
| 75 |
50 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration( | 76 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration( |
51 const std::vector<AudioOutputDeviceInfo>& devices, | 77 const std::vector<AudioOutputDeviceInfo>& devices, |
52 bool has_actual_devices) | 78 bool has_actual_devices) |
53 : devices(devices), has_actual_devices(has_actual_devices) {} | 79 : devices(devices), has_actual_devices(has_actual_devices) {} |
54 | 80 |
55 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration() | 81 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration() |
56 : has_actual_devices(false) {} | 82 : has_actual_devices(false) {} |
57 | 83 |
58 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration( | 84 AudioOutputDeviceEnumeration::AudioOutputDeviceEnumeration( |
59 const AudioOutputDeviceEnumeration& other) = default; | 85 const AudioOutputDeviceEnumeration& other) = default; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 return ++current_event_sequence_; | 173 return ++current_event_sequence_; |
148 } | 174 } |
149 | 175 |
150 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { | 176 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { |
151 DCHECK(thread_checker_.CalledOnValidThread()); | 177 DCHECK(thread_checker_.CalledOnValidThread()); |
152 return seq_last_enumeration_ > seq_last_invalidation_ && | 178 return seq_last_enumeration_ > seq_last_invalidation_ && |
153 !is_enumeration_ongoing_; | 179 !is_enumeration_ongoing_; |
154 } | 180 } |
155 | 181 |
156 } // namespace content | 182 } // namespace content |
OLD | NEW |