Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

posix-fd-support.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "../plugin.h"
  3. // This extension let your plugin hook itself into the host select/poll/epoll/kqueue reactor.
  4. // This is useful to handle asynchronous I/O on the main thread.
  5. static CLAP_CONSTEXPR const char CLAP_EXT_POSIX_FD_SUPPORT[] = "clap.posix-fd-support";
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. enum {
  10. // IO events flags, they can be used to form a mask which describes:
  11. // - which events you are interested in (register_fd/modify_fd)
  12. // - which events happened (on_fd)
  13. CLAP_POSIX_FD_READ = 1 << 0,
  14. CLAP_POSIX_FD_WRITE = 1 << 1,
  15. CLAP_POSIX_FD_ERROR = 1 << 2,
  16. };
  17. typedef uint32_t clap_posix_fd_flags_t;
  18. typedef struct clap_plugin_posix_fd_support {
  19. // This callback is "level-triggered".
  20. // It means that a writable fd will continuously produce "on_fd()" events;
  21. // don't forget using modify_fd() to remove the write notification once you're
  22. // done writting.
  23. //
  24. // [main-thread]
  25. void(CLAP_ABI *on_fd)(const clap_plugin_t *plugin, int fd, clap_posix_fd_flags_t flags);
  26. } clap_plugin_posix_fd_support_t;
  27. typedef struct clap_host_posix_fd_support {
  28. // [main-thread]
  29. bool(CLAP_ABI *register_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags);
  30. // [main-thread]
  31. bool(CLAP_ABI *modify_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags);
  32. // [main-thread]
  33. bool(CLAP_ABI *unregister_fd)(const clap_host_t *host, int fd);
  34. } clap_host_posix_fd_support_t;
  35. #ifdef __cplusplus
  36. }
  37. #endif