1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

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

The project setting does not reflect CLI argument overrides
(including `--headless` which sets the audio driver to `Dummy`),
so it can't be reliably used to detect which audio driver is
actually being used at run-time.
This commit is contained in:
Hugo Locurcio
2024-10-22 23:14:59 +02:00
parent 533c616cb8
commit 77c31b9cc8
4 changed files with 15 additions and 0 deletions

View File

@@ -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);
@@ -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);