diff --git a/stfx/clap/stfx-clap.h b/stfx/clap/stfx-clap.h index 63b7ec4..fd67675 100644 --- a/stfx/clap/stfx-clap.h +++ b/stfx/clap/stfx-clap.h @@ -308,9 +308,16 @@ struct Plugin : public clap_plugin { } inputBuffers.resize(0); outputBuffers.resize(0); + + if (plugin.effect.hasPendingWebMessage()) { + plugin.host->request_callback(plugin.host); + } return CLAP_PROCESS_CONTINUE; } - static void plugin_on_main_thread(const clap_plugin *obj) {} + static void plugin_on_main_thread(const clap_plugin *obj) { + auto &plugin = *(Plugin *)obj; + plugin.sendWebMessages(); + } // parameters struct Param : public clap_param_info { @@ -609,7 +616,7 @@ struct Plugin : public clap_plugin { if (!fillFromStream(stream, buffer)) return false; StateReader storage{buffer}; plugin.effect.state(storage); - sendWebMessages(); // should already be on the main thread + plugin.sendWebMessages(); // should already be on the main thread return true; } diff --git a/stfx/ui/web-ui.h b/stfx/ui/web-ui.h index 94797e6..4fc15c0 100644 --- a/stfx/ui/web-ui.h +++ b/stfx/ui/web-ui.h @@ -267,6 +267,11 @@ struct WebUIHelper { readyToSend.test_and_set(); } }; + + bool hasPendingWebMessage() const { + auto &message = queue[readIndex]; + return message.readyToSend.test(); + } // Poll on the main thread (and directly after any `.webReceive()`), calling `.sent()` after you've sent it, repeat until you get `nullptr` WebMessage * getPendingWebMessage() {