diff options
Diffstat (limited to 'servers/audio_server.cpp')
| -rw-r--r-- | servers/audio_server.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 49991e41d3..511a8b3122 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -40,6 +40,7 @@ #include "core/string/string_name.h" #include "core/templates/pair.h" #include "scene/resources/audio_stream_wav.h" +#include "scene/scene_string_names.h" #include "servers/audio/audio_driver_dummy.h" #include "servers/audio/effects/audio_effect_compressor.h" @@ -200,8 +201,6 @@ void AudioDriverManager::initialize(int p_driver) { GLOBAL_DEF_RST("audio/driver/enable_input", false); GLOBAL_DEF_RST("audio/driver/mix_rate", DEFAULT_MIX_RATE); GLOBAL_DEF_RST("audio/driver/mix_rate.web", 0); // Safer default output_latency for web (use browser default). - GLOBAL_DEF_RST("audio/driver/output_latency", DEFAULT_OUTPUT_LATENCY); - GLOBAL_DEF_RST("audio/driver/output_latency.web", 50); // Safer default output_latency for web. int failed_driver = -1; @@ -390,7 +389,7 @@ void AudioServer::_mix_step() { } AudioStreamPlaybackBusDetails *ptr = playback->bus_details.load(); - ERR_FAIL_COND(ptr == nullptr); + ERR_FAIL_NULL(ptr); // By putting null into the bus details pointers, we're taking ownership of their memory for the duration of this mix. AudioStreamPlaybackBusDetails bus_details = *ptr; @@ -621,8 +620,8 @@ void AudioServer::_mix_step_for_channel(AudioFrame *p_out_buf, AudioFrame *p_sou filter.set_stages(1); filter.set_gain(p_highshelf_gain); - ERR_FAIL_COND(p_processor_l == nullptr); - ERR_FAIL_COND(p_processor_r == nullptr); + ERR_FAIL_NULL(p_processor_l); + ERR_FAIL_NULL(p_processor_r); bool is_just_started = p_vol_start.l == 0 && p_vol_start.r == 0; p_processor_l->set_filter(&filter, /* clear_history= */ is_just_started); @@ -747,7 +746,7 @@ void AudioServer::set_bus_count(int p_count) { buses[i]->bypass = false; buses[i]->volume_db = 0; if (i > 0) { - buses[i]->send = "Master"; + buses[i]->send = SceneStringNames::get_singleton()->Master; } bus_map[attempt] = buses[i]; @@ -858,14 +857,16 @@ int AudioServer::get_bus_count() const { void AudioServer::set_bus_name(int p_bus, const String &p_name) { ERR_FAIL_INDEX(p_bus, buses.size()); if (p_bus == 0 && p_name != "Master") { - return; //bus 0 is always master + return; // Bus 0 is always "Master". } MARK_EDITED lock(); - if (buses[p_bus]->name == p_name) { + StringName old_name = buses[p_bus]->name; + + if (old_name == p_name) { unlock(); return; } @@ -889,12 +890,12 @@ void AudioServer::set_bus_name(int p_bus, const String &p_name) { attempts++; attempt = p_name + " " + itos(attempts); } - bus_map.erase(buses[p_bus]->name); + bus_map.erase(old_name); buses[p_bus]->name = attempt; bus_map[attempt] = buses[p_bus]; unlock(); - emit_signal(SNAME("bus_layout_changed")); + emit_signal(SNAME("bus_renamed"), p_bus, old_name, attempt); } String AudioServer::get_bus_name(int p_bus) const { @@ -1582,7 +1583,7 @@ void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout) { for (int i = 0; i < p_bus_layout->buses.size(); i++) { Bus *bus = memnew(Bus); if (i == 0) { - bus->name = "Master"; + bus->name = SceneStringNames::get_singleton()->Master; } else { bus->name = p_bus_layout->buses[i].name; bus->send = p_bus_layout->buses[i].send; @@ -1752,6 +1753,7 @@ void AudioServer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_speed_scale"), "set_playback_speed_scale", "get_playback_speed_scale"); ADD_SIGNAL(MethodInfo("bus_layout_changed")); + ADD_SIGNAL(MethodInfo("bus_renamed", PropertyInfo(Variant::INT, "bus_index"), PropertyInfo(Variant::STRING_NAME, "old_name"), PropertyInfo(Variant::STRING_NAME, "new_name"))); BIND_ENUM_CONSTANT(SPEAKER_MODE_STEREO); BIND_ENUM_CONSTANT(SPEAKER_SURROUND_31); @@ -1891,5 +1893,5 @@ void AudioBusLayout::_get_property_list(List<PropertyInfo> *p_list) const { AudioBusLayout::AudioBusLayout() { buses.resize(1); - buses.write[0].name = "Master"; + buses.write[0].name = SceneStringNames::get_singleton()->Master; } |
