Chromium Code Reviews| 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 // The <code>chrome.audio</code> API is provided to allow users to | 5 // The <code>chrome.audio</code> API is provided to allow users to |
| 6 // get information about and control the audio devices attached to the | 6 // get information about and control the audio devices attached to the |
| 7 // system. This API is currently only implemented for ChromeOS. | 7 // system. This API is currently only implemented for ChromeOS. |
| 8 namespace audio { | 8 namespace audio { |
| 9 | 9 |
| 10 // Type of stream an audio device provides. | 10 // Type of stream an audio device provides. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 // True if this is the current active device. | 74 // True if this is the current active device. |
| 75 boolean isActive; | 75 boolean isActive; |
| 76 // True if this is muted. | 76 // True if this is muted. |
| 77 boolean isMuted; | 77 boolean isMuted; |
| 78 // The sound level of the device, volume for output, gain for input. | 78 // The sound level of the device, volume for output, gain for input. |
| 79 long level; | 79 long level; |
| 80 // The stable/persisted device id string when available. | 80 // The stable/persisted device id string when available. |
| 81 DOMString? stableDeviceId; | 81 DOMString? stableDeviceId; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 dictionary DeviceFilter { | |
| 85 // If set, only audio devices whose stream type is included in this list | |
| 86 // will satisfy the filter. | |
| 87 StreamType[]? streamTypes; | |
| 88 | |
| 89 // If set, only audio devices whose active state matches this value will | |
| 90 // satisfy the filter. | |
| 91 boolean? isActive; | |
| 92 }; | |
| 93 | |
| 84 dictionary DeviceProperties { | 94 dictionary DeviceProperties { |
| 85 // True if this is muted. | 95 // True if this is muted. |
| 86 [deprecated="Use $(ref:setMute) to set mute state."] boolean? isMuted; | 96 [deprecated="Use $(ref:setMute) to set mute state."] boolean? isMuted; |
| 97 | |
| 87 // If this is an output device then this field indicates the output volume. | 98 // If this is an output device then this field indicates the output volume. |
| 88 // If this is an input device then this field is ignored. | 99 // If this is an input device then this field is ignored. |
| 89 double? volume; | 100 [deprecated="Use |level| to set output volume."] double? volume; |
|
Devlin
2017/02/10 20:24:29
Remind me - what's the plan for removing these?
tbarzic
2017/02/10 21:05:18
I'll send out a cl that makes these available only
| |
| 101 | |
| 90 // If this is an input device then this field indicates the input gain. | 102 // If this is an input device then this field indicates the input gain. |
| 91 // If this is an output device then this field is ignored. | 103 // If this is an output device then this field is ignored. |
| 92 double? gain; | 104 [deprecated="Use |level| to set input gain."] double? gain; |
| 105 | |
| 106 // <p> | |
| 107 // The audio device's desired sound level. Defaults to the device's | |
| 108 // current sound level. | |
| 109 // </p> | |
| 110 // <p>If used with audio input device, represents audio device gain.</p> | |
| 111 // <p>If used with audio output device, represents audio device volume.</p> | |
| 112 long? level; | |
|
Devlin
2017/02/10 20:24:29
Would it make sense to rename gain/volume on the d
tbarzic
2017/02/10 21:05:18
Those are actually also deprecated - they're only
| |
| 93 }; | 113 }; |
| 94 | 114 |
| 95 dictionary DeviceIdLists { | 115 dictionary DeviceIdLists { |
| 96 // <p>List of input devices specified by their ID.</p> | 116 // <p>List of input devices specified by their ID.</p> |
| 97 // <p>To indicate input devices should be unaffected, leave this property | 117 // <p>To indicate input devices should be unaffected, leave this property |
| 98 // unset.</p> | 118 // unset.</p> |
| 99 DOMString[]? input; | 119 DOMString[]? input; |
| 100 | 120 |
| 101 // <p>List of output devices specified by their ID.</p> | 121 // <p>List of output devices specified by their ID.</p> |
| 102 // <p>To indicate output devices should be unaffected, leave this property | 122 // <p>To indicate output devices should be unaffected, leave this property |
| 103 // unset.</p> | 123 // unset.</p> |
| 104 DOMString[]? output; | 124 DOMString[]? output; |
| 105 }; | 125 }; |
| 106 | 126 |
| 107 dictionary MuteChangedEvent { | 127 dictionary MuteChangedEvent { |
| 108 // The type of the stream for which the mute value changed. The updated mute | 128 // The type of the stream for which the mute value changed. The updated mute |
| 109 // value applies to all devices with this stream type. | 129 // value applies to all devices with this stream type. |
| 110 StreamType streamType; | 130 StreamType streamType; |
| 111 | 131 |
| 112 // Whether or not the stream is now muted. | 132 // Whether or not the stream is now muted. |
| 113 boolean isMuted; | 133 boolean isMuted; |
| 114 }; | 134 }; |
| 115 | 135 |
| 136 dictionary LevelChangedEvent { | |
| 137 // ID of device whose sound level has changed. | |
| 138 DOMString deviceId; | |
| 139 | |
| 140 // The device's new sound level. | |
| 141 long level; | |
| 142 }; | |
| 143 | |
| 116 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, | 144 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, |
| 117 InputDeviceInfo[] inputInfo); | 145 InputDeviceInfo[] inputInfo); |
| 146 callback GetDevicesCallback = void(AudioDeviceInfo[] devices); | |
| 147 callback GetMuteCallback = void(boolean value); | |
| 118 callback EmptyCallback = void(); | 148 callback EmptyCallback = void(); |
| 119 callback GetMuteCallback = void(boolean value); | |
| 120 | 149 |
| 121 interface Functions { | 150 interface Functions { |
| 122 // Gets the information of all audio output and input devices. | 151 // Gets a list of audio devices filtered based on |filter|. |
| 123 static void getInfo(GetInfoCallback callback); | 152 // |filter|: Device properties by which to filter the list of returned |
| 153 // audio devices. Use <code>{}</code> to get all available audio | |
| 154 // devices. | |
| 155 // |callback|: Reports the requested list of audio devices. | |
| 156 static void getDevices(DeviceFilter filter, GetDevicesCallback callback); | |
|
Devlin
2017/02/10 20:24:29
should filter be optional?
tbarzic
2017/02/10 21:05:18
I slightly prefer it not being optional, but I can
Devlin
2017/02/13 23:18:09
If there's no reason to require it, it seems odd t
tbarzic
2017/02/14 00:27:13
OK, done.
| |
| 124 | 157 |
| 125 // Sets lists of active input and/or output devices. | 158 // Sets lists of active input and/or output devices. |
| 126 // |ids|: <p>Specifies IDs of devices that should be active. If either the | 159 // |ids|: <p>Specifies IDs of devices that should be active. If either the |
| 127 // input or output list is not set, devices in that category are | 160 // input or output list is not set, devices in that category are |
| 128 // unaffected. | 161 // unaffected. |
| 129 // </p> | 162 // </p> |
| 130 // <p>It is an error to pass in a non-existent device ID.</p> | 163 // <p>It is an error to pass in a non-existent device ID.</p> |
| 131 // <p><b>NOTE:</b> While the method signature allows device IDs to be | 164 // <p><b>NOTE:</b> While the method signature allows device IDs to be |
| 132 // passed as a list of strings, this method of setting active devices | 165 // passed as a list of strings, this method of setting active devices |
| 133 // is deprecated and should not be relied upon to work. Please use | 166 // is deprecated and should not be relied upon to work. Please use |
| 134 // $(ref: DeviceIdLists) instead. | 167 // $(ref:DeviceIdLists) instead. |
| 135 // </p> | 168 // </p> |
| 136 static void setActiveDevices((DeviceIdLists or DOMString[]) ids, | 169 static void setActiveDevices((DeviceIdLists or DOMString[]) ids, |
| 137 EmptyCallback callback); | 170 EmptyCallback callback); |
| 138 | 171 |
| 139 // Sets the properties for the input or output device. | 172 // Sets the properties for the input or output device. |
| 140 static void setProperties(DOMString id, | 173 static void setProperties(DOMString id, |
| 141 DeviceProperties properties, | 174 DeviceProperties properties, |
| 142 EmptyCallback callback); | 175 EmptyCallback callback); |
| 143 | 176 |
| 144 // Gets the system-wide mute state for the specified stream type. | 177 // Gets the system-wide mute state for the specified stream type. |
| 145 // |streamType|: Stream type for which mute state should be fetched. | 178 // |streamType|: Stream type for which mute state should be fetched. |
| 146 // |callback|: Callback reporting whether mute is set or not for specified | 179 // |callback|: Callback reporting whether mute is set or not for specified |
| 147 // stream type. | 180 // stream type. |
| 148 static void getMute(StreamType streamType, GetMuteCallback callback); | 181 static void getMute(StreamType streamType, GetMuteCallback callback); |
| 149 | 182 |
| 150 // Sets mute state for a stream type. The mute state will apply to all audio | 183 // Sets mute state for a stream type. The mute state will apply to all audio |
| 151 // devices with the specified audio stream type. | 184 // devices with the specified audio stream type. |
| 152 // |streamType|: Stream type for which mute state should be set. | 185 // |streamType|: Stream type for which mute state should be set. |
| 153 // |isMuted|: New mute value. | 186 // |isMuted|: New mute value. |
| 154 static void setMute(StreamType streamType, | 187 static void setMute(StreamType streamType, |
| 155 boolean isMuted, | 188 boolean isMuted, |
| 156 optional EmptyCallback callback); | 189 optional EmptyCallback callback); |
| 190 | |
| 191 // Gets the information of all audio output and input devices. | |
| 192 [deprecated="Use $(ref:getDevices) instead."] | |
| 193 static void getInfo(GetInfoCallback callback); | |
| 157 }; | 194 }; |
| 158 | 195 |
| 159 interface Events { | 196 interface Events { |
| 160 // Fired when anything changes to the audio device configuration. | |
| 161 static void onDeviceChanged(); | |
| 162 | |
| 163 // Fired when sound level changes for an active audio device. | 197 // Fired when sound level changes for an active audio device. |
| 164 // |id|: id of the audio device. | 198 static void onLevelChanged(LevelChangedEvent event); |
| 165 // |level|: new sound level of device(volume for output, gain for input). | |
| 166 static void OnLevelChanged(DOMString id, long level); | |
| 167 | 199 |
| 168 // Fired when the mute state of the audio input or output changes. | 200 // Fired when the mute state of the audio input or output changes. |
| 169 // Note that mute state is system-wide and the new value applies to every | 201 // Note that mute state is system-wide and the new value applies to every |
| 170 // audio device with specified stream type. | 202 // audio device with specified stream type. |
| 171 static void onMuteChanged(MuteChangedEvent event); | 203 static void onMuteChanged(MuteChangedEvent event); |
| 172 | 204 |
| 173 // Fired when audio devices change, either new devices being added, or | 205 // Fired when audio devices change, either new devices being added, or |
| 174 // existing devices being removed. | 206 // existing devices being removed. |
| 175 // |devices|: List of all present audio devices after the change. | 207 // |devices|: List of all present audio devices after the change. |
| 176 static void OnDevicesChanged(AudioDeviceInfo[] devices); | 208 static void onDeviceListChanged(AudioDeviceInfo[] devices); |
|
Devlin
2017/02/10 20:24:29
Did we check that no one is currently using this e
tbarzic
2017/02/10 21:05:18
yes, I checked the event is not currently in use.
| |
| 209 | |
| 210 // Fired when anything changes to the audio device configuration. | |
| 211 [deprecated="Use more granular $(ref:onLevelChanged), | |
| 212 $(ref:onMuteChanged) and $(ref:onDeviceListChanged) instead."] | |
| 213 static void onDeviceChanged(); | |
| 177 }; | 214 }; |
| 178 }; | 215 }; |
| OLD | NEW |