Browse Source

Implement CLAP posix-fd extension, fix things with current plugins

Signed-off-by: falkTX <falktx@falktx.com>
pull/1689/head
falkTX 2 years ago
parent
commit
a615fefaf9
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
18 changed files with 570 additions and 205 deletions
  1. +4
    -5
      source/backend/engine/CarlaEngine.cpp
  2. +440
    -130
      source/backend/plugin/CarlaPluginCLAP.cpp
  3. +1
    -0
      source/backend/utils/Information.cpp
  4. +4
    -4
      source/discovery/carla-discovery.cpp
  5. +3
    -3
      source/includes/clap/entry.h
  6. +3
    -3
      source/includes/clap/events.h
  7. +4
    -4
      source/includes/clap/ext/audio-ports.h
  8. +20
    -20
      source/includes/clap/ext/gui.h
  9. +9
    -9
      source/includes/clap/ext/params.h
  10. +46
    -0
      source/includes/clap/ext/posix-fd-support.h
  11. +3
    -3
      source/includes/clap/ext/state.h
  12. +3
    -3
      source/includes/clap/ext/timer-support.h
  13. +4
    -4
      source/includes/clap/host.h
  14. +3
    -3
      source/includes/clap/plugin-factory.h
  15. +10
    -10
      source/includes/clap/plugin.h
  16. +8
    -0
      source/includes/clap/private/macros.h
  17. +2
    -2
      source/includes/clap/stream.h
  18. +3
    -2
      source/utils/CarlaClapUtils.hpp

+ 4
- 5
source/backend/engine/CarlaEngine.cpp View File

@@ -764,6 +764,10 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
plugin = CarlaPlugin::newAU(initializer);
break;

case PLUGIN_CLAP:
plugin = CarlaPlugin::newCLAP(initializer);
break;

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
case PLUGIN_INTERNAL:
plugin = CarlaPlugin::newNative(initializer);
@@ -800,10 +804,6 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
plugin = CarlaPlugin::newJSFX(initializer);
break;

case PLUGIN_CLAP:
plugin = CarlaPlugin::newCLAP(initializer);
break;

case PLUGIN_JACK:
# ifdef HAVE_JACK
plugin = CarlaPlugin::newJackApp(initializer);
@@ -819,7 +819,6 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
case PLUGIN_SFZ:
case PLUGIN_JACK:
case PLUGIN_JSFX:
case PLUGIN_CLAP:
setLastError("Plugin bridges cannot handle this binary");
break;
#endif


+ 440
- 130
source/backend/plugin/CarlaPluginCLAP.cpp
File diff suppressed because it is too large
View File


+ 1
- 0
source/backend/utils/Information.cpp View File

@@ -166,6 +166,7 @@ const char* const* carla_get_supported_file_extensions()
"so",
#endif
"vst3",
"clap",

// Audio files
#ifdef HAVE_SNDFILE


+ 4
- 4
source/discovery/carla-discovery.cpp View File

@@ -1861,10 +1861,10 @@ struct carla_clap_host : clap_host_t {
request_callback = carla_request_callback;
}

static const void* carla_get_extension(const clap_host_t*, const char*) { return nullptr; }
static void carla_request_restart(const clap_host_t*) {}
static void carla_request_process(const clap_host_t*) {}
static void carla_request_callback(const clap_host_t*) {}
static CLAP_ABI const void* carla_get_extension(const clap_host_t*, const char*) { return nullptr; }
static CLAP_ABI void carla_request_restart(const clap_host_t*) {}
static CLAP_ABI void carla_request_process(const clap_host_t*) {}
static CLAP_ABI void carla_request_callback(const clap_host_t*) {}
};

static void do_clap_check(lib_t& libHandle, const char* const filename, const bool doInit)


+ 3
- 3
source/includes/clap/entry.h View File

