From 0eec70a1ca0342093aa1a5a4b27a51633a8681f7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 28 Oct 2014 01:18:44 +0000 Subject: [PATCH] Export Engine/Plugin C++ API; Make carla_get_engine() non-const --- source/backend/CarlaEngine.hpp | 24 +++++++++++------------ source/backend/CarlaHost.h | 2 +- source/backend/CarlaPlugin.hpp | 2 +- source/backend/CarlaStandalone.cpp | 2 +- source/tests/ansi-pedantic-test.c | 31 ++++++++++++++++++++++++++++-- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 18720fd76..f657dcf1a 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -167,7 +167,7 @@ enum EngineControlEventType { /*! * Engine control event. */ -struct EngineControlEvent { +struct CARLA_API EngineControlEvent { EngineControlEventType type; //!< Control-Event type. uint16_t param; //!< Parameter Id, midi bank or midi program. float value; //!< Parameter value, normalized to 0.0f<->1.0f. @@ -181,7 +181,7 @@ struct EngineControlEvent { /*! * Engine MIDI event. */ -struct EngineMidiEvent { +struct CARLA_API EngineMidiEvent { static const uint8_t kDataSize = 4; //!< Size of internal data uint8_t port; //!< Port offset (usually 0) @@ -198,7 +198,7 @@ struct EngineMidiEvent { /*! * Engine event. */ -struct EngineEvent { +struct CARLA_API EngineEvent { EngineEventType type; //!< Event Type; either Control or MIDI uint32_t time; //!< Time offset in frames uint8_t channel; //!< Channel, used for MIDI-related events @@ -222,7 +222,7 @@ struct EngineEvent { /*! * Engine options. */ -struct EngineOptions { +struct CARLA_API EngineOptions { EngineProcessMode processMode; EngineTransportMode transportMode; @@ -264,7 +264,7 @@ struct EngineOptions { /*! * Engine BBT Time information. */ -struct EngineTimeInfoBBT { +struct CARLA_API EngineTimeInfoBBT { int32_t bar; //!< current bar int32_t beat; //!< current beat-within-bar int32_t tick; //!< current tick-within-beat @@ -284,7 +284,7 @@ struct EngineTimeInfoBBT { /*! * Engine Time information. */ -struct EngineTimeInfo { +struct CARLA_API EngineTimeInfo { static const uint kValidBBT = 0x1; bool playing; @@ -313,7 +313,7 @@ struct EngineTimeInfo { * Carla Engine port (Abstract). * This is the base class for all Carla Engine ports. */ -class CarlaEnginePort +class CARLA_API CarlaEnginePort { protected: /*! @@ -366,7 +366,7 @@ protected: /*! * Carla Engine Audio port. */ -class CarlaEngineAudioPort : public CarlaEnginePort +class CARLA_API CarlaEngineAudioPort : public CarlaEnginePort { public: /*! @@ -413,7 +413,7 @@ protected: /*! * Carla Engine CV port. */ -class CarlaEngineCVPort : public CarlaEnginePort +class CARLA_API CarlaEngineCVPort : public CarlaEnginePort { public: /*! @@ -460,7 +460,7 @@ protected: /*! * Carla Engine Event port. */ -class CarlaEngineEventPort : public CarlaEnginePort +class CARLA_API CarlaEngineEventPort : public CarlaEnginePort { public: /*! @@ -553,7 +553,7 @@ protected: * Each plugin requires one client from the engine (created via CarlaEngine::addClient()). * @note This is a virtual class, some engine types provide custom funtionality. */ -class CarlaEngineClient +class CARLA_API CarlaEngineClient { public: /*! @@ -648,7 +648,7 @@ protected: * Carla Engine. * @note This is a virtual class for all available engine types available in Carla. */ -class CarlaEngine +class CARLA_API CarlaEngine { protected: /*! diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index f4b4e1d07..93679e221 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -408,7 +408,7 @@ CARLA_EXPORT const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginTyp * Get the currently used engine, maybe be NULL. * @note C++ only */ -CARLA_EXPORT const CarlaEngine* carla_get_engine(); +CARLA_EXPORT CarlaEngine* carla_get_engine(); #endif /*! diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index ff8ff3e60..4dbf770c6 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -64,7 +64,7 @@ struct StateSave; * * @see PluginType */ -class CarlaPlugin +class CARLA_API CarlaPlugin { protected: /*! diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 00d686dd5..b0aac1d64 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -404,7 +404,7 @@ const EngineDriverDeviceInfo* carla_get_engine_driver_device_info(uint index, co // ------------------------------------------------------------------------------------------------------------------- -const CarlaEngine* carla_get_engine() +CarlaEngine* carla_get_engine() { carla_debug("carla_get_engine()"); diff --git a/source/tests/ansi-pedantic-test.c b/source/tests/ansi-pedantic-test.c index 8ff621d5d..d44b031f9 100644 --- a/source/tests/ansi-pedantic-test.c +++ b/source/tests/ansi-pedantic-test.c @@ -23,12 +23,14 @@ #ifdef __cplusplus # include "CarlaEngine.hpp" # include "CarlaPlugin.hpp" +# include # include # ifdef CARLA_PROPER_CPP11_SUPPORT # undef NULL # define NULL nullptr # endif #else +# include # include #endif @@ -87,8 +89,18 @@ int main(int argc, char* argv[]) if (carla_engine_init("JACK", "ansi-test")) { +#ifdef __cplusplus + CarlaEngine* const engine(carla_get_engine()); + assert(engine != nullptr); + engine->getLastError(); +#endif if (carla_add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", 0, NULL)) { +#ifdef __cplusplus + CarlaPlugin* const plugin(engine->getPlugin(0)); + assert(plugin != nullptr); + plugin->getId(); +#endif carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); carla_transport_play(); } @@ -96,15 +108,30 @@ int main(int argc, char* argv[]) { printf("%s\n", carla_get_last_error()); } - +#ifdef __cplusplus + engine->setAboutToClose(); +#endif carla_engine_close(); } +#ifdef __cplusplus + EngineControlEvent e1; + EngineMidiEvent e2; + EngineEvent e3; + e3.fillFromMidiData(0, nullptr); + EngineOptions e4; + EngineTimeInfoBBT e5; + EngineTimeInfo e6; +#endif + return 0; - /* unused */ + /* unused C */ (void)argc; (void)argv; (void)a; (void)b; (void)c; (void)d; (void)e; (void)f; (void)g; (void)h; (void)i; (void)j; (void)k; +#ifdef __cplusplus + (void)e1; (void)e2; (void)e4; (void)e5; (void)e6; +#endif }