Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AudioServer.get_driver_name() to get the actual audio driver name #98435

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/classes/AudioServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
Returns the volume of the bus at index [param bus_idx] in dB.
</description>
</method>
<method name="get_driver_name" qualifiers="const">
<return type="String" />
<description>
Returns the name of the current audio driver. The default usually depends on the operating system, but may be overridden via the [code]--audio-driver[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url]. [code]--headless[/code] also automatically sets the audio driver to [code]Dummy[/code]. See also [member ProjectSettings.audio/driver/driver].
</description>
</method>
<method name="get_input_device_list">
<return type="PackedStringArray" />
<description>
Expand Down
1 change: 1 addition & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@
<member name="audio/driver/driver" type="String" setter="" getter="">
Specifies the audio driver to use. This setting is platform-dependent as each platform supports different audio drivers. If left empty, the default audio driver will be used.
The [code]Dummy[/code] audio driver disables all audio playback and recording, which is useful for non-game applications as it reduces CPU usage. It also prevents the engine from appearing as an application playing audio in the OS' audio mixer.
To query the value that is being used at run-time (which may be overridden by command-line arguments or headless mode), use [method AudioServer.get_driver_name].
[b]Note:[/b] The driver in use can be overridden at runtime via the [code]--audio-driver[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url].
</member>
<member name="audio/driver/enable_input" type="bool" setter="" getter="" default="false">
Expand Down
6 changes: 6 additions & 0 deletions servers/audio_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,10 @@ uint64_t AudioServer::get_mixed_frames() const {
return mix_frames;
}

String AudioServer::get_driver_name() const {
return AudioDriver::get_singleton()->get_name();
}

void AudioServer::notify_listener_changed() {
for (CallbackItem *ci : listener_changed_callback_list) {
ci->callback(ci->userdata);
Expand Down Expand Up @@ -1947,6 +1951,8 @@ void AudioServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_speaker_mode"), &AudioServer::get_speaker_mode);
ClassDB::bind_method(D_METHOD("get_mix_rate"), &AudioServer::get_mix_rate);

ClassDB::bind_method(D_METHOD("get_driver_name"), &AudioServer::get_driver_name);

ClassDB::bind_method(D_METHOD("get_output_device_list"), &AudioServer::get_output_device_list);
ClassDB::bind_method(D_METHOD("get_output_device"), &AudioServer::get_output_device);
ClassDB::bind_method(D_METHOD("set_output_device", "name"), &AudioServer::set_output_device);
Expand Down
2 changes: 2 additions & 0 deletions servers/audio_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ class AudioServer : public Object {
uint64_t get_mix_count() const;
uint64_t get_mixed_frames() const;

String get_driver_name() const;

void notify_listener_changed();

virtual void init();
Expand Down
Loading