@@ -48,16 +48,16 @@ typedef struct clap_plugin_entry {
//
// If init() returns false, then the host must not call deinit() nor any other clap
// related symbols from the DSO.
bool (*init)(const char *plugin_path);
bool (CLAP_ABI *init)(const char *plugin_path);

// No more calls into the DSO must be made after calling deinit().
void (*deinit)(void);
void (CLAP_ABI *deinit)(void);

// Get the pointer to a factory. See plugin-factory.h for an example.
//
// Returns null if the factory is not provided.
// The returned pointer must *not* be freed by the caller.
const void *(*get_factory)(const char *factory_id);
const void *(CLAP_ABI *get_factory)(const char *factory_id);
} clap_plugin_entry_t;

/* Entry point */


+ 3
- 3
source/includes/clap/events.h View File

@@ -263,10 +263,10 @@ typedef struct clap_event_midi2 {
typedef struct clap_input_events {
void *ctx; // reserved pointer for the list

uint32_t (*size)(const struct clap_input_events *list);
uint32_t (CLAP_ABI *size)(const struct clap_input_events *list);

// Don't free the returned event, it belongs to the list
const clap_event_header_t *(*get)(const struct clap_input_events *list, uint32_t index);
const clap_event_header_t *(CLAP_ABI *get)(const struct clap_input_events *list, uint32_t index);
} clap_input_events_t;

// Output event list, events must be sorted by time.
@@ -275,7 +275,7 @@ typedef struct clap_output_events {

// Pushes a copy of the event
// returns false if the event could not be pushed to the queue (out of memory?)
bool (*try_push)(const struct clap_output_events *list, const clap_event_header_t *event);
bool (CLAP_ABI *try_push)(const struct clap_output_events *list, const clap_event_header_t *event);
} clap_output_events_t;

#ifdef __cplusplus


+ 4
- 4
source/includes/clap/ext/audio-ports.h View File

@@ -69,11 +69,11 @@ typedef struct clap_audio_port_info {
typedef struct clap_plugin_audio_ports {
// number of ports, for either input or output
// [main-thread]
uint32_t (*count)(const clap_plugin_t *plugin, bool is_input);
uint32_t (CLAP_ABI *count)(const clap_plugin_t *plugin, bool is_input);

// get info about about an audio port.
// [main-thread]
bool (*get)(const clap_plugin_t *plugin,
bool (CLAP_ABI *get)(const clap_plugin_t *plugin,
uint32_t index,
bool is_input,
clap_audio_port_info_t *info);
@@ -102,13 +102,13 @@ enum {
typedef struct clap_host_audio_ports {
// Checks if the host allows a plugin to change a given aspect of the audio ports definition.
// [main-thread]
bool (*is_rescan_flag_supported)(const clap_host_t *host, uint32_t flag);
bool (CLAP_ABI *is_rescan_flag_supported)(const clap_host_t *host, uint32_t flag);

// Rescan the full list of audio ports according to the flags.
// It is illegal to ask the host to rescan with a flag that is not supported.
// Certain flags require the plugin to be de-activated.
// [main-thread]
void (*rescan)(const clap_host_t *host, uint32_t flags);
void (CLAP_ABI *rescan)(const clap_host_t *host, uint32_t flags);
} clap_host_audio_ports_t;

#ifdef __cplusplus


+ 20
- 20
source/includes/clap/ext/gui.h View File

@@ -97,12 +97,12 @@ typedef struct clap_gui_resize_hints {
typedef struct clap_plugin_gui {
// Returns true if the requested gui api is supported
// [main-thread]
bool (*is_api_supported)(const clap_plugin_t *plugin, const char *api, bool is_floating);
bool (CLAP_ABI *is_api_supported)(const clap_plugin_t *plugin, const char *api, bool is_floating);

// Returns true if the plugin has a preferred api.
// The host has no obligation to honor the plugin preferrence, this is just a hint.
// [main-thread]
bool (*get_preferred_api)(const clap_plugin_t *plugin, const char **api, bool *is_floating);
bool (CLAP_ABI *get_preferred_api)(const clap_plugin_t *plugin, const char **api, bool *is_floating);

// Create and allocate all resources necessary for the gui.
//
@@ -115,11 +115,11 @@ typedef struct clap_plugin_gui {
//
// After this call, the GUI may not be visible yet; don't forget to call show().
// [main-thread]
bool (*create)(const clap_plugin_t *plugin, const char *api, bool is_floating);
bool (CLAP_ABI *create)(const clap_plugin_t *plugin, const char *api, bool is_floating);

// Free all resources associated with the gui.
// [main-thread]
void (*destroy)(const clap_plugin_t *plugin);
void (CLAP_ABI *destroy)(const clap_plugin_t *plugin);

// Set the absolute GUI scaling factor, and override any OS info.
// Should not be used if the windowing api relies upon logical pixels.
@@ -130,21 +130,21 @@ typedef struct clap_plugin_gui {
// Returns true if the scaling could be applied
// Returns false if the call was ignored, or the scaling could not be applied.
// [main-thread]
bool (*set_scale)(const clap_plugin_t *plugin, double scale);
bool (CLAP_ABI *set_scale)(const clap_plugin_t *plugin, double scale);

// Get the current size of the plugin UI.
// clap_plugin_gui->create() must have been called prior to asking the size.
// [main-thread]
bool (*get_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height);
bool (CLAP_ABI *get_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height);

// Returns true if the window is resizeable (mouse drag).
// Only for embedded windows.
// [main-thread]
bool (*can_resize)(const clap_plugin_t *plugin);
bool (CLAP_ABI *can_resize)(const clap_plugin_t *plugin);

// Returns true if the plugin can provide hints on how to resize the window.
// [main-thread]
bool (*get_resize_hints)(const clap_plugin_t *plugin, clap_gui_resize_hints_t *hints);
bool (CLAP_ABI *get_resize_hints)(const clap_plugin_t *plugin, clap_gui_resize_hints_t *hints);

// If the plugin gui is resizable, then the plugin will calculate the closest
// usable size which fits in the given size.
@@ -152,38 +152,38 @@ typedef struct clap_plugin_gui {
//
// Only for embedded windows.
// [main-thread]
bool (*adjust_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height);
bool (CLAP_ABI *adjust_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height);

// Sets the window size. Only for embedded windows.
// [main-thread]
bool (*set_size)(const clap_plugin_t *plugin, uint32_t width, uint32_t height);
bool (CLAP_ABI *set_size)(const clap_plugin_t *plugin, uint32_t width, uint32_t height);

// Embbeds the plugin window into the given window.
// [main-thread & !floating]
bool (*set_parent)(const clap_plugin_t *plugin, const clap_window_t *window);
bool (CLAP_ABI *set_parent)(const clap_plugin_t *plugin, const clap_window_t *window);

// Set the plugin floating window to stay above the given window.
// [main-thread & floating]
bool (*set_transient)(const clap_plugin_t *plugin, const clap_window_t *window);
bool (CLAP_ABI *set_transient)(const clap_plugin_t *plugin, const clap_window_t *window);

// Suggests a window title. Only for floating windows.
// [main-thread & floating]
void (*suggest_title)(const clap_plugin_t *plugin, const char *title);
void (CLAP_ABI *suggest_title)(const clap_plugin_t *plugin, const char *title);

// Show the window.
// [main-thread]
bool (*show)(const clap_plugin_t *plugin);
bool (CLAP_ABI *show)(const clap_plugin_t *plugin);

// Hide the window, this method does not free the resources, it just hides
// the window content. Yet it may be a good idea to stop painting timers.
// [main-thread]
bool (*hide)(const clap_plugin_t *plugin);
bool (CLAP_ABI *hide)(const clap_plugin_t *plugin);
} clap_plugin_gui_t;

typedef struct clap_host_gui {
// The host should call get_resize_hints() again.
// [thread-safe]
void (*resize_hints_changed)(const clap_host_t *host);
void (CLAP_ABI *resize_hints_changed)(const clap_host_t *host);

/* Request the host to resize the client area to width, height.
* Return true if the new size is accepted, false otherwise.
@@ -194,24 +194,24 @@ typedef struct clap_host_gui {
* satisfied then the host will call set_size() to revert the operation.
*
* [thread-safe] */
bool (*request_resize)(const clap_host_t *host, uint32_t width, uint32_t height);
bool (CLAP_ABI *request_resize)(const clap_host_t *host, uint32_t width, uint32_t height);

/* Request the host to show the plugin gui.
* Return true on success, false otherwise.
* [thread-safe] */
bool (*request_show)(const clap_host_t *host);
bool (CLAP_ABI *request_show)(const clap_host_t *host);

/* Request the host to hide the plugin gui.
* Return true on success, false otherwise.
* [thread-safe] */
bool (*request_hide)(const clap_host_t *host);
bool (CLAP_ABI *request_hide)(const clap_host_t *host);

// The floating window has been closed, or the connection to the gui has been lost.
//
// If was_destroyed is true, then the host must call clap_plugin_gui->destroy() to acknowledge
// the gui destruction.
// [thread-safe]
void (*closed)(const clap_host_t *host, bool was_destroyed);
void (CLAP_ABI *closed)(const clap_host_t *host, bool was_destroyed);
} clap_host_gui_t;

#ifdef __cplusplus


+ 9
- 9
source/includes/clap/ext/params.h View File

@@ -183,28 +183,28 @@ typedef struct clap_param_info {
typedef struct clap_plugin_params {
// Returns the number of parameters.
// [main-thread]
uint32_t (*count)(const clap_plugin_t *plugin);
uint32_t (CLAP_ABI *count)(const clap_plugin_t *plugin);

// Copies the parameter's info to param_info and returns true on success.
// [main-thread]
bool (*get_info)(const clap_plugin_t *plugin,
bool (CLAP_ABI *get_info)(const clap_plugin_t *plugin,
uint32_t param_index,
clap_param_info_t *param_info);

// Gets the parameter plain value.
// [main-thread]
bool (*get_value)(const clap_plugin_t *plugin, clap_id param_id, double *value);
bool (CLAP_ABI *get_value)(const clap_plugin_t *plugin, clap_id param_id, double *value);

// Formats the display text for the given parameter value.
// The host should always format the parameter value to text using this function
// before displaying it to the user.
// [main-thread]
bool (*value_to_text)(
bool (CLAP_ABI *value_to_text)(
const clap_plugin_t *plugin, clap_id param_id, double value, char *display, uint32_t size);

// Converts the display text to a parameter value.
// [main-thread]
bool (*text_to_value)(const clap_plugin_t *plugin,
bool (CLAP_ABI *text_to_value)(const clap_plugin_t *plugin,
clap_id param_id,
const char *display,
double *value);
@@ -213,7 +213,7 @@ typedef struct clap_plugin_params {
// This method must not be called concurrently to clap_plugin->process().
//
// [active ? audio-thread : main-thread]
void (*flush)(const clap_plugin_t *plugin,
void (CLAP_ABI *flush)(const clap_plugin_t *plugin,
const clap_input_events_t *in,
const clap_output_events_t *out);
} clap_plugin_params_t;
@@ -272,11 +272,11 @@ typedef uint32_t clap_param_clear_flags;
typedef struct clap_host_params {
// Rescan the full list of parameters according to the flags.
// [main-thread]
void (*rescan)(const clap_host_t *host, clap_param_rescan_flags flags);
void (CLAP_ABI *rescan)(const clap_host_t *host, clap_param_rescan_flags flags);

// Clears references to a parameter.
// [main-thread]
void (*clear)(const clap_host_t *host, clap_id param_id, clap_param_clear_flags flags);
void (CLAP_ABI *clear)(const clap_host_t *host, clap_id param_id, clap_param_clear_flags flags);

// Request a parameter flush.
//
@@ -288,7 +288,7 @@ typedef struct clap_host_params {
// plugin would already be within process() or flush().
//
// [thread-safe,!audio-thread]
void (*request_flush)(const clap_host_t *host);
void (CLAP_ABI *request_flush)(const clap_host_t *host);
} clap_host_params_t;

#ifdef __cplusplus


+ 46
- 0
source/includes/clap/ext/posix-fd-support.h View File

@@ -0,0 +1,46 @@
#pragma once

#include "../plugin.h"

// This extension let your plugin hook itself into the host select/poll/epoll/kqueue reactor.
// This is useful to handle asynchronous I/O on the main thread.
static CLAP_CONSTEXPR const char CLAP_EXT_POSIX_FD_SUPPORT[] = "clap.posix-fd-support";

#ifdef __cplusplus
extern "C" {
#endif

enum {
// IO events flags, they can be used to form a mask which describes:
// - which events you are interested in (register_fd/modify_fd)
// - which events happened (on_fd)
CLAP_POSIX_FD_READ = 1 << 0,
CLAP_POSIX_FD_WRITE = 1 << 1,
CLAP_POSIX_FD_ERROR = 1 << 2,
};
typedef uint32_t clap_posix_fd_flags_t;

typedef struct clap_plugin_posix_fd_support {
// This callback is "level-triggered".
// It means that a writable fd will continuously produce "on_fd()" events;
// don't forget using modify_fd() to remove the write notification once you're
// done writting.
//
// [main-thread]
void(CLAP_ABI *on_fd)(const clap_plugin_t *plugin, int fd, clap_posix_fd_flags_t flags);
} clap_plugin_posix_fd_support_t;

typedef struct clap_host_posix_fd_support {
// [main-thread]
bool(CLAP_ABI *register_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags);

// [main-thread]
bool(CLAP_ABI *modify_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags);

// [main-thread]
bool(CLAP_ABI *unregister_fd)(const clap_host_t *host, int fd);
} clap_host_posix_fd_support_t;

#ifdef __cplusplus
}
#endif

+ 3
- 3
source/includes/clap/ext/state.h View File

@@ -13,19 +13,19 @@ typedef struct clap_plugin_state {
// Saves the plugin state into stream.
// Returns true if the state was correctly saved.
// [main-thread]
bool (*save)(const clap_plugin_t *plugin, const clap_ostream_t *stream);
bool (CLAP_ABI *save)(const clap_plugin_t *plugin, const clap_ostream_t *stream);

// Loads the plugin state from stream.
// Returns true if the state was correctly restored.
// [main-thread]
bool (*load)(const clap_plugin_t *plugin, const clap_istream_t *stream);
bool (CLAP_ABI *load)(const clap_plugin_t *plugin, const clap_istream_t *stream);
} clap_plugin_state_t;

typedef struct clap_host_state {
// Tell the host that the plugin state has changed and should be saved again.
// If a parameter value changes, then it is implicit that the state is dirty.
// [main-thread]
void (*mark_dirty)(const clap_host_t *host);
void (CLAP_ABI *mark_dirty)(const clap_host_t *host);
} clap_host_state_t;

#ifdef __cplusplus


+ 3
- 3
source/includes/clap/ext/timer-support.h View File

@@ -10,7 +10,7 @@ extern "C" {

typedef struct clap_plugin_timer_support {
// [main-thread]
void (*on_timer)(const clap_plugin_t *plugin, clap_id timer_id);
void (CLAP_ABI *on_timer)(const clap_plugin_t *plugin, clap_id timer_id);
} clap_plugin_timer_support_t;

typedef struct clap_host_timer_support {
@@ -18,10 +18,10 @@ typedef struct clap_host_timer_support {
// The host may adjust the period if it is under a certain threshold.
// 30 Hz should be allowed.
// [main-thread]
bool (*register_timer)(const clap_host_t *host, uint32_t period_ms, clap_id *timer_id);
bool (CLAP_ABI *register_timer)(const clap_host_t *host, uint32_t period_ms, clap_id *timer_id);

// [main-thread]
bool (*unregister_timer)(const clap_host_t *host, clap_id timer_id);
bool (CLAP_ABI *unregister_timer)(const clap_host_t *host, clap_id timer_id);
} clap_host_timer_support_t;

#ifdef __cplusplus


+ 4
- 4
source/includes/clap/host.h View File

@@ -19,21 +19,21 @@ typedef struct clap_host {

// Query an extension.
// [thread-safe]
const void *(*get_extension)(const struct clap_host *host, const char *extension_id);
const void *(CLAP_ABI *get_extension)(const struct clap_host *host, const char *extension_id);

// Request the host to deactivate and then reactivate the plugin.
// The operation may be delayed by the host.
// [thread-safe]
void (*request_restart)(const struct clap_host *host);
void (CLAP_ABI *request_restart)(const struct clap_host *host);

// Request the host to activate and start processing the plugin.
// This is useful if you have external IO and need to wake up the plugin from "sleep".
// [thread-safe]
void (*request_process)(const struct clap_host *host);
void (CLAP_ABI *request_process)(const struct clap_host *host);

// Request the host to schedule a call to plugin->on_main_thread(plugin) on the main thread.
// [thread-safe]
void (*request_callback)(const struct clap_host *host);
void (CLAP_ABI *request_callback)(const struct clap_host *host);
} clap_host_t;

#ifdef __cplusplus


+ 3
- 3
source/includes/clap/plugin-factory.h View File

@@ -15,13 +15,13 @@ extern "C" {
typedef struct clap_plugin_factory {
// Get the number of plugins available.
// [thread-safe]
uint32_t (*get_plugin_count)(const struct clap_plugin_factory *factory);
uint32_t (CLAP_ABI *get_plugin_count)(const struct clap_plugin_factory *factory);

// Retrieves a plugin descriptor by its index.
// Returns null in case of error.
// The descriptor must not be freed.
// [thread-safe]
const clap_plugin_descriptor_t *(*get_plugin_descriptor)(
const clap_plugin_descriptor_t *(CLAP_ABI *get_plugin_descriptor)(
const struct clap_plugin_factory *factory, uint32_t index);

// Create a clap_plugin by its plugin_id.
@@ -29,7 +29,7 @@ typedef struct clap_plugin_factory {
// The plugin is not allowed to use the host callbacks in the create method.
// Returns null in case of error.
// [thread-safe]
const clap_plugin_t *(*create_plugin)(const struct clap_plugin_factory *factory,
const clap_plugin_t *(CLAP_ABI *create_plugin)(const struct clap_plugin_factory *factory,
const clap_host_t *host,
const char *plugin_id);
} clap_plugin_factory_t;


+ 10
- 10
source/includes/clap/plugin.h View File

@@ -38,12 +38,12 @@ typedef struct clap_plugin {
// Must be called after creating the plugin.
// If init returns false, the host must destroy the plugin instance.
// [main-thread]
bool (*init)(const struct clap_plugin *plugin);
bool (CLAP_ABI *init)(const struct clap_plugin *plugin);

// Free the plugin and its resources.
// It is required to deactivate the plugin prior to this call.
// [main-thread & !active]
void (*destroy)(const struct clap_plugin *plugin);
void (CLAP_ABI *destroy)(const struct clap_plugin *plugin);

// Activate and deactivate the plugin.
// In this call the plugin may allocate memory and prepare everything needed for the process
@@ -52,21 +52,21 @@ typedef struct clap_plugin {
// Once activated the latency and port configuration must remain constant, until deactivation.
//
// [main-thread & !active_state]
bool (*activate)(const struct clap_plugin *plugin,
bool (CLAP_ABI *activate)(const struct clap_plugin *plugin,
double sample_rate,
uint32_t min_frames_count,
uint32_t max_frames_count);

// [main-thread & active_state]
void (*deactivate)(const struct clap_plugin *plugin);
void (CLAP_ABI *deactivate)(const struct clap_plugin *plugin);

// Call start processing before processing.
// [audio-thread & active_state & !processing_state]
bool (*start_processing)(const struct clap_plugin *plugin);
bool (CLAP_ABI *start_processing)(const struct clap_plugin *plugin);

// Call stop processing before sending the plugin to sleep.
// [audio-thread & active_state & processing_state]
void (*stop_processing)(const struct clap_plugin *plugin);
void (CLAP_ABI *stop_processing)(const struct clap_plugin *plugin);

// - Clears all buffers, performs a full reset of the processing state (filters, oscillators,
// enveloppes, lfo, ...) and kills all voices.
@@ -74,21 +74,21 @@ typedef struct clap_plugin {
// - clap_process.steady_time may jump backward.
//
// [audio-thread & active_state]
void (*reset)(const struct clap_plugin *plugin);
void (CLAP_ABI *reset)(const struct clap_plugin *plugin);

// process audio, events, ...
// [audio-thread & active_state & processing_state]
clap_process_status (*process)(const struct clap_plugin *plugin, const clap_process_t *process);
clap_process_status (CLAP_ABI *process)(const struct clap_plugin *plugin, const clap_process_t *process);

// Query an extension.
// The returned pointer is owned by the plugin.
// [thread-safe]
const void *(*get_extension)(const struct clap_plugin *plugin, const char *id);
const void *(CLAP_ABI *get_extension)(const struct clap_plugin *plugin, const char *id);

// Called by the host on the main thread in response to a previous call to:
// host->request_callback(host);
// [main-thread]
void (*on_main_thread)(const struct clap_plugin *plugin);
void (CLAP_ABI *on_main_thread)(const struct clap_plugin *plugin);
} clap_plugin_t;

#ifdef __cplusplus


+ 8
- 0
source/includes/clap/private/macros.h View File

@@ -17,6 +17,14 @@
# endif
#endif

#if !defined(CLAP_ABI)
# if defined _WIN32 || defined __CYGWIN__
# define CLAP_ABI __cdecl
# else
# define CLAP_ABI
# endif
#endif

#if defined(__cplusplus) && __cplusplus >= 201103L
# define CLAP_HAS_CXX11
# define CLAP_CONSTEXPR constexpr


+ 2
- 2
source/includes/clap/stream.h View File

@@ -11,14 +11,14 @@ typedef struct clap_istream {
void *ctx; // reserved pointer for the stream

// returns the number of bytes read; 0 indicates end of file and -1 a read error
int64_t (*read)(const struct clap_istream *stream, void *buffer, uint64_t size);
int64_t (CLAP_ABI *read)(const struct clap_istream *stream, void *buffer, uint64_t size);
} clap_istream_t;

typedef struct clap_ostream {
void *ctx; // reserved pointer for the stream

// returns the number of bytes written; -1 on write error
int64_t (*write)(const struct clap_ostream *stream, const void *buffer, uint64_t size);
int64_t (CLAP_ABI *write)(const struct clap_ostream *stream, const void *buffer, uint64_t size);
} clap_ostream_t;

#ifdef __cplusplus


+ 3
- 2
source/utils/CarlaClapUtils.hpp View File

@@ -28,6 +28,7 @@
#include "clap/ext/note-ports.h"
#include "clap/ext/gui.h"
#include "clap/ext/params.h"
#include "clap/ext/posix-fd-support.h"
#include "clap/ext/state.h"
#include "clap/ext/timer-support.h"

@@ -173,7 +174,7 @@ struct clap_istream_impl : clap_istream_t {
read = read_impl;
}

static int64_t read_impl(const clap_istream_t* const stream, void* const buffer, const uint64_t size) noexcept
static CLAP_ABI int64_t read_impl(const clap_istream_t* const stream, void* const buffer, const uint64_t size) noexcept
{
clap_istream_impl* const self = static_cast<clap_istream_impl*>(stream->ctx);

@@ -202,7 +203,7 @@ struct clap_ostream_impl : clap_ostream_t {
write = write_impl;
}

static int64_t write_impl(const clap_ostream* const stream, const void* const buffer, const uint64_t size) noexcept
static CLAP_ABI int64_t write_impl(const clap_ostream* const stream, const void* const buffer, const uint64_t size) noexcept
{
CARLA_SAFE_ASSERT_RETURN(size != 0, 0);



Loading…
Cancel
Save