From 61139c8d9d655e07964d63ec1f5a091a7e8ab7d0 Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 2 Feb 2026 09:28:28 +0100 Subject: 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. --- tools/spectool.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tools/spectool.cc') 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; } -- cgit v1.2.3