summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2024-10-22 23:14:59 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2024-10-22 23:14:59 +0200
commit77c31b9cc8cbfa84eacbfdbb76773d15b4e5423d (patch)
tree0a59dca8ef377821da581d758e8ea13bffe8094b /servers
parent533c616cb86ff7bb940d58ffbbcc1a3eca0aa33d (diff)
downloadredot-engine-77c31b9cc8cbfa84eacbfdbb76773d15b4e5423d.tar.gz
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.
Diffstat (limited to 'servers')
-rw-r--r--servers/audio_server.cpp6
-rw-r--r--servers/audio_server.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 70ef88e36d..17b573ab7b 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -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);
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 16fcc029b3..d4e1aa9995 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -427,6 +427,8 @@ public:
uint64_t get_mix_count() const;
uint64_t get_mixed_frames() const;
+ String get_driver_name() const;
+
void notify_listener_changed();
virtual void init();