Skip to content

Commit 3e7dd07

Browse files
authored
feat: Remove event, buses and VCA limit (#347)
1 parent aaac25c commit 3e7dd07

File tree

5 files changed

+89
-72
lines changed

5 files changed

+89
-72
lines changed

src/fmod_cache.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,33 +245,33 @@ void FmodCache::clear() {
245245

246246
void FmodCache::_get_bank_data(Ref<FmodBank> bank) {
247247
bank->update_bank_data();
248-
for (Ref<FmodBus> bus : bank->getBuses()) {
248+
for (Ref<FmodBus> bus : bank->get_buses()) {
249249
FMOD_GUID guid {bus->get_guid()};
250250
buses[guid] = bus;
251251
strings_to_guid[bus->get_path()] = guid;
252252
}
253-
for (Ref<FmodVCA> vca : bank->getVcAs()) {
253+
for (Ref<FmodVCA> vca : bank->get_vcas()) {
254254
FMOD_GUID guid {vca->get_guid()};
255255
vcas[guid] = vca;
256256
strings_to_guid[vca->get_path()] = guid;
257257
}
258-
for (Ref<FmodEventDescription> desc : bank->getEventDescriptions()) {
258+
for (Ref<FmodEventDescription> desc : bank->get_event_descriptions()) {
259259
FMOD_GUID guid {desc->get_guid()};
260260
event_descriptions[guid] = desc;
261261
strings_to_guid[desc->get_path()] = guid;
262262
}
263263
}
264264

265265
void FmodCache::_remove_bank_data(FmodBank* bank) {
266-
for (Ref<FmodBus> bus : bank->getBuses()) {
266+
for (Ref<FmodBus> bus : bank->get_buses()) {
267267
strings_to_guid.erase(bus->get_path());
268268
buses.erase(bus->get_guid());
269269
}
270-
for (Ref<FmodVCA> vca : bank->getVcAs()) {
270+
for (Ref<FmodVCA> vca : bank->get_vcas()) {
271271
strings_to_guid.erase(vca->get_path());
272272
vcas.erase(vca->get_guid());
273273
}
274-
for (Ref<FmodEventDescription> desc : bank->getEventDescriptions()) {
274+
for (Ref<FmodEventDescription> desc : bank->get_event_descriptions()) {
275275
strings_to_guid.erase(desc->get_path());
276276
event_descriptions.erase(desc->get_guid());
277277
}

src/helpers/common.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,11 @@
1616
#define MAX_PATH_SIZE 512
1717
#define MAX_DRIVER_NAME_SIZE 256
1818

19-
#define MAX_VCA_COUNT 64
20-
#define MAX_BUS_COUNT 64
21-
#define MAX_EVENT_DESCRIPTION_COUNT 256
22-
#define MAX_EVENT_INSTANCE_COUNT 128
23-
2419
#define GODOT_LOG_INFO(message) UtilityFunctions::print(message);
2520
#define GODOT_LOG_VERBOSE(message) UtilityFunctions::print_verbose(message);
2621
#define GODOT_LOG_WARNING(message) UtilityFunctions::push_warning(message, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__);
2722
#define GODOT_LOG_ERROR(message) UtilityFunctions::push_error(message, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__);
2823

29-
#define CHECK_SIZE(maxSize, actualSize, type) \
30-
if ((actualSize) > (maxSize)) { \
31-
String message = "FMOD Sound System: type maximum size is " + String::num(maxSize) + " but the bank contains " \
32-
+ String::num(actualSize) + " entries"; \
33-
GODOT_LOG_ERROR(message) \
34-
(actualSize) = maxSize; \
35-
}
36-
3724
#define ERROR_CHECK_WITH_REASON(_result, _reason) \
3825
(((_result) != FMOD_OK) ? (godot::UtilityFunctions::push_error(FMOD_ErrorString(_result), BOOST_CURRENT_FUNCTION, __FILE__, __LINE__), \
3926
godot::UtilityFunctions::push_error(_reason, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__), false) : true)

src/studio/fmod_bank.cpp

Lines changed: 60 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ int FmodBank::get_loading_state() {
2727
return state;
2828
}
2929

30-
int FmodBank::get_bus_count() {
31-
return buses.size();
30+
int64_t FmodBank::get_bus_count() {
31+
return _buses.size();
3232
}
3333

34-
int FmodBank::get_event_description_count() {
35-
return eventDescriptions.size();
34+
int64_t FmodBank::get_event_description_count() {
35+
return _event_descriptions.size();
3636
}
3737

38-
int FmodBank::get_vca_count() const {
39-
return VCAs.size();
38+
int64_t FmodBank::get_vca_count() const {
39+
return _vcas.size();
4040
}
4141

4242
int FmodBank::get_string_count() const {
@@ -47,23 +47,23 @@ int FmodBank::get_string_count() const {
4747

4848
Array FmodBank::get_description_list() const {
4949
Array array;
50-
for (const Ref<FmodEventDescription>& ref : eventDescriptions) {
50+
for (const Ref<FmodEventDescription>& ref : _event_descriptions) {
5151
array.append(ref);
5252
}
5353
return array;
5454
}
5555

5656
Array FmodBank::get_bus_list() const {
5757
Array array;
58-
for (const Ref<FmodBus>& ref : buses) {
58+
for (const Ref<FmodBus>& ref : _buses) {
5959
array.append(ref);
6060
}
6161
return array;
6262
}
6363

6464
Array FmodBank::get_vca_list() const {
6565
Array array;
66-
for (const Ref<FmodVCA>& ref : VCAs) {
66+
for (const Ref<FmodVCA>& ref : _vcas) {
6767
array.append(ref);
6868
}
6969
return array;
@@ -76,54 +76,78 @@ void FmodBank::update_bank_data() {
7676
}
7777

7878
void FmodBank::load_all_vca() {
79-
FMOD::Studio::VCA* array[MAX_VCA_COUNT];
8079
int size = 0;
81-
if (ERROR_CHECK_WITH_REASON(_wrapped->getVCAList(array, MAX_VCA_COUNT, &size), vformat("Cannot get VCA list for bank %s", get_path()))) {
82-
CHECK_SIZE(MAX_VCA_COUNT, size, VCAs)
83-
VCAs.clear();
84-
for (int i = 0; i < size; ++i) {
85-
Ref<FmodVCA> ref = FmodVCA::create_ref(array[i]);
86-
VCAs.push_back(ref);
80+
if (ERROR_CHECK_WITH_REASON(_wrapped->getVCACount(&size), vformat("Cannot get VCA count for bank %s", get_path()))) {
81+
if (size == 0) {
82+
return;
83+
}
84+
85+
Vector<FMOD::Studio::VCA*> raw_vcas;
86+
raw_vcas.resize(size);
87+
88+
if (ERROR_CHECK_WITH_REASON(_wrapped->getVCAList(raw_vcas.ptrw(), size, &size), vformat("Cannot get VCA list for bank %s", get_path()))) {
89+
_vcas.clear();
90+
91+
for (int i = 0; i < size; ++i) {
92+
Ref<FmodVCA> ref = FmodVCA::create_ref(raw_vcas[i]);
93+
_vcas.push_back(ref);
94+
}
8795
}
8896
}
8997
}
9098

9199
void FmodBank::load_all_buses() {
92-
FMOD::Studio::Bus* array[MAX_BUS_COUNT];
93100
int size = 0;
94-
if (ERROR_CHECK_WITH_REASON(_wrapped->getBusList(array, MAX_BUS_COUNT, &size), vformat("Cannot get bus list for bank %s", get_path()))) {
95-
CHECK_SIZE(MAX_BUS_COUNT, size, buses)
96-
buses.clear();
97-
for (int i = 0; i < size; ++i) {
98-
Ref<FmodBus> ref = FmodBus::create_ref(array[i]);
99-
buses.push_back(ref);
101+
if (ERROR_CHECK_WITH_REASON(_wrapped->getBusCount(&size), vformat("Cannot get bus count for bank %s", get_path()))) {
102+
if (size == 0) {
103+
return;
104+
}
105+
106+
Vector<FMOD::Studio::Bus*> raw_buses;
107+
raw_buses.resize(size);
108+
109+
if (ERROR_CHECK_WITH_REASON(_wrapped->getBusList(raw_buses.ptrw(), size, &size), vformat("Cannot get bus list for bank %s", get_path()))) {
110+
_buses.clear();
111+
112+
for (int i = 0; i < size; ++i) {
113+
Ref<FmodBus> ref = FmodBus::create_ref(raw_buses[i]);
114+
_buses.push_back(ref);
115+
}
100116
}
101117
}
102118
}
103119

104120
void FmodBank::load_all_event_descriptions() {
105-
FMOD::Studio::EventDescription* array[MAX_EVENT_DESCRIPTION_COUNT];
106121
int size = 0;
107-
if (ERROR_CHECK_WITH_REASON(_wrapped->getEventList(array, MAX_EVENT_DESCRIPTION_COUNT, &size), vformat("Cannot get event list for bank %s", get_path()))) {
108-
CHECK_SIZE(MAX_EVENT_DESCRIPTION_COUNT, size, Events)
109-
eventDescriptions.clear();
110-
for (int i = 0; i < size; ++i) {
111-
Ref<FmodEventDescription> ref = FmodEventDescription::create_ref(array[i]);
112-
eventDescriptions.push_back(ref);
122+
if (ERROR_CHECK_WITH_REASON(_wrapped->getEventCount(&size), vformat("Cannot get event count for bank %s", get_path()))) {
123+
if (size == 0) {
124+
return;
125+
}
126+
127+
Vector<FMOD::Studio::EventDescription*> raw_events;
128+
raw_events.resize(size);
129+
130+
if (ERROR_CHECK_WITH_REASON(_wrapped->getEventList(raw_events.ptrw(), size, &size), vformat("Cannot get event list for bank %s", get_path()))) {
131+
_event_descriptions.clear();
132+
133+
for (int i = 0; i < size; ++i) {
134+
Ref<FmodEventDescription> ref = FmodEventDescription::create_ref(raw_events[i]);
135+
_event_descriptions.push_back(ref);
136+
}
113137
}
114138
}
115139
}
116140

117-
const List<Ref<FmodEventDescription>>& FmodBank::getEventDescriptions() const {
118-
return eventDescriptions;
141+
const List<Ref<FmodEventDescription>>& FmodBank::get_event_descriptions() const {
142+
return _event_descriptions;
119143
}
120144

121-
const List<Ref<FmodBus>>& FmodBank::getBuses() const {
122-
return buses;
145+
const List<Ref<FmodBus>>& FmodBank::get_buses() const {
146+
return _buses;
123147
}
124148

125-
const List<Ref<FmodVCA>>& FmodBank::getVcAs() const {
126-
return VCAs;
149+
const List<Ref<FmodVCA>>& FmodBank::get_vcas() const {
150+
return _vcas;
127151
}
128152

129153
const String& FmodBank::get_godot_res_path() const {

src/studio/fmod_bank.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace godot {
1212
class FmodBank : public RefCounted {
1313
FMODCLASSWITHPATH(FmodBank, RefCounted, FMOD::Studio::Bank);
1414

15-
List<Ref<FmodEventDescription>> eventDescriptions;
16-
List<Ref<FmodBus>> buses;
17-
List<Ref<FmodVCA>> VCAs;
15+
List<Ref<FmodEventDescription>> _event_descriptions;
16+
List<Ref<FmodBus>> _buses;
17+
List<Ref<FmodVCA>> _vcas;
1818
String _godot_res_path;
1919

2020
void load_all_vca();
@@ -27,9 +27,9 @@ namespace godot {
2727

2828
int get_loading_state();
2929

30-
int get_event_description_count();
31-
int get_bus_count();
32-
int get_vca_count() const;
30+
int64_t get_event_description_count();
31+
int64_t get_bus_count();
32+
int64_t get_vca_count() const;
3333
int get_string_count() const;
3434

3535
Array get_description_list() const;
@@ -38,9 +38,9 @@ namespace godot {
3838

3939
void update_bank_data();
4040

41-
const List<Ref<FmodEventDescription>>& getEventDescriptions() const;
42-
const List<Ref<FmodBus>>& getBuses() const;
43-
const List<Ref<FmodVCA>>& getVcAs() const;
41+
const List<Ref<FmodEventDescription>>& get_event_descriptions() const;
42+
const List<Ref<FmodBus>>& get_buses() const;
43+
const List<Ref<FmodVCA>>& get_vcas() const;
4444

4545
const String& get_godot_res_path() const;
4646

src/studio/fmod_event_description.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,21 @@ int FmodEventDescription::get_length() {
5858

5959
Array FmodEventDescription::get_instance_list() {
6060
Array array;
61-
FMOD::Studio::EventInstance* instances[MAX_EVENT_INSTANCE_COUNT];
62-
int count = 0;
63-
ERROR_CHECK_WITH_REASON(_wrapped->getInstanceList(instances, MAX_EVENT_INSTANCE_COUNT, &count), vformat("Cannot get instances list for event %s with guid %s", get_path(), get_guid_as_string()));
64-
CHECK_SIZE(MAX_EVENT_INSTANCE_COUNT, count, events)
65-
for (int i = 0; i < count; ++i) {
66-
godot::FmodEvent* event_instance;
67-
instances[i]->getUserData((void**) &event_instance);
68-
array.append(Ref(event_instance));
61+
62+
int size = 0;
63+
if (ERROR_CHECK_WITH_REASON(_wrapped->getInstanceCount(&size), vformat("Cannot get instances count for event %s with guid %s", get_path(), get_guid_as_string()))) {
64+
Vector<FMOD::Studio::EventInstance*> instances;
65+
instances.resize(size);
66+
67+
if (ERROR_CHECK_WITH_REASON(_wrapped->getInstanceList(instances.ptrw(), size, &size), vformat("Cannot get instances list for event %s with guid %s", get_path(), get_guid_as_string()))) {
68+
for (int i = 0; i < size; ++i) {
69+
godot::FmodEvent* event_instance;
70+
instances[i]->getUserData((void**) &event_instance);
71+
array.append(Ref(event_instance));
72+
}
73+
}
6974
}
75+
7076
return array;
7177
}
7278

0 commit comments

Comments
 (0)