Expose `AudioServer.capture_device` as a property

This is more consistent with `AudioServer.device` (for output),
which is already exposed as a property.

(cherry picked from commit 1d35b37499)
This commit is contained in:
Hugo Locurcio 2022-02-14 18:09:09 +01:00 committed by Rémi Verschelde
parent 60f9c0fb42
commit cfba65fa23
2 changed files with 7 additions and 13 deletions

View File

@ -29,25 +29,12 @@
Adds an [AudioEffect] effect to the bus [code]bus_idx[/code] at [code]at_position[/code]. Adds an [AudioEffect] effect to the bus [code]bus_idx[/code] at [code]at_position[/code].
</description> </description>
</method> </method>
<method name="capture_get_device">
<return type="String" />
<description>
Name of the current device for audio input (see [method capture_get_device_list]). The value [code]"Default"[/code] means that the system-wide default audio input is currently used.
</description>
</method>
<method name="capture_get_device_list"> <method name="capture_get_device_list">
<return type="Array" /> <return type="Array" />
<description> <description>
Returns the names of all audio input devices detected on the system. Returns the names of all audio input devices detected on the system.
</description> </description>
</method> </method>
<method name="capture_set_device">
<return type="void" />
<argument index="0" name="name" type="String" />
<description>
Sets which audio input device is used for audio capture. On systems with multiple audio inputs (such as analog and USB), this can be used to select the audio input device. Setting the value [code]"Default"[/code] will record audio from the system-wide default audio input. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
</description>
</method>
<method name="generate_bus_layout" qualifiers="const"> <method name="generate_bus_layout" qualifiers="const">
<return type="AudioBusLayout" /> <return type="AudioBusLayout" />
<description> <description>
@ -308,6 +295,9 @@
<member name="bus_count" type="int" setter="set_bus_count" getter="get_bus_count" default="1"> <member name="bus_count" type="int" setter="set_bus_count" getter="get_bus_count" default="1">
Number of available audio buses. Number of available audio buses.
</member> </member>
<member name="capture_device" type="String" setter="capture_set_device" getter="capture_get_device" default="&quot;Default&quot;">
Name of the current device for audio input (see [method get_device_list]). On systems with multiple audio inputs (such as analog, USB and HDMI audio), this can be used to select the audio input device. The value [code]"Default"[/code] will record audio on the system-wide default audio input. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
</member>
<member name="device" type="String" setter="set_device" getter="get_device" default="&quot;Default&quot;"> <member name="device" type="String" setter="set_device" getter="get_device" default="&quot;Default&quot;">
Name of the current device for audio output (see [method get_device_list]). On systems with multiple audio outputs (such as analog, USB and HDMI audio), this can be used to select the audio output device. The value [code]"Default"[/code] will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code]. Name of the current device for audio output (see [method get_device_list]). On systems with multiple audio outputs (such as analog, USB and HDMI audio), this can be used to select the audio output device. The value [code]"Default"[/code] will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
</member> </member>

View File

@ -1325,6 +1325,10 @@ void AudioServer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "bus_count"), "set_bus_count", "get_bus_count"); ADD_PROPERTY(PropertyInfo(Variant::INT, "bus_count"), "set_bus_count", "get_bus_count");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "device"), "set_device", "get_device"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "device"), "set_device", "get_device");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "capture_device"), "capture_set_device", "capture_get_device");
// The default value may be set to an empty string by the platform-specific audio driver.
// Override for class reference generation purposes.
ADD_PROPERTY_DEFAULT("capture_device", "Default");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rate_scale"), "set_global_rate_scale", "get_global_rate_scale"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rate_scale"), "set_global_rate_scale", "get_global_rate_scale");
ADD_SIGNAL(MethodInfo("bus_layout_changed")); ADD_SIGNAL(MethodInfo("bus_layout_changed"));