From 4743749a2898282bf16a6ae95cd20794ddecb3ed Mon Sep 17 00:00:00 2001 From: Tristan Grespinet Date: Thu, 1 Dec 2022 12:08:04 +0100 Subject: [PATCH] Remove unused return type for load_bank() (#142) * Remove unused return type for load_bank() * Don't shut down Fmod if already initialize when Fmod.ready() is called. --- demo/Script/FmodTest.gd | 5 +++++ demo/addons/fmod/Fmod.gd | 7 ++++--- demo/fmod/fmod_config.cfg | 2 +- demo/project.godot | 2 +- src/godot_fmod.cpp | 5 ++--- src/godot_fmod.h | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/demo/Script/FmodTest.gd b/demo/Script/FmodTest.gd index 8efb11b0..de84211d 100644 --- a/demo/Script/FmodTest.gd +++ b/demo/Script/FmodTest.gd @@ -1,3 +1,8 @@ extends Node +func _enter_tree(): + Fmod.load_configuration("res://fmod/fmod_config.cfg") + + + diff --git a/demo/addons/fmod/Fmod.gd b/demo/addons/fmod/Fmod.gd index a13983d1..9ecc09ff 100644 --- a/demo/addons/fmod/Fmod.gd +++ b/demo/addons/fmod/Fmod.gd @@ -135,7 +135,8 @@ func _notification(what): func _ready(): ###SETUP FMOD### - load_configuration("res://fmod/fmod_config.cfg", true) + if not started: + load_configuration("res://fmod/fmod_config.cfg", true) func _process(delta): if started: @@ -297,8 +298,8 @@ func get_object_attached_to_listener(index: int) -> Node: ########## ###BANK### ########## -func load_bank(pathTo_bank: String, load_bankFlag: int) -> String: - return godot_fmod.load_bank(pathTo_bank, load_bankFlag) +func load_bank(pathTo_bank: String, load_bankFlag: int) -> void: + godot_fmod.load_bank(pathTo_bank, load_bankFlag) func unload_bank(pathTo_bank: String) -> void: godot_fmod.unload_bank(pathTo_bank) diff --git a/demo/fmod/fmod_config.cfg b/demo/fmod/fmod_config.cfg index f5440174..b9eb82d8 100644 --- a/demo/fmod/fmod_config.cfg +++ b/demo/fmod/fmod_config.cfg @@ -8,7 +8,7 @@ NumChannels=16 NumListeners=2 DSPBufferSize=1048 ShowDebug=true -LoadFMODOnStart=true +LoadFMODOnStart=false [Banks] diff --git a/demo/project.godot b/demo/project.godot index dd42155e..43f9ed86 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -19,7 +19,7 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/fmod/nodes/FmodEventEmitter.gd" }, { -"base": "Node", +"base": "", "class": "FmodNative", "language": "NativeScript", "path": "res://addons/fmod/Fmod.gdns" diff --git a/src/godot_fmod.cpp b/src/godot_fmod.cpp index 96d8e856..2d76be4c 100644 --- a/src/godot_fmod.cpp +++ b/src/godot_fmod.cpp @@ -572,9 +572,9 @@ void Fmod::set_software_format(int sampleRate, const int speakerMode, int numRaw ERROR_CHECK(coreSystem->setSoftwareFormat(sampleRate, static_cast(speakerMode), numRawSpeakers)); } -String Fmod::load_bank(const String& pathToBank, unsigned int flag) { +void Fmod::load_bank(const String& pathToBank, unsigned int flag) { DRIVE_PATH(pathToBank) - if (banks.has(pathToBank)) return pathToBank;// bank is already loaded + if (banks.has(pathToBank)) return;// bank is already loaded FMOD::Studio::Bank* bank = nullptr; ERROR_CHECK(system->loadBankFile(pathToBank.alloc_c_string(), flag, &bank)); if (bank) { @@ -588,7 +588,6 @@ String Fmod::load_bank(const String& pathToBank, unsigned int flag) { loadingBanks.append(loadingBank); } } - return pathToBank; } void Fmod::unload_bank(const String& pathToBank) { diff --git a/src/godot_fmod.h b/src/godot_fmod.h index 2e30b8c4..1f81bb9c 100644 --- a/src/godot_fmod.h +++ b/src/godot_fmod.h @@ -189,7 +189,7 @@ namespace godot { int get_system_dsp_num_buffers(); Array get_system_dsp_buffer_size(); - String load_bank(const String& pathToBank, unsigned int flag); + void load_bank(const String& pathToBank, unsigned int flag); void unload_bank(const String& pathToBank); bool check_vca_path(const String& vcaPath); bool check_bus_path(const String& busPath);