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_manager_base.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 AudioOutputDeviceEnumeration EnumerateDevicesOnDeviceThread( | 18 AudioOutputDeviceEnumeration EnumerateDevicesOnDeviceThread( |
19 media::AudioManager* audio_manager) { | 19 media::AudioManager* audio_manager) { |
20 DCHECK(audio_manager->GetWorkerTaskRunner()->BelongsToCurrentThread()); | 20 DCHECK(audio_manager->GetWorkerTaskRunner()->BelongsToCurrentThread()); |
21 | 21 |
22 AudioOutputDeviceEnumeration snapshot; | 22 AudioOutputDeviceEnumeration snapshot; |
23 media::AudioDeviceNames device_names; | 23 media::AudioDeviceNames device_names; |
24 audio_manager->GetAudioOutputDeviceNames(&device_names); | 24 audio_manager->GetAudioOutputDeviceNames(&device_names); |
25 | 25 |
26 // If no devices in enumeration, return a list with a default device | 26 // If no devices in enumeration, return a list with a default device |
27 if (device_names.empty()) { | 27 if (device_names.empty()) { |
28 snapshot.push_back({media::AudioManagerBase::kDefaultDeviceId, | 28 snapshot.push_back({media::AudioManagerBase::kDefaultDeviceId, |
29 media::AudioManagerBase::kDefaultDeviceName, | 29 media::AudioManager::GetDefaultDeviceName(), |
30 audio_manager->GetDefaultOutputStreamParameters()}); | 30 audio_manager->GetDefaultOutputStreamParameters()}); |
31 return snapshot; | 31 return snapshot; |
32 } | 32 } |
33 | 33 |
34 for (const media::AudioDeviceName& name : device_names) { | 34 for (const media::AudioDeviceName& name : device_names) { |
35 snapshot.push_back( | 35 snapshot.push_back( |
36 {name.unique_id, name.device_name, | 36 {name.unique_id, name.device_name, |
37 name.unique_id == media::AudioManagerBase::kDefaultDeviceId | 37 name.unique_id == media::AudioManagerBase::kDefaultDeviceId |
38 ? audio_manager->GetDefaultOutputStreamParameters() | 38 ? audio_manager->GetDefaultOutputStreamParameters() |
39 : audio_manager->GetOutputStreamParameters(name.unique_id)}); | 39 : audio_manager->GetOutputStreamParameters(name.unique_id)}); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return ++current_event_sequence_; | 125 return ++current_event_sequence_; |
126 } | 126 } |
127 | 127 |
128 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { | 128 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { |
129 DCHECK(thread_checker_.CalledOnValidThread()); | 129 DCHECK(thread_checker_.CalledOnValidThread()); |
130 return seq_last_enumeration_ > seq_last_invalidation_ && | 130 return seq_last_enumeration_ > seq_last_invalidation_ && |
131 !is_enumeration_ongoing_; | 131 !is_enumeration_ongoing_; |
132 } | 132 } |
133 | 133 |
134 } // namespace content | 134 } // namespace content |
OLD | NEW |