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 // AudioOutputDeviceEnumerator is used to enumerate audio output devices. | 5 // AudioOutputDeviceEnumerator is used to enumerate audio output devices. |
6 // It can return cached results of previous enumerations in order to boost | 6 // It can return cached results of previous enumerations in order to boost |
7 // performance. | 7 // performance. |
8 // All its public methods must be called on the thread where the object is | 8 // All its public methods must be called on the thread where the object is |
9 // created. | 9 // created. |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // AudioOutputDeviceInfo describes information about an audio output device. | 37 // AudioOutputDeviceInfo describes information about an audio output device. |
38 // The enumerations returned by AudioOutputDeviceEnumerator::Enumerate() contain | 38 // The enumerations returned by AudioOutputDeviceEnumerator::Enumerate() contain |
39 // elements of this type. It is used only in the browser side. | 39 // elements of this type. It is used only in the browser side. |
40 struct AudioOutputDeviceInfo { | 40 struct AudioOutputDeviceInfo { |
41 std::string unique_id; | 41 std::string unique_id; |
42 std::string device_name; | 42 std::string device_name; |
43 media::AudioParameters output_params; | 43 media::AudioParameters output_params; |
44 }; | 44 }; |
45 | 45 |
46 typedef std::vector<AudioOutputDeviceInfo> AudioOutputDeviceEnumeration; | 46 // The result of an enumeration. It is used only in the browser side. |
| 47 struct AudioOutputDeviceEnumeration { |
| 48 public: |
| 49 AudioOutputDeviceEnumeration( |
| 50 const std::vector<AudioOutputDeviceInfo>& devices, |
| 51 bool has_actual_devices); |
| 52 AudioOutputDeviceEnumeration(); |
| 53 ~AudioOutputDeviceEnumeration(); |
| 54 |
| 55 std::vector<AudioOutputDeviceInfo> devices; |
| 56 bool has_actual_devices; |
| 57 }; |
| 58 |
47 typedef base::Callback<void(const AudioOutputDeviceEnumeration&)> | 59 typedef base::Callback<void(const AudioOutputDeviceEnumeration&)> |
48 AudioOutputDeviceEnumerationCB; | 60 AudioOutputDeviceEnumerationCB; |
49 | 61 |
50 class CONTENT_EXPORT AudioOutputDeviceEnumerator { | 62 class CONTENT_EXPORT AudioOutputDeviceEnumerator { |
51 public: | 63 public: |
52 enum CachePolicy { | 64 enum CachePolicy { |
53 CACHE_POLICY_NO_CACHING, | 65 CACHE_POLICY_NO_CACHING, |
54 CACHE_POLICY_MANUAL_INVALIDATION | 66 CACHE_POLICY_MANUAL_INVALIDATION |
55 }; | 67 }; |
56 AudioOutputDeviceEnumerator(media::AudioManager* audio_manager, | 68 AudioOutputDeviceEnumerator(media::AudioManager* audio_manager, |
57 CachePolicy cache_policy); | 69 CachePolicy cache_policy); |
58 ~AudioOutputDeviceEnumerator(); | 70 ~AudioOutputDeviceEnumerator(); |
59 | 71 |
60 // Does an enumeration and provides the results to the callback. | 72 // Does an enumeration and provides the results to the callback. |
61 // If there are no physical devices, the result contains a single entry with | 73 // If there are no physical devices, the result contains a single entry with |
62 // the default parameters provided by the underlying audio manager. | 74 // the default parameters provided by the underlying audio manager and with |
| 75 // the |has_actual_devices| field set to false. |
63 // The behavior with no physical devices is there to ease the transition | 76 // The behavior with no physical devices is there to ease the transition |
64 // from the use of RenderThreadImpl::GetAudioHardwareConfig(), which always | 77 // from the use of RenderThreadImpl::GetAudioHardwareConfig(), which always |
65 // provides default parameters, even if there are no devices. | 78 // provides default parameters, even if there are no devices. |
66 // See https://crbug.com/549125. | 79 // See https://crbug.com/549125. |
| 80 // Some audio managers always report a single device, regardless of the |
| 81 // physical devices in the system. In this case the |has_actual_devices| field |
| 82 // is set to true to differentiate from the case of no physical devices. |
67 void Enumerate(const AudioOutputDeviceEnumerationCB& callback); | 83 void Enumerate(const AudioOutputDeviceEnumerationCB& callback); |
68 | 84 |
69 // Invalidates the current cache. | 85 // Invalidates the current cache. |
70 void InvalidateCache(); | 86 void InvalidateCache(); |
71 | 87 |
72 // Sets the cache policy. | 88 // Sets the cache policy. |
73 void SetCachePolicy(CachePolicy cache_policy); | 89 void SetCachePolicy(CachePolicy cache_policy); |
74 | 90 |
75 // Returns true if the caching policy is different from | 91 // Returns true if the caching policy is different from |
76 // CACHE_POLICY_NO_CACHING, false otherwise. | 92 // CACHE_POLICY_NO_CACHING, false otherwise. |
(...skipping 21 matching lines...) Expand all Loading... |
98 | 114 |
99 base::ThreadChecker thread_checker_; | 115 base::ThreadChecker thread_checker_; |
100 base::WeakPtrFactory<AudioOutputDeviceEnumerator> weak_factory_; | 116 base::WeakPtrFactory<AudioOutputDeviceEnumerator> weak_factory_; |
101 | 117 |
102 DISALLOW_COPY_AND_ASSIGN(AudioOutputDeviceEnumerator); | 118 DISALLOW_COPY_AND_ASSIGN(AudioOutputDeviceEnumerator); |
103 }; | 119 }; |
104 | 120 |
105 } // namespace content | 121 } // namespace content |
106 | 122 |
107 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DEVICE_ENUMERATOR_H_ | 123 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DEVICE_ENUMERATOR_H_ |
OLD | NEW |