clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit f91062cb9a98eaf763ebb6e8d71e38deff05c942
parent ec4900654e5f534d3359497d894c1932d34470ca
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Sat,  8 May 2021 23:24:00 +0200

Refine event-loop

Diffstat:
Minclude/clap/ext/draft/event-loop.h | 46+++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/include/clap/ext/draft/event-loop.h b/include/clap/ext/draft/event-loop.h @@ -1,44 +1,52 @@ #pragma once +#include <stddef.h> #ifdef __cplusplus extern "C" { #endif #include "../../clap.h" -#define CLAP_EXT_EV_LOOP "clap/draft/event-loop" +#define CLAP_EXT_EVENT_LOOP "clap/draft/event-loop" + +#ifdef _WIN32 +typedef void *clap_fd; +#else +typedef int clap_fd; +#endif enum { - CLAP_EV_LOOP_READ = 1, - CLAP_EV_LOOP_WRITE = 2, + CLAP_FD_READ = 1 << 0, + CLAP_FD_WRITE = 1 << 1, + CLAP_FD_ERROR = 1 << 2, }; -typedef void (*clap_fd_callback)(clap_plugin *plugin, int fd, int flags); +typedef struct clap_plugin_event_loop { + // [main-thread] + void (*on_timer)(clap_plugin *plugin, size_t timer_id); -typedef void (*clap_timer_callback)(clap_plugin *plugin, uint64_t timer_id); + // [main-thread] + void (*on_fd)(clap_plugin *plugin, clap_fd fd, uint32_t flags); +} clap_plugin_event_loop; typedef struct clap_host_event_loop { // [main-thread] - bool (*register_timer)(clap_host * host, - clap_plugin * plugin, - int64_t period_ms, - clap_timer_callback callback, - uint64_t * timer_id); + bool (*register_timer)(clap_host * host, + clap_plugin *plugin, + uint32_t period_ms, + uint32_t * timer_id); + + // [main-thread] + bool (*unregister_timer)(clap_host *host, clap_plugin *plugin, uint32_t timer_id); // [main-thread] - bool (*unregister_timer)(clap_host * host, - clap_plugin *plugin, - uint64_t timer_id); + bool (*register_fd)(clap_host *host, clap_plugin *plugin, clap_fd fd, uint32_t flags); // [main-thread] - bool (*register_fd)(clap_host * host, - clap_plugin * plugin, - int fd, - int flags, - clap_fd_callback callback); + bool (*modify_fd)(clap_host *host, clap_plugin *plugin, clap_fd fd, uint32_t flags); // [main-thread] - bool (*unregister_fd)(clap_host *host, clap_plugin *plugin, int fd); + bool (*unregister_fd)(clap_host *host, clap_plugin *plugin, clap_fd fd); } clap_host_event_loop; #ifdef __cplusplus