commit 7b7de427c2bcd26944e6ffd186868d3f19b69dfa parent 855b3abe7a01224eef29aac6e1e9c1f880eb1f71 Author: Alexandre Bique <bique.alexandre@gmail.com> Date: Thu, 3 Mar 2022 09:39:59 +0100 Bunch of nodiscard Diffstat:
34 files changed, 192 insertions(+), 172 deletions(-)
diff --git a/include/clap/converters/clap-converter.h b/include/clap/converters/clap-converter.h @@ -13,25 +13,25 @@ typedef struct clap_clap_converter { const char *dst_plugin_id; // [main-thread] - bool (*convert_state)(const struct clap_clap_converter *converter, - const clap_istream_t *src, - const clap_ostream_t *dst); + CLAP_NODISCARD bool (*convert_state)(const struct clap_clap_converter *converter, + const clap_istream_t *src, + const clap_ostream_t *dst); // converts the clap param id and normalized value. // [thread-safe] - bool (*convert_normalized_value)(const struct clap_clap_converter *converter, - clap_id src_param_id, - double src_normalized_value, - clap_id *dst_param_id, - double *dst_normalized_value); + CLAP_NODISCARD bool (*convert_normalized_value)(const struct clap_clap_converter *converter, + clap_id src_param_id, + double src_normalized_value, + clap_id *dst_param_id, + double *dst_normalized_value); // converts the clap param id and plain value. // [thread-safe] - bool (*convert_plain_value)(const struct clap_clap_converter *converter, - clap_id src_param_id, - double src_plain_value, - clap_id *dst_param_id, - double *dst_plain_value); + CLAP_NODISCARD bool (*convert_plain_value)(const struct clap_clap_converter *converter, + clap_id src_param_id, + double src_plain_value, + clap_id *dst_param_id, + double *dst_plain_value); } clap_clap_converter_t; // Factory identifier @@ -40,11 +40,12 @@ static CLAP_CONSTEXPR const char CLAP_CLAP_CONVERTER_FACTORY_ID[] = "clap.clap-c // List all the converters available in the current DSO. typedef struct clap_clap_converter_factory { // Get the number of converters - uint32_t (*count)(const struct clap_clap_converter_factory *factory); + CLAP_NODISCARD uint32_t (*count)(const struct clap_clap_converter_factory *factory); // Get the converter at the given index - const clap_clap_converter_t *(*get)(const struct clap_clap_converter_factory *factory, - uint32_t index); + CLAP_NODISCARD const + clap_clap_converter_t *(*get)(const struct clap_clap_converter_factory *factory, + uint32_t index); } clap_clap_converter_factory_t; #ifdef __cplusplus diff --git a/include/clap/converters/vst2-converter.h b/include/clap/converters/vst2-converter.h @@ -14,25 +14,25 @@ typedef struct clap_vst2_converter { const char *clap_plugin_id; // [main-thread] - bool (*convert_state)(const struct clap_vst2_converter *converter, - const clap_istream_t *vst2, - const clap_ostream_t *clap); + CLAP_NODISCARD bool (*convert_state)(const struct clap_vst2_converter *converter, + const clap_istream_t *vst2, + const clap_ostream_t *clap); // converts the vst2 param id and normalized value to clap. // [thread-safe] - bool (*convert_normalized_value)(const struct clap_vst2_converter *converter, - uint32_t vst2_param_id, - double vst2_normalized_value, - clap_id *clap_param_id, - double *clap_normalized_value); + CLAP_NODISCARD bool (*convert_normalized_value)(const struct clap_vst2_converter *converter, + uint32_t vst2_param_id, + double vst2_normalized_value, + clap_id *clap_param_id, + double *clap_normalized_value); // converts the vst2 param id and plain value to clap. // [thread-safe] - bool (*convert_plain_value)(const struct clap_vst2_converter *converter, - uint32_t vst2_param_id, - double vst2_plain_value, - clap_id *clap_param_id, - double *clap_plain_value); + CLAP_NODISCARD bool (*convert_plain_value)(const struct clap_vst2_converter *converter, + uint32_t vst2_param_id, + double vst2_plain_value, + clap_id *clap_param_id, + double *clap_plain_value); } clap_vst2_converter_t; // Factory identifier @@ -41,11 +41,12 @@ static CLAP_CONSTEXPR const char CLAP_VST2_CONVERTER_FACTORY_ID[] = "clap.vst2-c // List all the converters available in the current DSO. typedef struct clap_vst2_converter_factory { // Get the number of converters - uint32_t (*count)(const struct clap_vst2_converter_factory *factory); + CLAP_NODISCARD uint32_t (*count)(const struct clap_vst2_converter_factory *factory); // Get the converter at the given index - const clap_vst2_converter_t *(*get)(const struct clap_vst2_converter_factory *factory, - uint32_t index); + CLAP_NODISCARD const + clap_vst2_converter_t *(*get)(const struct clap_vst2_converter_factory *factory, + uint32_t index); } clap_vst2_converter_factory_t; #ifdef __cplusplus diff --git a/include/clap/converters/vst3-converter.h b/include/clap/converters/vst3-converter.h @@ -15,26 +15,26 @@ typedef struct clap_vst3_converter { const char *clap_plugin_id; // [main-thread] - bool (*convert_state)(const struct clap_vst3_converter *converter, - const clap_istream_t *vst3_processor, - const clap_istream_t *vst3_editor, - const clap_ostream_t *clap); + CLAP_NODISCARD bool (*convert_state)(const struct clap_vst3_converter *converter, + const clap_istream_t *vst3_processor, + const clap_istream_t *vst3_editor, + const clap_ostream_t *clap); // converts the vst3 param id and normalized value to clap. // [thread-safe] - bool (*convert_normalized_value)(const struct clap_vst3_converter *converter, - uint32_t vst3_param_id, - double vst3_normalized_value, - clap_id *clap_param_id, - double *clap_normaliezd_value); + CLAP_NODISCARD bool (*convert_normalized_value)(const struct clap_vst3_converter *converter, + uint32_t vst3_param_id, + double vst3_normalized_value, + clap_id *clap_param_id, + double *clap_normaliezd_value); // converts the vst3 param id and plain value to clap. // [thread-safe] - bool (*convert_plain_value)(const struct clap_vst3_converter *converter, - uint32_t vst3_param_id, - double vst3_plain_value, - clap_id *clap_param_id, - double *clap_plain_value); + CLAP_NODISCARD bool (*convert_plain_value)(const struct clap_vst3_converter *converter, + uint32_t vst3_param_id, + double vst3_plain_value, + clap_id *clap_param_id, + double *clap_plain_value); } clap_vst3_converter_t; // Factory identifier @@ -43,11 +43,12 @@ static CLAP_CONSTEXPR const char CLAP_VST3_CONVERTER_FACTORY_ID[] = "clap.vst3-c // List all the converters available in the current DSO. typedef struct clap_vst3_converter_factory { // Get the number of converters - uint32_t (*count)(const struct clap_vst3_converter_factory *factory); + CLAP_NODISCARD uint32_t (*count)(const struct clap_vst3_converter_factory *factory); // Get the converter at the given index - const clap_vst3_converter_t *(*get)(const struct clap_vst3_converter_factory *factory, - uint32_t index); + CLAP_NODISCARD const + clap_vst3_converter_t *(*get)(const struct clap_vst3_converter_factory *factory, + uint32_t index); } clap_vst3_converter_factory_t; #ifdef __cplusplus diff --git a/include/clap/entry.h b/include/clap/entry.h @@ -3,7 +3,6 @@ #include "version.h" #include "private/macros.h" - #ifdef __cplusplus extern "C" { #endif @@ -39,7 +38,7 @@ typedef struct clap_plugin_entry { // // If the initialization depends upon expensive computation, maybe try to do them ahead of time // and cache the result. - bool (*init)(const char *plugin_path); + CLAP_NODISCARD bool (*init)(const char *plugin_path); // No more calls into the DSO must be made after calling deinit(). void (*deinit)(void); @@ -49,7 +48,7 @@ typedef struct clap_plugin_entry { // // 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); + CLAP_NODISCARD const void *(*get_factory)(const char *factory_id); } clap_plugin_entry_t; /* Entry point */ diff --git a/include/clap/ext/audio-ports-config.h b/include/clap/ext/audio-ports-config.h @@ -30,31 +30,33 @@ extern "C" { // Minimalistic description of ports configuration typedef struct clap_audio_ports_config { clap_id id; - char name[CLAP_NAME_SIZE]; + char name[CLAP_NAME_SIZE]; // main input info - uint32_t input_channel_count; + uint32_t input_channel_count; const char *input_port_type; // main output info - uint32_t output_channel_count; - const char * output_port_type; + uint32_t output_channel_count; + const char *output_port_type; } clap_audio_ports_config_t; // The audio ports config scan has to be done while the plugin is deactivated. typedef struct clap_plugin_audio_ports_config { // gets the number of available configurations // [main-thread] - uint32_t (*count)(const clap_plugin_t *plugin); + CLAP_NODISCARD uint32_t (*count)(const clap_plugin_t *plugin); // gets information about a configuration // [main-thread] - bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_audio_ports_config_t *config); + CLAP_NODISCARD bool (*get)(const clap_plugin_t *plugin, + uint32_t index, + clap_audio_ports_config_t *config); // selects the configuration designated by id // returns true if the configuration could be applied // [main-thread,plugin-deactivated] - bool (*select)(const clap_plugin_t *plugin, clap_id config_id); + CLAP_NODISCARD bool (*select)(const clap_plugin_t *plugin, clap_id config_id); } clap_plugin_audio_ports_config_t; typedef struct clap_host_audio_ports_config { diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -7,8 +7,8 @@ /// /// This extension provides a way for the plugin to describe its current audio ports. /// -/// If the plugin does not implement this extension, it will have a default 32 bits stereo input and output. -/// This makes 32 bit support a requirement for both plugin and host. +/// If the plugin does not implement this extension, it will have a default 32 bits stereo input and +/// output. This makes 32 bit support a requirement for both plugin and host. /// /// The plugin is only allowed to change its ports configuration while it is deactivated. @@ -30,8 +30,8 @@ enum { }; typedef struct clap_audio_port_info { - clap_id id; // stable identifier - char name[CLAP_NAME_SIZE]; // displayable name + clap_id id; // stable identifier + char name[CLAP_NAME_SIZE]; // displayable name uint32_t flags; uint32_t channel_count; @@ -57,14 +57,14 @@ 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); + CLAP_NODISCARD uint32_t (*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, - uint32_t index, - bool is_input, - clap_audio_port_info_t *info); + CLAP_NODISCARD bool (*get)(const clap_plugin_t *plugin, + uint32_t index, + bool is_input, + clap_audio_port_info_t *info); } clap_plugin_audio_ports_t; enum { @@ -90,7 +90,7 @@ 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)(uint32_t flag); + CLAP_NODISCARD bool (*is_rescan_flag_supported)(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. diff --git a/include/clap/ext/draft/ambisonic.h b/include/clap/ext/draft/ambisonic.h @@ -36,10 +36,10 @@ typedef struct clap_ambisonic_info { typedef struct clap_plugin_ambisonic { // Returns true on success // [main-thread] - bool (*get_info)(const clap_plugin_t *plugin, - bool is_input, - uint32_t port_index, - clap_ambisonic_info_t *info); + CLAP_NODISCARD bool (*get_info)(const clap_plugin_t *plugin, + bool is_input, + uint32_t port_index, + clap_ambisonic_info_t *info); } clap_plugin_ambisonic_t; diff --git a/include/clap/ext/draft/cv.h b/include/clap/ext/draft/cv.h @@ -23,10 +23,10 @@ typedef struct clap_plugin_cv { // Stores into the channel_map array, the surround identifer of each channels. // Returns the number of elements stored in channel_map // [main-thread] - uint32_t (*get_channel_type)(const clap_plugin_t *plugin, - bool is_input, - uint32_t port_index, - uint32_t channel_index); + CLAP_NODISCARD uint32_t (*get_channel_type)(const clap_plugin_t *plugin, + bool is_input, + uint32_t port_index, + uint32_t channel_index); } clap_plugin_cv_t; typedef struct clap_host_cv { diff --git a/include/clap/ext/draft/file-reference.h b/include/clap/ext/draft/file-reference.h @@ -25,36 +25,40 @@ extern "C" { typedef struct clap_file_reference { clap_id resource_id; - char path[CLAP_PATH_SIZE]; - bool belongs_to_plugin_collection; + char path[CLAP_PATH_SIZE]; + bool belongs_to_plugin_collection; } clap_file_reference_t; typedef struct clap_plugin_file_reference { // returns the number of file reference this plugin has // [main-thread] - uint32_t (*count)(const clap_plugin_t *plugin); + CLAP_NODISCARD uint32_t (*count)(const clap_plugin_t *plugin); // gets the file reference at index // returns true on success // [main-thread] - bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_file_reference_t *file_reference); + CLAP_NODISCARD bool (*get)(const clap_plugin_t *plugin, + uint32_t index, + clap_file_reference_t *file_reference); // This method does not compute the hash. // It is only used in case of missing resource. The host may have additionnal known resource // location and may be able to locate the file by using its known hash. // [main-thread] - bool (*get_hash)(const clap_plugin_t *plugin, - clap_id resource_id, - clap_hash hash, - uint8_t *digest, - uint32_t digest_size); + CLAP_NODISCARD bool (*get_hash)(const clap_plugin_t *plugin, + clap_id resource_id, + clap_hash hash, + uint8_t *digest, + uint32_t digest_size); // updates the path to a file reference // [main-thread] - bool (*update_path)(const clap_plugin_t *plugin, clap_id resource_id, const char *path); + CLAP_NODISCARD bool (*update_path)(const clap_plugin_t *plugin, + clap_id resource_id, + const char *path); // [main-thread] - bool (*save_resources)(const clap_plugin_t *plugin); + CLAP_NODISCARD bool (*save_resources)(const clap_plugin_t *plugin); } clap_plugin_file_reference_t; typedef struct clap_host_file_reference { diff --git a/include/clap/ext/draft/midi-mappings.h b/include/clap/ext/draft/midi-mappings.h @@ -27,7 +27,9 @@ typedef struct clap_plugin_midi_mappings { uint32_t (*count)(const clap_plugin_t *plugin); // [main-thread] - bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_midi_mapping_t *mapping); + CLAP_NODISCARD bool (*get)(const clap_plugin_t *plugin, + uint32_t index, + clap_midi_mapping_t *mapping); } clap_plugin_midi_mappings_t; typedef struct clap_host_midi_mappings { diff --git a/include/clap/ext/draft/preset-load.h b/include/clap/ext/draft/preset-load.h @@ -11,7 +11,7 @@ extern "C" { typedef struct clap_plugin_preset_load { // Loads a preset in the plugin native preset file format from a path. // [main-thread] - bool (*from_file)(const clap_plugin_t *plugin, const char *path); + CLAP_NODISCARD bool (*from_file)(const clap_plugin_t *plugin, const char *path); } clap_plugin_preset_load_t; #ifdef __cplusplus diff --git a/include/clap/ext/draft/surround.h b/include/clap/ext/draft/surround.h @@ -57,11 +57,11 @@ typedef struct clap_plugin_surround { // Stores into the channel_map array, the surround identifer of each channels. // Returns the number of elements stored in channel_map // [main-thread] - uint32_t (*get_channel_map)(const clap_plugin_t *plugin, - bool is_input, - uint32_t port_index, - uint8_t *channel_map, - uint32_t channel_map_capacity); + CLAP_NODISCARD uint32_t (*get_channel_map)(const clap_plugin_t *plugin, + bool is_input, + uint32_t port_index, + uint8_t *channel_map, + uint32_t channel_map_capacity); // Informs the plugin that the host preferred channel map has changed. // [main-thread] diff --git a/include/clap/ext/draft/track-info.h b/include/clap/ext/draft/track-info.h @@ -16,7 +16,7 @@ typedef struct clap_track_info { char name[CLAP_NAME_SIZE]; char path[CLAP_MODULE_SIZE]; // Like "/group1/group2/drum-machine/drum-pad-13" int32_t channel_count; - const char *audio_port_type; + const char *audio_port_type; clap_color_t color; bool is_return_track; } clap_track_info_t; @@ -29,7 +29,7 @@ typedef struct clap_plugin_track_info { typedef struct clap_host_track_info { // Get info about the track the plugin belongs to. // [main-thread] - bool (*get)(const clap_host_t *host, clap_track_info_t *info); + CLAP_NODISCARD bool (*get)(const clap_host_t *host, clap_track_info_t *info); } clap_host_track_info_t; #ifdef __cplusplus diff --git a/include/clap/ext/draft/tuning.h b/include/clap/ext/draft/tuning.h @@ -16,7 +16,7 @@ typedef struct clap_host_tuning { // The plugin is not supposed to query it for each samples, // but at a rate that makes sense for low frequency modulations. // [audio-thread] - double (*get)(const clap_host_t *host, int32_t key, int32_t channel); + CLAP_NODISCARD double (*get)(const clap_host_t *host, int32_t key, int32_t channel); } clap_host_tuning_t; #ifdef __cplusplus diff --git a/include/clap/ext/event-filter.h b/include/clap/ext/event-filter.h @@ -19,10 +19,11 @@ extern "C" { typedef struct clap_plugin_event_filter { // Returns true if the plugin is interested in the given event type. // [main-thread] - bool (*accepts)(const clap_plugin_t *plugin, uint16_t space_id, uint16_t event_type); + CLAP_NODISCARD bool (*accepts)(const clap_plugin_t *plugin, + uint16_t space_id, + uint16_t event_type); } clap_plugin_event_filter_t; - typedef struct clap_host_event_filter { // Informs the host that the set of accepted event type changed. // This requires the plugin to be deactivated. diff --git a/include/clap/ext/event-registry.h b/include/clap/ext/event-registry.h @@ -14,7 +14,9 @@ typedef struct clap_host_event_registry { // // Return false and sets *space to UINT16_MAX if the space name is unknown to the host. // [main-thread] - bool (*query)(const clap_host_t *host, const char *space_name, uint16_t *space_id); + CLAP_NODISCARD bool (*query)(const clap_host_t *host, + const char *space_name, + uint16_t *space_id); } clap_host_event_registry_t; #ifdef __cplusplus diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h @@ -51,7 +51,7 @@ extern "C" { #endif typedef struct clap_gui_window_x11 { - const char *display; + const char *display; unsigned long window; } clap_gui_window_x11_t; @@ -76,16 +76,16 @@ typedef struct clap_gui_window { typedef struct clap_plugin_gui { // Returns true if the given windowing API is supported by the plugin // [main-thread] - bool (*is_api_supported)(const clap_plugin_t *plugin, const char *api); + CLAP_NODISCARD bool (*is_api_supported)(const clap_plugin_t *plugin, const char *api); // Returns the identifier of the preferred windowing API. // [main-thread] - const char *(*get_preferred_api)(const clap_plugin_t *plugin); + CLAP_NODISCARD const char *(*get_preferred_api)(const clap_plugin_t *plugin); // Create and allocate all resources necessary for the gui, and for the given windowing API. // After this call, the GUI is ready to be shown but it is not yet visible. // [main-thread] - bool (*create)(const clap_plugin_t *plugin, const char *api); + CLAP_NODISCARD bool (*create)(const clap_plugin_t *plugin, const char *api); // Free all resources associated with the gui. // [main-thread] @@ -97,36 +97,40 @@ typedef struct clap_plugin_gui { // // Return false if the plugin can't apply the scaling; true on success. // [main-thread,optional] - bool (*set_scale)(const clap_plugin_t *plugin, double scale); + CLAP_NODISCARD bool (*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); + CLAP_NODISCARD bool (*get_size)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height); // [main-thread] - bool (*can_resize)(const clap_plugin_t *plugin); + CLAP_NODISCARD bool (*can_resize)(const clap_plugin_t *plugin); // If the plugin gui is resizable, then the plugin will calculate the closest // usable size which fits in the given size. // This method does not change the size. // // [main-thread] - bool (*compute_size_to_fit)(const clap_plugin_t *plugin, uint32_t *width, uint32_t *height); + CLAP_NODISCARD bool (*compute_size_to_fit)(const clap_plugin_t *plugin, + uint32_t *width, + uint32_t *height); // Sets the window size // Returns true if the size is supported. // [main-thread] - bool (*set_size)(const clap_plugin_t *plugin, uint32_t width, uint32_t height); + CLAP_NODISCARD bool (*set_size)(const clap_plugin_t *plugin, uint32_t width, uint32_t height); // Attaches the plugin's window to the given parent window. // [main-thread] - bool (*attach)(const clap_plugin_t *plugin, const clap_gui_window_t *parent_window); + CLAP_NODISCARD bool (*attach)(const clap_plugin_t *plugin, + const clap_gui_window_t *parent_window); // In case the window was created with the "free" windowing API. // Sets the window to which the plugin's window shall stay above. // [main-thread] - bool (*set_transient)(const clap_plugin_t *plugin, const clap_gui_window_t *daw_window); + CLAP_NODISCARD bool (*set_transient)(const clap_plugin_t *plugin, + const clap_gui_window_t *daw_window); // Suggests a window title. Only useful when using the "free" windowing API. // [main-thread] @@ -147,17 +151,17 @@ typedef struct clap_host_gui { * Return true if the new size is accepted, false otherwise. * The host doesn't have to call set_size(). * [main-thread] */ - bool (*request_resize)(const clap_host_t *host, uint32_t width, uint32_t height); + CLAP_NODISCARD bool (*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. * [main-thread] */ - bool (*request_show)(const clap_host_t *host); + CLAP_NODISCARD bool (*request_show)(const clap_host_t *host); /* Request the host to hide the plugin gui. * Return true on success, false otherwise. * [main-thread] */ - bool (*request_hide)(const clap_host_t *host); + CLAP_NODISCARD bool (*request_hide)(const clap_host_t *host); } clap_host_gui_t; #ifdef __cplusplus diff --git a/include/clap/ext/latency.h b/include/clap/ext/latency.h @@ -12,7 +12,7 @@ extern "C" { typedef struct clap_plugin_latency { // Returns the plugin latency. // [main-thread] - uint32_t (*get)(const clap_plugin_t *plugin); + CLAP_NODISCARD uint32_t (*get)(const clap_plugin_t *plugin); } clap_plugin_latency_t; typedef struct clap_host_latency { diff --git a/include/clap/ext/note-name.h b/include/clap/ext/note-name.h @@ -19,11 +19,11 @@ typedef struct clap_note_name { typedef struct clap_plugin_note_name { // Return the number of note names // [main-thread] - uint32_t (*count)(const clap_plugin_t *plugin); + CLAP_NODISCARD uint32_t (*count)(const clap_plugin_t *plugin); // Returns true on success and stores the result into note_name // [main-thread] - bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_note_name_t *note_name); + CLAP_NODISCARD bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_note_name_t *note_name); } clap_plugin_note_name; typedef struct clap_host_note_name { diff --git a/include/clap/ext/note-ports.h b/include/clap/ext/note-ports.h @@ -33,24 +33,24 @@ enum clap_note_dialect { }; typedef struct clap_note_port_info { - clap_id id; // stable identifier - uint32_t supported_dialects; // bitfield, see clap_note_dialect - uint32_t preferred_dialect; // one value of clap_note_dialect - char name[CLAP_NAME_SIZE]; // displayable name, i18n? + clap_id id; // stable identifier + uint32_t supported_dialects; // bitfield, see clap_note_dialect + uint32_t preferred_dialect; // one value of clap_note_dialect + char name[CLAP_NAME_SIZE]; // displayable name, i18n? } clap_note_port_info_t; // The note ports scan has to be done while the plugin is deactivated. typedef struct clap_plugin_note_ports { // number of ports, for either input or output // [main-thread] - uint32_t (*count)(const clap_plugin_t *plugin, bool is_input); + CLAP_NODISCARD uint32_t (*count)(const clap_plugin_t *plugin, bool is_input); // get info about about a note port. // [main-thread] - bool (*get)(const clap_plugin_t *plugin, - uint32_t index, - bool is_input, - clap_note_port_info_t *info); + CLAP_NODISCARD bool (*get)(const clap_plugin_t *plugin, + uint32_t index, + bool is_input, + clap_note_port_info_t *info); } clap_plugin_note_ports_t; enum { @@ -67,7 +67,7 @@ enum { typedef struct clap_host_note_ports { // Query which dialects the host supports // [main-thread] - uint32_t (*supported_dialects)(const clap_host_t *host); + CLAP_NODISCARD uint32_t (*supported_dialects)(const clap_host_t *host); // Rescan the full list of note ports according to the flags. // [main-thread] diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -155,8 +155,8 @@ typedef struct clap_param_info { char name[CLAP_NAME_SIZE]; // the display name char module[CLAP_MODULE_SIZE]; // the module containing the param, eg: - // "oscillators/wt1"; '/' will be used as a - // separator to show a tree like structure. + // "oscillators/wt1"; '/' will be used as a + // separator to show a tree like structure. double min_value; // minimum plain value double max_value; // maximum plain value @@ -166,31 +166,31 @@ 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); + CLAP_NODISCARD uint32_t (*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, - uint32_t param_index, - clap_param_info_t *param_info); + CLAP_NODISCARD bool (*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); + CLAP_NODISCARD bool (*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)( + CLAP_NODISCARD bool (*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, - clap_id param_id, - const char *display, - double *value); + CLAP_NODISCARD bool (*text_to_value)(const clap_plugin_t *plugin, + clap_id param_id, + const char *display, + double *value); // Flushes a set of parameter changes. // This method must not be called concurrently to clap_plugin->process(). diff --git a/include/clap/ext/posix-fd-support.h b/include/clap/ext/posix-fd-support.h @@ -27,13 +27,13 @@ typedef struct clap_plugin_posix_fd_support { typedef struct clap_host_posix_fd_support { // [main-thread] - bool (*register_fd)(const clap_host_t *host, int fd, int flags); + CLAP_NODISCARD bool (*register_fd)(const clap_host_t *host, int fd, int flags); // [main-thread] - bool (*modify_fd)(const clap_host_t *host, int fd, int flags); + CLAP_NODISCARD bool (*modify_fd)(const clap_host_t *host, int fd, int flags); // [main-thread] - bool (*unregister_fd)(const clap_host_t *host, int fd); + CLAP_NODISCARD bool (*unregister_fd)(const clap_host_t *host, int fd); } clap_host_posix_fd_support_t; #ifdef __cplusplus diff --git a/include/clap/ext/render.h b/include/clap/ext/render.h @@ -27,11 +27,11 @@ typedef struct clap_plugin_render { // Returns true if the plugin has an hard requirement to process in real-time. // This is especially useful for plugin acting as a proxy to an hardware device. // [main-thread] - bool (*has_hard_realtime_requirement)(const clap_plugin_t *plugin); + CLAP_NODISCARD bool (*has_hard_realtime_requirement)(const clap_plugin_t *plugin); // Returns true if the rendering mode could be applied. // [main-thread] - bool (*set)(const clap_plugin_t *plugin, clap_plugin_render_mode mode); + CLAP_NODISCARD bool (*set)(const clap_plugin_t *plugin, clap_plugin_render_mode mode); } clap_plugin_render_t; #ifdef __cplusplus diff --git a/include/clap/ext/state.h b/include/clap/ext/state.h @@ -13,12 +13,12 @@ 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, clap_ostream_t *stream); + CLAP_NODISCARD bool (*save)(const clap_plugin_t *plugin, 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, clap_istream_t *stream); + CLAP_NODISCARD bool (*load)(const clap_plugin_t *plugin, clap_istream_t *stream); } clap_plugin_state_t; typedef struct clap_host_state { diff --git a/include/clap/ext/tail.h b/include/clap/ext/tail.h @@ -11,7 +11,7 @@ extern "C" { typedef struct clap_plugin_tail { // Returns tail length in samples. // [main-thread,audio-thread] - uint32_t (*get)(const clap_plugin_t *plugin); + CLAP_NODISCARD uint32_t (*get)(const clap_plugin_t *plugin); } clap_plugin_tail_t; typedef struct clap_host_tail { diff --git a/include/clap/ext/thread-check.h b/include/clap/ext/thread-check.h @@ -14,11 +14,11 @@ extern "C" { typedef struct clap_host_thread_check { // Returns true if "this" thread is the main thread. // [thread-safe] - bool (*is_main_thread)(const clap_host_t *host); + CLAP_NODISCARD bool (*is_main_thread)(const clap_host_t *host); // Returns true if "this" thread is one of the audio threads. // [thread-safe] - bool (*is_audio_thread)(const clap_host_t *host); + CLAP_NODISCARD bool (*is_audio_thread)(const clap_host_t *host); } clap_host_thread_check_t; #ifdef __cplusplus diff --git a/include/clap/ext/thread-pool.h b/include/clap/ext/thread-pool.h @@ -58,7 +58,7 @@ typedef struct clap_host_thread_pool { // The host should check that the plugin is within the process call, and if not, reject the exec // request. // [audio-thread] - bool (*request_exec)(const clap_host_t *host, uint32_t num_tasks); + CLAP_NODISCARD bool (*request_exec)(const clap_host_t *host, uint32_t num_tasks); } clap_host_thread_pool_t; #ifdef __cplusplus diff --git a/include/clap/ext/timer-support.h b/include/clap/ext/timer-support.h @@ -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); + CLAP_NODISCARD bool (*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); + CLAP_NODISCARD bool (*unregister_timer)(const clap_host_t *host, clap_id timer_id); } clap_host_timer_support_t; #ifdef __cplusplus diff --git a/include/clap/hash.h b/include/clap/hash.h @@ -1,6 +1,6 @@ #pragma once -#include "clap.h" +#include "private/std.h" #ifdef __cplusplus extern "C" { diff --git a/include/clap/host.h b/include/clap/host.h @@ -19,7 +19,8 @@ typedef struct clap_host { // Query an extension. // [thread-safe] - const void *(*get_extension)(const struct clap_host *host, const char *extension_id); + CLAP_NODISCARD const void *(*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. diff --git a/include/clap/plugin-factory.h b/include/clap/plugin-factory.h @@ -15,23 +15,24 @@ 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); + CLAP_NODISCARD uint32_t (*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 struct clap_plugin_factory *factory, uint32_t index); + CLAP_NODISCARD const + clap_plugin_descriptor_t *(*get_plugin_descriptor)(const struct clap_plugin_factory *factory, + uint32_t index); /* Create a clap_plugin by its plugin_id. * The returned pointer must be freed by calling plugin->destroy(plugin); * 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_host_t *host, - const char *plugin_id); + CLAP_NODISCARD const clap_plugin_t *(*create_plugin)(const struct clap_plugin_factory *factory, + const clap_host_t *host, + const char *plugin_id); } clap_plugin_factory_t; #ifdef __cplusplus diff --git a/include/clap/plugin-invalidation.h b/include/clap/plugin-invalidation.h @@ -1,5 +1,6 @@ #pragma once +#include "private/std.h" #include "private/macros.h" #ifdef __cplusplus @@ -26,17 +27,17 @@ static const CLAP_CONSTEXPR char CLAP_PLUGIN_INVALIDATION_FACTORY_ID[] = // This interfaces solves this issue and gives a way to the host to monitor additional files. typedef struct clap_plugin_invalidation_factory { // Get the number of invalidation source. - uint32_t (*count)(const struct clap_plugin_invalidation_factory *factory); + CLAP_NODISCARD uint32_t (*count)(const struct clap_plugin_invalidation_factory *factory); // Get the invalidation source by its index. // [thread-safe] - const clap_plugin_invalidation_source_t *(*get)( + CLAP_NODISCARD const clap_plugin_invalidation_source_t *(*get)( const struct clap_plugin_invalidation_factory *factory, uint32_t index); // In case the host detected a invalidation event, it can call refresh() to let the // plugin_entry scan the set of plugins available. // If the function returned false, then the plugin needs to be reloaded. - bool (*refresh)(const struct clap_plugin_invalidation_factory *factory); + CLAP_NODISCARD bool (*refresh)(const struct clap_plugin_invalidation_factory *factory); } clap_plugin_invalidation_factory_t; #ifdef __cplusplus diff --git a/include/clap/plugin.h b/include/clap/plugin.h @@ -4,7 +4,6 @@ #include "host.h" #include "process.h" - #ifdef __cplusplus extern "C" { #endif @@ -54,7 +53,7 @@ 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); + CLAP_NODISCARD bool (*init)(const struct clap_plugin *plugin); // Free the plugin and its resources. // It is not required to deactivate the plugin prior to this call. @@ -68,16 +67,16 @@ 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, - double sample_rate, - uint32_t min_frames_count, - uint32_t max_frames_count); + CLAP_NODISCARD bool (*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); // Call start processing before processing. // [audio-thread & active_state & !processing_state] - bool (*start_processing)(const struct clap_plugin *plugin); + CLAP_NODISCARD bool (*start_processing)(const struct clap_plugin *plugin); // Call stop processing before sending the plugin to sleep. // [audio-thread & active_state & processing_state] diff --git a/include/clap/version.h b/include/clap/version.h @@ -29,6 +29,7 @@ static CLAP_CONSTEXPR const clap_version_t CLAP_VERSION = { // For version 0, we require the same minor version because // we may still break the ABI at this point -static CLAP_CONSTEXPR inline bool clap_version_is_compatible(const clap_version_t v) { +static CLAP_NODISCARD CLAP_CONSTEXPR inline bool +clap_version_is_compatible(const clap_version_t v) { return v.major == CLAP_VERSION_MAJOR && v.minor == CLAP_VERSION_MINOR; }