summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-02 09:28:28 +0100
committerskal <pascal.massimino@gmail.com>2026-02-02 09:28:28 +0100
commit61139c8d9d655e07964d63ec1f5a091a7e8ab7d0 (patch)
tree4cf3694702f24e96c1c76a339f7b3e4d4fdf5e70 /tools
parent0b0067cb0a8db5ea5178501a12aacdef436a9845 (diff)
refactor(platform): Encapsulate state in PlatformState struct
- Replaced all global static variables in the platform layer with a single PlatformState struct. - Updated all platform function signatures to accept a pointer to this struct, making the implementation stateless and more modular. - Refactored main.cc, tests, and tools to instantiate and pass the PlatformState struct. - This improves code organization and removes scattered global state.
Diffstat (limited to 'tools')
-rw-r--r--tools/spectool.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/spectool.cc b/tools/spectool.cc
index dfb00de..19f3a2f 100644
--- a/tools/spectool.cc
+++ b/tools/spectool.cc
@@ -131,7 +131,8 @@ int play_spec(const char* in_path) {
fread(spec_data.data(), sizeof(float), spec_data.size(), f_in);
fclose(f_in);
- platform_init_window(false, nullptr, nullptr);
+ PlatformState platform_state = {};
+ platform_init(&platform_state, false, nullptr, nullptr);
audio_init();
audio_start();
Spectrogram spec;
@@ -144,12 +145,12 @@ int play_spec(const char* in_path) {
synth_trigger_voice(spec_id, 0.7f, 0.0f);
printf("Playing... Press Ctrl+C to exit.\n");
- while (synth_get_active_voice_count() > 0 && !platform_should_close()) {
- platform_poll();
+ while (synth_get_active_voice_count() > 0 && !platform_should_close(&platform_state)) {
+ platform_poll(&platform_state);
}
audio_shutdown();
- platform_shutdown();
+ platform_shutdown(&platform_state);
return 0;
}