clap

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

commit 0183f23dd2d793c50d1dc8828f7278a8a8b31411
parent 732594d677deff37e11ba8c0455bff885a5e439a
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Tue, 21 Dec 2021 10:16:39 +0100

More work on alignment

Diffstat:
MCMakeLists.txt | 5+++++
Minclude/clap/audio-buffer.h | 2+-
Minclude/clap/converters/clap-converter.h | 5+++++
Minclude/clap/converters/vst2-converter.h | 5+++++
Minclude/clap/converters/vst3-converter.h | 5+++++
Minclude/clap/entry.h | 2+-
Minclude/clap/events.h | 2+-
Minclude/clap/ext/audio-ports-config.h | 18+++++++++++-------
Minclude/clap/ext/audio-ports.h | 25++++++++++++++-----------
Minclude/clap/ext/draft/check-for-update.h | 8++++++--
Minclude/clap/ext/draft/file-reference.h | 12++++++++----
Minclude/clap/ext/draft/midi-mappings.h | 12++++++++----
Minclude/clap/ext/draft/preset-load.h | 6+++++-
Minclude/clap/ext/draft/quick-controls.h | 14+++++++++-----
Minclude/clap/ext/draft/track-info.h | 22+++++++++++++---------
Minclude/clap/ext/draft/tuning.h | 6+++++-
Minclude/clap/ext/event-filter.h | 6+++++-
Minclude/clap/ext/fd-support.h | 6+++++-
Minclude/clap/ext/gui-cocoa.h | 6+++++-
Minclude/clap/ext/gui-free-standing.h | 6+++++-
Minclude/clap/ext/gui-win32.h | 6+++++-
Minclude/clap/ext/gui-x11.h | 6+++++-
Minclude/clap/ext/gui.h | 6+++++-
Minclude/clap/ext/latency.h | 7+++++--
Minclude/clap/ext/log.h | 6+++++-
Minclude/clap/ext/note-name.h | 14+++++++++-----
Minclude/clap/ext/note-ports.h | 11+++++++----
Minclude/clap/ext/params.h | 36+++++++++++++++++++++---------------
Minclude/clap/ext/render.h | 6+++++-
Minclude/clap/ext/state.h | 6+++++-
Minclude/clap/ext/thread-check.h | 6+++++-
Minclude/clap/ext/thread-pool.h | 6+++++-
Minclude/clap/ext/timer-support.h | 6+++++-
Minclude/clap/host.h | 2+-
Minclude/clap/plugin-factory.h | 2+-
Minclude/clap/plugin.h | 2+-
Minclude/clap/private/align.h | 6++++--
Minclude/clap/process.h | 2+-
Minclude/clap/stream.h | 2+-
Minclude/clap/string-sizes.h | 6+++---
Minclude/clap/version.h | 2+-
41 files changed, 222 insertions(+), 97 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -23,3 +23,8 @@ if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Cl target_compile_options(clap-compile-test-c PRIVATE -Wall -Wextra -pedantic) target_compile_options(clap-compile-test-cpp PRIVATE -Wall -Wextra -pedantic) endif() + +if (${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + target_compile_options(clap-compile-test-c PRIVATE -Werror=pragma-pack) + target_compile_options(clap-compile-test-cpp PRIVATE -Werror=pragma-pack) +endif() diff --git a/include/clap/audio-buffer.h b/include/clap/audio-buffer.h @@ -8,7 +8,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) typedef struct clap_audio_buffer { // Either data32 or data64 pointer will be set. diff --git a/include/clap/converters/clap-converter.h b/include/clap/converters/clap-converter.h @@ -2,11 +2,14 @@ #include "../clap.h" #include "../stream.h" +#include "../private/align.h" #ifdef __cplusplus extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // This interface provide all the tool to convert a vst3 plugin instance into a clap plugin instance typedef struct clap_clap_converter { const char *src_plugin_id; @@ -40,6 +43,8 @@ typedef struct clap_clap_converter_factory { uint32_t index); } clap_clap_converter_factory_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/converters/vst2-converter.h b/include/clap/converters/vst2-converter.h @@ -2,11 +2,14 @@ #include "../clap.h" #include "../stream.h" +#include "../private/align.h" #ifdef __cplusplus extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // This interface provide all the tool to convert a vst2 plugin instance into a clap plugin instance typedef struct clap_vst2_converter { uint32_t vst2_plugin_id; @@ -50,6 +53,8 @@ typedef struct clap_vst2_converter_factory { uint32_t index); } clap_vst2_converter_factory_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/converters/vst3-converter.h b/include/clap/converters/vst3-converter.h @@ -2,11 +2,14 @@ #include "../clap.h" #include "../stream.h" +#include "../private/align.h" #ifdef __cplusplus extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // This interface provide all the tool to convert a vst3 plugin instance into a clap plugin instance typedef struct clap_vst3_converter { const char *vst3_plugin_id; @@ -49,6 +52,8 @@ typedef struct clap_vst3_converter_factory { uint32_t index); } clap_vst3_converter_factory_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/entry.h b/include/clap/entry.h @@ -9,7 +9,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) // This interface is the entry point of the dynamic library. // diff --git a/include/clap/events.h b/include/clap/events.h @@ -11,7 +11,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) enum { CLAP_EVENT_NOTE_ON, // press a key; note attribute diff --git a/include/clap/ext/audio-ports-config.h b/include/clap/ext/audio-ports-config.h @@ -1,8 +1,8 @@ #pragma once -#include "../clap.h" #include "../chmap.h" #include "../string-sizes.h" +#include "../plugin.h" /// @page Audio Ports Config /// @@ -28,18 +28,20 @@ static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS_CONFIG[] = "clap.audio-por extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // Minimalistic description of ports configuration typedef struct clap_audio_ports_config { - clap_id id; - char name[CLAP_NAME_SIZE]; + alignas(4) clap_id id; + alignas(1) char name[CLAP_NAME_SIZE]; // main input info - uint32_t input_channel_count; - clap_chmap input_channel_map; + alignas(4) uint32_t input_channel_count; + alignas(4) clap_chmap input_channel_map; // main output info - uint32_t output_channel_count; - clap_chmap output_channel_map; + alignas(4) uint32_t output_channel_count; + alignas(4) clap_chmap output_channel_map; } clap_audio_ports_config_t; // The audio ports config scan has to be done while the plugin is deactivated. @@ -64,6 +66,8 @@ typedef struct clap_host_audio_ports_config { void (*rescan)(const clap_host_t *host); } clap_host_audio_ports_config_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" #include "../chmap.h" #include "../string-sizes.h" @@ -18,19 +18,20 @@ static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS[] = "clap.audio-ports"; extern "C" { #endif -typedef struct clap_audio_port_info { - clap_id id; // stable identifier - char name[CLAP_NAME_SIZE]; // displayable name +#pragma pack(push, CLAP_ALIGN) - uint32_t channel_count; - clap_chmap channel_map; - uint32_t sample_size; // 32 for float and 64 for double +typedef struct clap_audio_port_info { + alignas(4) clap_id id; // stable identifier + alignas(1) char name[CLAP_NAME_SIZE]; // displayable name - bool is_main; // there can only be 1 main input and output - bool is_cv; // control voltage - bool in_place; // if true the daw can use the same buffer for input - // and output, only for main input to main output + alignas(4) uint32_t channel_count; + alignas(4) clap_chmap channel_map; + alignas(4) uint32_t sample_size; // 32 for float and 64 for double + alignas(1) bool is_main; // there can only be 1 main input and output + alignas(1) bool is_cv; // control voltage + alignas(1) bool in_place; // if true the daw can use the same buffer for input + // and output, only for main input to main output } clap_audio_port_info_t; // The audio ports scan has to be done while the plugin is deactivated. @@ -67,6 +68,8 @@ typedef struct clap_host_audio_ports { void (*rescan)(const clap_host_t *host, uint32_t flags); } clap_host_audio_ports_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif diff --git a/include/clap/ext/draft/check-for-update.h b/include/clap/ext/draft/check-for-update.h @@ -1,6 +1,6 @@ #pragma once -#include "../../clap.h" +#include "../../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_CHECK_FOR_UPDATE[] = "clap.check_for_update.draft/0"; @@ -8,12 +8,14 @@ static CLAP_CONSTEXPR const char CLAP_EXT_CHECK_FOR_UPDATE[] = "clap.check_for_u extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_check_for_update_info { const char *version; const char *release_date; // YYYY-MM-DD const char *url; - bool is_stable; + alignas(1) bool is_stable; } clap_check_for_update_info_t; typedef struct clap_plugin_check_for_update { @@ -26,6 +28,8 @@ typedef struct clap_host_check_for_update { void (*on_new_version)(const clap_host_t *host, const clap_check_for_update_info_t *update_info); } clap_host_check_for_update_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/draft/file-reference.h b/include/clap/ext/draft/file-reference.h @@ -1,6 +1,6 @@ #pragma once -#include "../../clap.h" +#include "../../plugin.h" #include "../../hash.h" #include "../../string-sizes.h" @@ -10,6 +10,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_FILE_REFERENCE[] = "clap.file-referenc extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + /// @page File Reference /// /// This extension provides a way for the host to know about files which are used @@ -24,9 +26,9 @@ extern "C" { /// and needs to be saved. typedef struct clap_file_reference { - clap_id resource_id; - char path[CLAP_PATH_SIZE]; - bool belongs_to_plugin_collection; + alignas(4) clap_id resource_id; + alignas(1) char path[CLAP_PATH_SIZE]; + alignas(1) bool belongs_to_plugin_collection; } clap_file_reference_t; typedef struct clap_plugin_file_reference { @@ -66,6 +68,8 @@ typedef struct clap_host_file_reference { void (*set_dirty)(const clap_host_t *host, clap_id resource_id); } clap_host_file_reference; +#pragma pack(pop) + #ifdef __cplusplus } #endif diff --git a/include/clap/ext/draft/midi-mappings.h b/include/clap/ext/draft/midi-mappings.h @@ -1,6 +1,6 @@ #pragma once -#include "../../clap.h" +#include "../../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_MIDI_MAPPINGS[] = "clap.midi-mappings.draft/0"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_MIDI_MAPPINGS[] = "clap.midi-mappings. extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + enum { CLAP_MIDI_MAPPING_CC7, CLAP_MIDI_MAPPING_CC14, @@ -17,9 +19,9 @@ enum { typedef int32_t clap_midi_mapping_type; typedef struct clap_midi_mapping { - int32_t channel; - int32_t number; - clap_id param_id; + alignas(4) int32_t channel; + alignas(4) int32_t number; + alignas(4) clap_id param_id; } clap_midi_mapping_t; typedef struct clap_plugin_midi_mappings { @@ -35,6 +37,8 @@ typedef struct clap_host_midi_mappings { void (*changed)(const clap_host_t *host); } clap_host_midi_mappings_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/draft/preset-load.h b/include/clap/ext/draft/preset-load.h @@ -1,6 +1,6 @@ #pragma once -#include "../../clap.h" +#include "../../plugin.h" static const char CLAP_EXT_PRESET_LOAD[] = "clap.preset-load.draft/0"; @@ -8,12 +8,16 @@ static const char CLAP_EXT_PRESET_LOAD[] = "clap.preset-load.draft/0"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + 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_plugin_preset_load_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/draft/quick-controls.h b/include/clap/ext/draft/quick-controls.h @@ -1,6 +1,6 @@ #pragma once -#include "../../clap.h" +#include "../../plugin.h" #include "../../string-sizes.h" static CLAP_CONSTEXPR const char CLAP_EXT_QUICK_CONTROLS[] = "clap.quick-controls.draft/0"; @@ -9,13 +9,15 @@ static CLAP_CONSTEXPR const char CLAP_EXT_QUICK_CONTROLS[] = "clap.quick-control extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + enum { CLAP_QUICK_CONTROLS_COUNT = 8 }; typedef struct clap_quick_controls_page { - clap_id id; - char name[CLAP_NAME_SIZE]; - char keywords[CLAP_KEYWORDS_SIZE]; - clap_id param_ids[CLAP_QUICK_CONTROLS_COUNT]; + alignas(4) clap_id id; + alignas(1) char name[CLAP_NAME_SIZE]; + alignas(1) char keywords[CLAP_KEYWORDS_SIZE]; + alignas(4) clap_id param_ids[CLAP_QUICK_CONTROLS_COUNT]; } clap_quick_controls_page_t; typedef struct clap_plugin_quick_controls { @@ -44,6 +46,8 @@ typedef struct clap_host_quick_controls { void (*changed)(const clap_host_t *host, clap_quick_controls_changed_flags flags); } clap_host_quick_controls_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/draft/track-info.h b/include/clap/ext/draft/track-info.h @@ -1,6 +1,6 @@ #pragma once -#include "../../clap.h" +#include "../../plugin.h" #include "../../chmap.h" #include "../../color.h" #include "../../string-sizes.h" @@ -11,15 +11,17 @@ static CLAP_CONSTEXPR const char CLAP_EXT_TRACK_INFO[] = "clap.track-info.draft/ extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_track_info { - clap_id id; - int32_t index; - char name[CLAP_NAME_SIZE]; - char path[512]; // Like "/group1/group2/drum-machine/drum-pad-13" - int32_t channel_count; - clap_chmap channel_map; - clap_color_t color; - bool is_return_track; + alignas(4) clap_id id; + alignas(4) int32_t index; + alignas(1) char name[CLAP_NAME_SIZE]; + alignas(1) char path[CLAP_MODULE_SIZE]; // Like "/group1/group2/drum-machine/drum-pad-13" + alignas(4) int32_t channel_count; + alignas(4) clap_chmap channel_map; + alignas(4) clap_color_t color; + alignas(4) bool is_return_track; } clap_track_info_t; typedef struct clap_plugin_track_info { @@ -33,6 +35,8 @@ typedef struct clap_host_track_info { bool (*get)(const clap_host_t *host, clap_track_info_t *info); } clap_host_track_info_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/draft/tuning.h b/include/clap/ext/draft/tuning.h @@ -1,6 +1,6 @@ #pragma once -#include "../../clap.h" +#include "../../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_TUNING[] = "clap.tuning.draft/0"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_TUNING[] = "clap.tuning.draft/0"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // This extension provides a dynamic tuning table to the plugin. typedef struct clap_host_tuning { // The plugin can ask the host, the frequency of a given key, @@ -19,6 +21,8 @@ typedef struct clap_host_tuning { double (*get)(const clap_host_t *host, int32_t key, int32_t channel); } clap_host_tuning_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/event-filter.h b/include/clap/ext/event-filter.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_EVENT_FILTER[] = "clap.event-filter"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_EVENT_FILTER[] = "clap.event-filter"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // This extension lets the host know which event types the plugin is interested // in. // The host will cache the set of accepted events before activating the plugin. @@ -26,6 +28,8 @@ typedef struct clap_host_event_filter { void (*changed)(const clap_host_t *host); } clap_host_event_filter_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/fd-support.h b/include/clap/ext/fd-support.h @@ -2,7 +2,7 @@ #include <stddef.h> -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_FD_SUPPORT[] = "clap.fd-support"; @@ -10,6 +10,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_FD_SUPPORT[] = "clap.fd-support"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + #ifdef _WIN32 typedef void *clap_fd; #else @@ -45,6 +47,8 @@ typedef struct clap_host_fd_support { bool (*unregister_fd)(const clap_host_t *host, clap_fd fd); } clap_host_fd_support_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/gui-cocoa.h b/include/clap/ext/gui-cocoa.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_GUI_COCOA[] = "clap.gui-cocoa"; @@ -8,11 +8,15 @@ static CLAP_CONSTEXPR const char CLAP_EXT_GUI_COCOA[] = "clap.gui-cocoa"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_plugin_gui_cocoa { // [main-thread] bool (*attach)(const clap_plugin_t *plugin, void *nsView); } clap_plugin_gui_cocoa_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif diff --git a/include/clap/ext/gui-free-standing.h b/include/clap/ext/gui-free-standing.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_GUI_FREE_STANDING[] = "clap.gui-free-standing"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_GUI_FREE_STANDING[] = "clap.gui-free-s extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_plugin_gui_free_standing { // Opens the plugin window as a free standing window, which means it is not // embedded in the host and managed by the plugin. @@ -15,6 +17,8 @@ typedef struct clap_plugin_gui_free_standing { bool (*open)(const clap_plugin_t * plugin); } clap_plugin_gui_free_standing_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/gui-win32.h b/include/clap/ext/gui-win32.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_GUI_WIN32[] = "clap.gui-win32"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_GUI_WIN32[] = "clap.gui-win32"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // we don't want to include windows.h from this file. typedef void *clap_hwnd; @@ -16,6 +18,8 @@ typedef struct clap_plugin_gui_win32 { bool (*attach)(const clap_plugin_t *plugin, clap_hwnd window); } clap_plugin_gui_win32_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/gui-x11.h b/include/clap/ext/gui-x11.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_GUI_X11[] = "clap.gui-x11"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_GUI_X11[] = "clap.gui-x11"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_plugin_gui_x11 { // Use the protocol XEmbed // https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html @@ -15,6 +17,8 @@ typedef struct clap_plugin_gui_x11 { bool (*attach)(const clap_plugin_t *plugin, const char *display_name, unsigned long window); } clap_plugin_gui_x11_t; +#pragma pack(pop, CLAP_ALIGN) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" /// @page GUI /// @@ -29,6 +29,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_GUI[] = "clap.gui"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_plugin_gui { // Create and allocate all resources necessary for the gui. // After this call, the GUI is ready to be shown but it is not yet visible. @@ -81,6 +83,8 @@ typedef struct clap_host_gui { bool (*resize)(const clap_host_t *host, uint32_t width, uint32_t height); } clap_host_gui_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/latency.h b/include/clap/ext/latency.h @@ -1,7 +1,6 @@ #pragma once -#include "../clap.h" -#include <stdint.h> +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_LATENCY[] = "clap.latency"; @@ -9,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_LATENCY[] = "clap.latency"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // The audio ports scan has to be done while the plugin is deactivated. typedef struct clap_plugin_latency { // Returns the plugin latency. @@ -24,6 +25,8 @@ typedef struct clap_host_latency { void (*changed)(const clap_host_t *host); } clap_host_latency_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif diff --git a/include/clap/ext/log.h b/include/clap/ext/log.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_LOG[] = "clap.log"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_LOG[] = "clap.log"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + enum { CLAP_LOG_DEBUG = 0, CLAP_LOG_INFO = 1, @@ -28,6 +30,8 @@ typedef struct clap_host_log { void (*log)(const clap_host_t *host, clap_log_severity severity, const char *msg); } clap_host_log_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/note-name.h b/include/clap/ext/note-name.h @@ -1,20 +1,22 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" #include "../string-sizes.h" #ifdef __cplusplus extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + static CLAP_CONSTEXPR const char CLAP_EXT_NOTE_NAME[] = "clap.note-name"; typedef struct clap_note_name { - char name[CLAP_NAME_SIZE]; - int32_t port; - int32_t key; - int32_t channel; // -1 for every channels + alignas(1) char name[CLAP_NAME_SIZE]; + alignas(4) int32_t port; + alignas(4) int32_t key; + alignas(4) int32_t channel; // -1 for every channels } clap_note_name_t; typedef struct clap_plugin_note_name { @@ -33,6 +35,8 @@ typedef struct clap_host_note_name { void (*changed)(const clap_host_t *host); } clap_host_note_name_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/note-ports.h b/include/clap/ext/note-ports.h @@ -1,7 +1,6 @@ #pragma once -#include "../clap.h" -#include "../chmap.h" +#include "../plugin.h" #include "../string-sizes.h" /// @page Note Ports @@ -18,9 +17,11 @@ static CLAP_CONSTEXPR const char CLAP_EXT_NOTE_PORTS[] = "clap.note-ports"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_note_port_info { - clap_id id; // stable identifier - char name[CLAP_NAME_SIZE]; // displayable name, i18n? + alignas(4) clap_id id; // stable identifier + alignas(1) char name[CLAP_NAME_SIZE]; // displayable name, i18n? } clap_note_port_info_t; // The audio ports scan has to be done while the plugin is deactivated. @@ -54,6 +55,8 @@ typedef struct clap_host_note_ports { void (*rescan)(const clap_host_t *host, uint32_t flags); } clap_host_note_ports_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" #include "../string-sizes.h" /// @page Parameters @@ -80,6 +80,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_PARAMS[] = "clap.params"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + enum { // Is this param stepped? (integer values only) // if so the double value is converted to integer using a cast (equivalent to trunc). @@ -125,9 +127,9 @@ typedef uint32_t clap_param_info_flags; /* This describes a parameter */ typedef struct clap_param_info { // stable parameter identifier, it must never change. - clap_id id; + alignas(4) clap_id id; - clap_param_info_flags flags; + alignas(4) clap_param_info_flags flags; // This value is optional and set by the plugin. // Its purpose is to provide a fast access to the plugin parameter: @@ -142,14 +144,14 @@ typedef struct clap_param_info { // destroyed. void *cookie; - 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. + alignas(1) char name[CLAP_NAME_SIZE]; // the display name + alignas(1) 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. - double min_value; // minimum plain value - double max_value; // maximum plain value - double default_value; // default plain value + alignas(8) double min_value; // minimum plain value + alignas(8) double max_value; // maximum plain value + alignas(8) double default_value; // default plain value } clap_param_info_t; typedef struct clap_plugin_params { @@ -159,7 +161,9 @@ typedef struct clap_plugin_params { // Copies the parameter's info to param_info and returns true on success. // [main-thread] - bool (*get_info)(const clap_plugin_t *plugin, int32_t param_index, clap_param_info_t *param_info); + bool (*get_info)(const clap_plugin_t *plugin, + int32_t param_index, + clap_param_info_t *param_info); // Gets the parameter plain value. // [main-thread] @@ -175,9 +179,9 @@ typedef struct clap_plugin_params { // 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_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(). @@ -185,7 +189,7 @@ typedef struct clap_plugin_params { // // [active && !processing : audio-thread] // [!active : main-thread] - void (*flush)(const clap_plugin_t * plugin, + void (*flush)(const clap_plugin_t *plugin, const clap_event_list_t *input_parameter_changes, const clap_event_list_t *output_parameter_changes); } clap_plugin_params_t; @@ -263,6 +267,8 @@ typedef struct clap_host_params { void (*request_flush)(const clap_host_t *host); } clap_host_params_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/render.h b/include/clap/ext/render.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_RENDER[] = "clap.render"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_RENDER[] = "clap.render"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + enum { // Default setting, used to play "realtime" CLAP_RENDER_REALTIME = 0, @@ -27,6 +29,8 @@ typedef struct clap_plugin_render { void (*set)(const clap_plugin_t *plugin, clap_plugin_render_mode mode); } clap_plugin_render_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/state.h b/include/clap/ext/state.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" #include "../stream.h" static CLAP_CONSTEXPR const char CLAP_EXT_STATE[] = "clap.state"; @@ -9,6 +9,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_STATE[] = "clap.state"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_plugin_state { // Saves the plugin state into stream. // Returns true if the state was correctly saved. @@ -28,6 +30,8 @@ typedef struct clap_host_state { void (*mark_dirty)(const clap_host_t *host); } clap_host_state_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif diff --git a/include/clap/ext/thread-check.h b/include/clap/ext/thread-check.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_THREAD_CHECK[] = "clap.thread-check"; @@ -8,6 +8,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_THREAD_CHECK[] = "clap.thread-check"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + // This interface is useful to do runtime checks and make // sure that the functions are called on the correct threads. // It is highly recommended to implement this extension @@ -21,6 +23,8 @@ typedef struct clap_host_thread_check { bool (*is_audio_thread)(const clap_host_t *host); } clap_host_thread_check_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/thread-pool.h b/include/clap/ext/thread-pool.h @@ -1,6 +1,6 @@ #pragma once -#include "../clap.h" +#include "../plugin.h" /// @page /// @@ -44,6 +44,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_THREAD_POOL[] = "clap.thread-pool"; extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_plugin_thread_pool { // Called by the thread pool void (*exec)(const clap_plugin_t *plugin, uint32_t task_index); @@ -61,6 +63,8 @@ typedef struct clap_host_thread_pool { bool (*request_exec)(const clap_host_t *host, uint32_t num_tasks); } clap_host_thread_pool_t; +#pragma pack(pop, CLAP_ALIGN) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/ext/timer-support.h b/include/clap/ext/timer-support.h @@ -2,7 +2,7 @@ #include <stddef.h> -#include "../clap.h" +#include "../plugin.h" static CLAP_CONSTEXPR const char CLAP_EXT_TIMER_SUPPORT[] = "clap.timer-support"; @@ -10,6 +10,8 @@ static CLAP_CONSTEXPR const char CLAP_EXT_TIMER_SUPPORT[] = "clap.timer-support" extern "C" { #endif +#pragma pack(push, CLAP_ALIGN) + typedef struct clap_plugin_timer_support { // [main-thread] void (*on_timer)(const clap_plugin_t *plugin, clap_id timer_id); @@ -26,6 +28,8 @@ typedef struct clap_host_timer_support { bool (*unregister_timer)(const clap_host_t *host, clap_id timer_id); } clap_host_timer_support_t; +#pragma pack(pop) + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/include/clap/host.h b/include/clap/host.h @@ -7,7 +7,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) typedef struct clap_host { clap_version_t clap_version; // initialized to CLAP_VERSION diff --git a/include/clap/plugin-factory.h b/include/clap/plugin-factory.h @@ -9,7 +9,7 @@ static const CLAP_CONSTEXPR char CLAP_PLUGIN_FACTORY_ID[] = "clap.plugin-factory extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) // Every methods must be thread-safe. // It is very important to be able to scan the plugin as quickly as possible. diff --git a/include/clap/plugin.h b/include/clap/plugin.h @@ -10,7 +10,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) /* bitfield * This gives an hint to the host what the plugin might do. */ diff --git a/include/clap/private/align.h b/include/clap/private/align.h @@ -7,4 +7,6 @@ # define CLAP_PTR_ALIGN 4 #elif UINTPTR_MAX == UINT16_MAX # define CLAP_PTR_ALIGN 2 -#endif -\ No newline at end of file +#endif + +#define CLAP_ALIGN CLAP_PTR_ALIGN +\ No newline at end of file diff --git a/include/clap/process.h b/include/clap/process.h @@ -9,7 +9,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) enum { // Processing failed. The output buffer must be discarded. diff --git a/include/clap/stream.h b/include/clap/stream.h @@ -8,7 +8,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) typedef struct clap_istream { void *ctx; // reserved pointer for the stream diff --git a/include/clap/string-sizes.h b/include/clap/string-sizes.h @@ -7,9 +7,9 @@ extern "C" { #endif enum { - CLAP_NAME_SIZE = 64, - CLAP_MODULE_SIZE = 128, - CLAP_KEYWORDS_SIZE = 128, + CLAP_NAME_SIZE = 256, + CLAP_MODULE_SIZE = 512, + CLAP_KEYWORDS_SIZE = 256, CLAP_PATH_SIZE = 4096, }; diff --git a/include/clap/version.h b/include/clap/version.h @@ -10,7 +10,7 @@ extern "C" { #endif -#pragma pack(push, CLAP_PTR_ALIGN) +#pragma pack(push, CLAP_ALIGN) typedef struct clap_version { // This is the major ABI and API design