diff options
author | Damien Zammit <damien@zamaudio.com> | 2014-04-30 20:00:38 +1000 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2014-04-30 20:00:38 +1000 |
commit | 9ffdcf0d8e8e0630b3cbff5a5dcb963a4600e272 (patch) | |
tree | 9365c4c5adaccc3096b38e4ecb340b34761eddea | |
parent | 338a5bbe8846ce0ca49cbad6d6a573188d0397c9 (diff) | |
parent | 3228ba3bff2ac4cd930ffc185a7373db4dc30f89 (diff) |
Merge pull request #13 from falkTX/master
Update DPF stuff; build dssi, lv2 and vst
24 files changed, 440 insertions, 375 deletions
diff --git a/libs/distrho/extra/d_leakdetector.hpp b/libs/distrho/extra/d_leakdetector.hpp index 7d27555..ca5a1b7 100644 --- a/libs/distrho/extra/d_leakdetector.hpp +++ b/libs/distrho/extra/d_leakdetector.hpp @@ -46,9 +46,9 @@ \endcode */ #define DISTRHO_LEAK_DETECTOR(ClassName) \ - friend class ::LeakedObjectDetector<ClassName>; \ + friend class ::DistrhoLeakedObjectDetector<ClassName>; \ static const char* getLeakedObjectClassName() noexcept { return #ClassName; } \ - ::LeakedObjectDetector<ClassName> DISTRHO_JOIN_MACRO(leakDetector, __LINE__); + ::DistrhoLeakedObjectDetector<ClassName> DISTRHO_JOIN_MACRO(leakDetector, __LINE__); #define DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \ DISTRHO_DECLARE_NON_COPY_CLASS(ClassName) \ @@ -67,14 +67,14 @@ class declaration. */ template <class OwnerClass> -class LeakedObjectDetector +class DistrhoLeakedObjectDetector { public: //============================================================================== - LeakedObjectDetector() noexcept { ++(getCounter().numObjects); } - LeakedObjectDetector(const LeakedObjectDetector&) noexcept { ++(getCounter().numObjects); } + DistrhoLeakedObjectDetector() noexcept { ++(getCounter().numObjects); } + DistrhoLeakedObjectDetector(const DistrhoLeakedObjectDetector&) noexcept { ++(getCounter().numObjects); } - ~LeakedObjectDetector() noexcept + ~DistrhoLeakedObjectDetector() noexcept { if (--(getCounter().numObjects) < 0) { diff --git a/libs/distrho/extra/d_mutex.hpp b/libs/distrho/extra/d_mutex.hpp deleted file mode 100644 index 34d06c4..0000000 --- a/libs/distrho/extra/d_mutex.hpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com> - * - * Permission to use, copy, modify, and/or distribute this software for any purpose with - * or without fee is hereby granted, provided that the above copyright notice and this - * permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef DISTRHO_MUTEX_HPP_INCLUDED -#define DISTRHO_MUTEX_HPP_INCLUDED - -#include "../DistrhoUtils.hpp" - -#include <pthread.h> - -// ----------------------------------------------------------------------- -// d_mutex class - -class d_mutex -{ -public: - /* - * Constructor. - */ - d_mutex() noexcept - { - pthread_mutex_init(&fMutex, nullptr); - } - - /* - * Destructor. - */ - ~d_mutex() noexcept - { - pthread_mutex_destroy(&fMutex); - } - - /* - * Lock the mutex. - */ - void lock() const noexcept - { - pthread_mutex_lock(&fMutex); - } - - /* - * Try to lock the mutex. - * Returns true if successful. - */ - bool tryLock() const noexcept - { - return (pthread_mutex_trylock(&fMutex) == 0); - } - - /* - * Unlock the mutex, optionally resetting the tryLock check. - */ - void unlock() const noexcept - { - pthread_mutex_unlock(&fMutex); - } - -private: - mutable pthread_mutex_t fMutex; - - DISTRHO_PREVENT_HEAP_ALLOCATION - DISTRHO_DECLARE_NON_COPY_CLASS(d_mutex) -}; - -// ----------------------------------------------------------------------- -// d_rmutex class - -class d_rmutex -{ -public: - /* - * Constructor. - */ - d_rmutex() noexcept - { -#ifdef DISTRHO_OS_WIN - InitializeCriticalSection(&fSection); -#else - pthread_mutexattr_t atts; - pthread_mutexattr_init(&atts); - pthread_mutexattr_settype(&atts, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&fMutex, &atts); - pthread_mutexattr_destroy(&atts); -#endif - } - - /* - * Destructor. - */ - ~d_rmutex() noexcept - { -#ifdef DISTRHO_OS_WIN - DeleteCriticalSection(&fSection); -#else - pthread_mutex_destroy(&fMutex); -#endif - } - - /* - * Lock the mutex. - */ - void lock() const noexcept - { -#ifdef DISTRHO_OS_WIN - EnterCriticalSection(&fSection); -#else - pthread_mutex_lock(&fMutex); -#endif - } - - /* - * Try to lock the mutex. - * Returns true if successful. - */ - bool tryLock() const noexcept - { -#ifdef DISTRHO_OS_WIN - return (TryEnterCriticalSection(&fSection) != FALSE); -#else - return (pthread_mutex_trylock(&fMutex) == 0); -#endif - } - - /* - * Unlock the mutex. - */ - void unlock() const noexcept - { -#ifdef DISTRHO_OS_WIN - LeaveCriticalSection(&fSection); -#else - pthread_mutex_unlock(&fMutex); -#endif - } - -private: -#ifdef DISTRHO_OS_WIN - mutable CRITICAL_SECTION fSection; -#else - mutable pthread_mutex_t fMutex; -#endif - - DISTRHO_PREVENT_HEAP_ALLOCATION - DISTRHO_DECLARE_NON_COPY_CLASS(d_rmutex) -}; - -// ----------------------------------------------------------------------- -// Helper class to lock&unlock a mutex during a function scope. - -template <class Mutex> -class d_scopeLocker -{ -public: - d_scopeLocker(const Mutex& mutex) noexcept - : fMutex(mutex) - { - fMutex.lock(); - } - - ~d_scopeLocker() noexcept - { - fMutex.unlock(); - } - -private: - const Mutex& fMutex; - - DISTRHO_PREVENT_HEAP_ALLOCATION - DISTRHO_DECLARE_NON_COPY_CLASS(d_scopeLocker) -}; - -// ----------------------------------------------------------------------- -// Helper class to unlock&lock a mutex during a function scope. - -template <class Mutex> -class d_scopeUnlocker -{ -public: - d_scopeUnlocker(const Mutex& mutex) noexcept - : fMutex(mutex) - { - fMutex.unlock(); - } - - ~d_scopeUnlocker() noexcept - { - fMutex.lock(); - } - -private: - const Mutex& fMutex; - - DISTRHO_PREVENT_HEAP_ALLOCATION - DISTRHO_DECLARE_NON_COPY_CLASS(d_scopeUnlocker) -}; - -// ----------------------------------------------------------------------- -// Define types - -typedef d_scopeLocker<d_mutex> d_mutexLocker; -typedef d_scopeLocker<d_rmutex> d_rmutexLocker; - -typedef d_scopeUnlocker<d_mutex> d_mutexUnlocker; -typedef d_scopeUnlocker<d_rmutex> d_rmutexUnlocker; - -// ----------------------------------------------------------------------- - -#endif // DISTRHO_MUTEX_HPP_INCLUDED diff --git a/libs/distrho/src/DistrhoPluginLV2export.cpp b/libs/distrho/src/DistrhoPluginLV2export.cpp index a920f40..780c615 100644 --- a/libs/distrho/src/DistrhoPluginLV2export.cpp +++ b/libs/distrho/src/DistrhoPluginLV2export.cpp @@ -98,20 +98,23 @@ void lv2_generate_ttl(const char* const basename) # else manifestString += " ui:binary <" + pluginLabel + "." DISTRHO_DLL_EXTENSION "> ;\n"; #endif -# if DISTRHO_PLUGIN_WANT_PROGRAMS manifestString += " lv2:extensionData ui:idleInterface ,\n"; +# if DISTRHO_PLUGIN_WANT_PROGRAMS + manifestString += " ui:showInterface ,\n"; manifestString += " <" LV2_PROGRAMS__Interface "> ;\n"; # else - manifestString += " lv2:extensionData ui:idleInterface ;\n"; + manifestString += " ui:showInterface ;\n"; # endif manifestString += " lv2:optionalFeature ui:noUserResize ,\n"; + manifestString += " ui:resize ,\n"; manifestString += " ui:touch ;\n"; - manifestString += " lv2:requiredFeature ui:resize ,\n"; # if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS - manifestString += " <" LV2_DATA_ACCESS_URI "> ,\n"; + manifestString += " lv2:requiredFeature <" LV2_DATA_ACCESS_URI "> ,\n"; manifestString += " <" LV2_INSTANCE_ACCESS_URI "> ,\n"; -# endif manifestString += " <" LV2_OPTIONS__options "> ,\n"; +# else + manifestString += " lv2:requiredFeature <" LV2_OPTIONS__options "> ,\n"; +# endif manifestString += " <" LV2_URID__map "> .\n"; #endif diff --git a/libs/distrho/src/DistrhoPluginVST.cpp b/libs/distrho/src/DistrhoPluginVST.cpp index 2920736..5eb1954 100644 --- a/libs/distrho/src/DistrhoPluginVST.cpp +++ b/libs/distrho/src/DistrhoPluginVST.cpp @@ -974,7 +974,8 @@ const AEffect* VSTPluginMain(audioMasterCallback audioMaster) effect->magic = kEffectMagic; effect->uniqueID = plugin->getUniqueId(); #ifdef VESTIGE_HEADER - *(int32_t*)&effect->unknown1 = plugin->getVersion(); + int32_t* const version = (int32_t*)&effect->unknown1; + *version = plugin->getVersion(); #else effect->version = plugin->getVersion(); #endif diff --git a/libs/distrho/src/DistrhoUIDSSI.cpp b/libs/distrho/src/DistrhoUIDSSI.cpp index 12c48d2..fe1fb09 100644 --- a/libs/distrho/src/DistrhoUIDSSI.cpp +++ b/libs/distrho/src/DistrhoUIDSSI.cpp @@ -248,6 +248,11 @@ int osc_debug_handler(const char* path, const char*, lo_arg**, int, lo_message, { d_debug("osc_debug_handler(\"%s\")", path); return 0; + +#ifndef DEBUG + // unused + (void)path; +#endif } void osc_error_handler(int num, const char* msg, const char* path) diff --git a/libs/distrho/src/DistrhoUIInternal.hpp b/libs/distrho/src/DistrhoUIInternal.hpp index 2672a85..e398624 100644 --- a/libs/distrho/src/DistrhoUIInternal.hpp +++ b/libs/distrho/src/DistrhoUIInternal.hpp @@ -233,6 +233,11 @@ public: return ! glApp.isQuiting(); } + bool isVisible() const noexcept + { + return glWindow.isVisible(); + } + void quit() { glWindow.close(); @@ -254,9 +259,11 @@ public: glWindow.setTransientWinId(winId); } - void setVisible(const bool yesNo) + bool setVisible(const bool yesNo) { glWindow.setVisible(yesNo); + + return ! glApp.isQuiting(); } private: diff --git a/libs/distrho/src/DistrhoUILV2.cpp b/libs/distrho/src/DistrhoUILV2.cpp index ad7271f..1e8aa36 100644 --- a/libs/distrho/src/DistrhoUILV2.cpp +++ b/libs/distrho/src/DistrhoUILV2.cpp @@ -34,7 +34,9 @@ START_NAMESPACE_DISTRHO class UiLv2 { public: - UiLv2(const intptr_t winId, const LV2_URID_Map* const uridMap, const LV2UI_Resize* const uiResz, const LV2UI_Touch* uiTouch, const LV2UI_Controller controller, const LV2UI_Write_Function writeFunc, void* const dspPtr) + UiLv2(const intptr_t winId, + const LV2_Options_Option* options, const LV2_URID_Map* const uridMap, const LV2UI_Resize* const uiResz, const LV2UI_Touch* uiTouch, + const LV2UI_Controller controller, const LV2UI_Write_Function writeFunc, void* const dspPtr) : fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback, dspPtr), fUridMap(uridMap), fUiResize(uiResz), @@ -42,14 +44,38 @@ public: fController(controller), fWriteFunction(writeFunc), fEventTransferURID(uridMap->map(uridMap->handle, LV2_ATOM__eventTransfer)), - fKeyValueURID(uridMap->map(uridMap->handle, "urn:distrho:keyValueState")) + fKeyValueURID(uridMap->map(uridMap->handle, "urn:distrho:keyValueState")), + fWinIdWasNull(winId == 0) { - fUiResize->ui_resize(fUiResize->handle, fUI.getWidth(), fUI.getHeight()); + if (winId == 0) + fUI.setTitle(fUI.getName()); + else if (fUiResize != nullptr) + fUiResize->ui_resize(fUiResize->handle, fUI.getWidth(), fUI.getHeight()); #if DISTRHO_PLUGIN_WANT_STATE // tell the DSP we're ready to receive msgs setState("__dpf_ui_data__", ""); #endif + + if (winId != 0) + return; + + const LV2_URID uridFrontendWinId(uridMap->map(uridMap->handle, "http://kxstudio.sf.net/ns/carla/frontendWinId")); + + for (int i=0; options[i].key != 0; ++i) + { + if (options[i].key == uridFrontendWinId) + { + if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Long)) + { + if (const int64_t frontendWinId = *(const int64_t*)options[i].value) + fUI.setTransientWinId(static_cast<intptr_t>(frontendWinId)); + } + else + d_stderr("Host provides frontendWinId but has wrong value type"); + break; + } + } } // ------------------------------------------------------------------- @@ -72,6 +98,9 @@ public: else if (format == fEventTransferURID) { const LV2_Atom* const atom((const LV2_Atom*)buffer); + + // TODO - check atom type + const char* const stateKey((const char*)LV2_ATOM_BODY_CONST(atom)); const char* const stateValue(stateKey+std::strlen(stateKey)+1); @@ -85,8 +114,20 @@ public: int lv2ui_idle() { - fUI.idle(); - return 0; + if (fWinIdWasNull) + return (fUI.idle() && fUI.isVisible()) ? 0 : 1; + + return fUI.idle() ? 0 : 1; + } + + int lv2ui_show() + { + return fUI.setVisible(true) ? 0 : 1; + } + + int lv2ui_hide() + { + return fUI.setVisible(false) ? 0 : 1; } // ------------------------------------------------------------------- @@ -155,7 +196,9 @@ protected: void uiResize(const uint width, const uint height) { fUI.setSize(width, height); - fUiResize->ui_resize(fUiResize->handle, width, height); + + if (fUiResize != nullptr && ! fWinIdWasNull) + fUiResize->ui_resize(fUiResize->handle, width, height); } private: @@ -174,6 +217,9 @@ private: const LV2_URID fEventTransferURID; const LV2_URID fKeyValueURID; + // using ui:showInterface if true + bool fWinIdWasNull; + // ------------------------------------------------------------------- // Callbacks @@ -263,16 +309,9 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char* uri, return nullptr; } - if (uiResize == nullptr) - { - d_stderr("UI Resize feature missing, cannot continue!"); - return nullptr; - } - if (parentId == nullptr) { - d_stderr("Parent Window Id missing, cannot continue!"); - return nullptr; + d_stdout("Parent Window Id missing, host should be using ui:showInterface..."); } #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS @@ -295,11 +334,13 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char* uri, *widget = parentId; - const intptr_t winId(*((intptr_t*)&parentId)); + const intptr_t winId((intptr_t)parentId); + + const LV2_URID uridSampleRate(uridMap->map(uridMap->handle, LV2_CORE__sampleRate)); for (int i=0; options[i].key != 0; ++i) { - if (options[i].key == uridMap->map(uridMap->handle, LV2_CORE__sampleRate)) + if (options[i].key == uridSampleRate) { if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Double)) d_lastUiSampleRate = *(const double*)options[i].value; @@ -313,7 +354,7 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char* uri, if (d_lastUiSampleRate == 0.0) d_lastUiSampleRate = 44100.0; - return new UiLv2(winId, uridMap, uiResize, uiTouch, controller, writeFunction, instance); + return new UiLv2(winId, options, uridMap, uiResize, uiTouch, controller, writeFunction, instance); } #define uiPtr ((UiLv2*)ui) @@ -335,6 +376,16 @@ static int lv2ui_idle(LV2UI_Handle ui) return uiPtr->lv2ui_idle(); } +static int lv2ui_show(LV2UI_Handle ui) +{ + return uiPtr->lv2ui_show(); +} + +static int lv2ui_hide(LV2UI_Handle ui) +{ + return uiPtr->lv2ui_hide(); +} + #if DISTRHO_PLUGIN_WANT_PROGRAMS static void lv2ui_select_program(LV2UI_Handle ui, uint32_t bank, uint32_t program) { @@ -347,9 +398,12 @@ static void lv2ui_select_program(LV2UI_Handle ui, uint32_t bank, uint32_t progra static const void* lv2ui_extension_data(const char* uri) { static const LV2UI_Idle_Interface uiIdle = { lv2ui_idle }; + static const LV2UI_Show_Interface uiShow = { lv2ui_show, lv2ui_hide }; if (std::strcmp(uri, LV2_UI__idleInterface) == 0) return &uiIdle; + if (std::strcmp(uri, LV2_UI__showInterface) == 0) + return &uiShow; #if DISTRHO_PLUGIN_WANT_PROGRAMS static const LV2_Programs_UI_Interface uiPrograms = { lv2ui_select_program }; diff --git a/libs/distrho/src/lv2/atom-forge.h b/libs/distrho/src/lv2/atom-forge.h index c727121..d803d23 100644 --- a/libs/distrho/src/lv2/atom-forge.h +++ b/libs/distrho/src/lv2/atom-forge.h @@ -1,5 +1,5 @@ /* - Copyright 2008-2012 David Robillard <http://drobilla.net> + Copyright 2008-2013 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -48,6 +48,12 @@ #include "atom-util.h" #include "urid.h" +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +# define LV2_ATOM_FORGE_DEPRECATED __attribute__((__deprecated__)) +#else +# define LV2_ATOM_FORGE_DEPRECATED +#endif + #ifdef __cplusplus extern "C" { #else @@ -89,7 +95,7 @@ typedef struct { LV2_Atom_Forge_Frame* stack; - LV2_URID Blank; + LV2_URID Blank LV2_ATOM_FORGE_DEPRECATED; LV2_URID Bool; LV2_URID Chunk; LV2_URID Double; @@ -97,9 +103,10 @@ typedef struct { LV2_URID Int; LV2_URID Long; LV2_URID Literal; + LV2_URID Object; LV2_URID Path; LV2_URID Property; - LV2_URID Resource; + LV2_URID Resource LV2_ATOM_FORGE_DEPRECATED; LV2_URID Sequence; LV2_URID String; LV2_URID Tuple; @@ -120,6 +127,13 @@ lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size); static inline void lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map) { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif lv2_atom_forge_set_buffer(forge, NULL, 0); forge->Blank = map->map(map->handle, LV2_ATOM__Blank); forge->Bool = map->map(map->handle, LV2_ATOM__Bool); @@ -129,6 +143,7 @@ lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map) forge->Int = map->map(map->handle, LV2_ATOM__Int); forge->Long = map->map(map->handle, LV2_ATOM__Long); forge->Literal = map->map(map->handle, LV2_ATOM__Literal); + forge->Object = map->map(map->handle, LV2_ATOM__Object); forge->Path = map->map(map->handle, LV2_ATOM__Path); forge->Property = map->map(map->handle, LV2_ATOM__Property); forge->Resource = map->map(map->handle, LV2_ATOM__Resource); @@ -138,6 +153,11 @@ lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map) forge->URI = map->map(map->handle, LV2_ATOM__URI); forge->URID = map->map(map->handle, LV2_ATOM__URID); forge->Vector = map->map(map->handle, LV2_ATOM__Vector); +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +#endif } static inline LV2_Atom* @@ -184,8 +204,51 @@ lv2_atom_forge_pop(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame) static inline bool lv2_atom_forge_top_is(LV2_Atom_Forge* forge, uint32_t type) { - return forge->stack && - lv2_atom_forge_deref(forge, forge->stack->ref)->type == type; + return forge->stack && forge->stack->ref && + (lv2_atom_forge_deref(forge, forge->stack->ref)->type == type); +} + +/** Return true iff @p type is an atom:Object. */ +static inline bool +lv2_atom_forge_is_object_type(const LV2_Atom_Forge* forge, uint32_t type) +{ +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + return (type == forge->Object || + type == forge->Blank || + type == forge->Resource); +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +#endif +} + +/** Return true iff @p type is an atom:Object with a blank ID. */ +static inline bool +lv2_atom_forge_is_blank(const LV2_Atom_Forge* forge, + uint32_t type, + const LV2_Atom_Object_Body* body) +{ +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + return (type == forge->Blank || + (type == forge->Object && body->id == 0)); +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +#endif } /** @@ -199,7 +262,7 @@ static inline void lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size) { forge->buf = buf; - forge->size = size; + forge->size = (uint32_t)size; forge->offset = 0; forge->deref = NULL; forge->sink = NULL; @@ -253,7 +316,7 @@ lv2_atom_forge_raw(LV2_Atom_Forge* forge, const void* data, uint32_t size) if (forge->sink) { out = forge->sink(forge->handle, data, size); } else { - out = (LV2_Atom_Forge_Ref)forge->buf + forge->offset; + out = (LV2_Atom_Forge_Ref)forge->buf + (LV2_Atom_Forge_Ref)forge->offset; uint8_t* mem = forge->buf + forge->offset; if (forge->offset + size > forge->size) { return 0; @@ -321,7 +384,8 @@ lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a) if (lv2_atom_forge_top_is(forge, forge->Vector)) { return lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size); } else { - return lv2_atom_forge_write(forge, a, sizeof(LV2_Atom) + a->size); + return lv2_atom_forge_write( + forge, a, (uint32_t)sizeof(LV2_Atom) + a->size); } } @@ -503,7 +567,7 @@ lv2_atom_forge_tuple(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame) } /** - Write the header of an atom:Resource. + Write the header of an atom:Object. The passed frame will be initialised to represent this object. To complete the object, write a sequence of properties, then pop the frame with @@ -514,12 +578,12 @@ lv2_atom_forge_tuple(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame) LV2_URID eg_Cat = map("http://example.org/Cat"); LV2_URID eg_name = map("http://example.org/name"); - // Write object header + // Start object with type eg_Cat and blank ID LV2_Atom_Forge_Frame frame; - lv2_atom_forge_resource(forge, &frame, 1, eg_Cat); + lv2_atom_forge_object(forge, &frame, 0, eg_Cat); - // Write property: eg:name = "Hobbes" - lv2_atom_forge_property_head(forge, eg_name, 0); + // Append property eg:name = "Hobbes" + lv2_atom_forge_key(forge, eg_name); lv2_atom_forge_string(forge, "Hobbes", strlen("Hobbes")); // Finish object @@ -527,39 +591,103 @@ lv2_atom_forge_tuple(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame) @endcode */ static inline LV2_Atom_Forge_Ref +lv2_atom_forge_object(LV2_Atom_Forge* forge, + LV2_Atom_Forge_Frame* frame, + LV2_URID id, + LV2_URID otype) +{ + const LV2_Atom_Object a = { + { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Object }, + { id, otype } + }; + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); +} + +/** + The same as lv2_atom_forge_object(), but for object:Resource. + + This function is deprecated and should not be used in new code. + Use lv2_atom_forge_object() directly instead. +*/ +LV2_ATOM_FORGE_DEPRECATED +static inline LV2_Atom_Forge_Ref lv2_atom_forge_resource(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame, LV2_URID id, LV2_URID otype) { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif const LV2_Atom_Object a = { - { sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Resource }, + { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Resource }, { id, otype } }; - LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a)); - return lv2_atom_forge_push(forge, frame, out); + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +#endif } /** - The same as lv2_atom_forge_resource(), but for object:Blank. + The same as lv2_atom_forge_object(), but for object:Blank. + + This function is deprecated and should not be used in new code. + Use lv2_atom_forge_object() directly instead. */ +LV2_ATOM_FORGE_DEPRECATED static inline LV2_Atom_Forge_Ref lv2_atom_forge_blank(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame, uint32_t id, LV2_URID otype) { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif const LV2_Atom_Object a = { - { sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Blank }, + { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Blank }, { id, otype } }; - LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a)); - return lv2_atom_forge_push(forge, frame, out); + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +#endif +} + +/** + Write a property key in an Object, to be followed by the value. + + See lv2_atom_forge_object() documentation for an example. +*/ +static inline LV2_Atom_Forge_Ref +lv2_atom_forge_key(LV2_Atom_Forge* forge, + LV2_URID key) +{ + const LV2_Atom_Property_Body a = { key, 0, { 0, 0 } }; + return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t)); } /** - Write the header for a property body (likely in an Object). - See lv2_atom_forge_resource() documentation for an example. + Write the header for a property body in an object, with context. + + If you do not need the context, which is almost certainly the case, + use the simpler lv2_atom_forge_key() instead. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_property_head(LV2_Atom_Forge* forge, @@ -567,7 +695,7 @@ lv2_atom_forge_property_head(LV2_Atom_Forge* forge, LV2_URID context) { const LV2_Atom_Property_Body a = { key, context, { 0, 0 } }; - return lv2_atom_forge_write(forge, &a, 2 * sizeof(uint32_t)); + return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t)); } /** @@ -579,11 +707,11 @@ lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge, uint32_t unit) { const LV2_Atom_Sequence a = { - { sizeof(LV2_Atom_Sequence) - sizeof(LV2_Atom), forge->Sequence }, + { (uint32_t)sizeof(LV2_Atom_Sequence_Body), forge->Sequence }, { unit, 0 } }; - LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a)); - return lv2_atom_forge_push(forge, frame, out); + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); } /** diff --git a/libs/distrho/src/lv2/atom-helpers.h b/libs/distrho/src/lv2/atom-helpers.h index 69bc496..97cef2c 100644 --- a/libs/distrho/src/lv2/atom-helpers.h +++ b/libs/distrho/src/lv2/atom-helpers.h @@ -1,7 +1,7 @@ // lv2_atom_helpers.h // /**************************************************************************** - Copyright (C) 2005-2012, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2005-2013, rncbc aka Rui Nuno Capela. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -40,7 +40,7 @@ #include <stdlib.h> #include <assert.h> -#include "atom.h" +#include "atom-util.h" #ifdef __cplusplus extern "C" { @@ -59,28 +59,18 @@ struct _LV2_Atom_Buffer } LV2_Atom_Buffer; -// Pad a size to 64 bits (for LV2 atom:Sequence event sizes). -// -static inline -uint32_t lv2_atom_buffer_pad_size ( uint32_t size ) -{ - return (size + 7) & (~7); -} - - // Clear and initialize an existing LV2 atom:Sequenece buffer. // static inline void lv2_atom_buffer_reset ( LV2_Atom_Buffer *buf, bool input ) { - if (input) + if (input) { buf->atoms.atom.size = sizeof(LV2_Atom_Sequence_Body); - else + buf->atoms.atom.type = buf->sequence_type; + } else { buf->atoms.atom.size = buf->capacity; - - buf->atoms.atom.type = buf->sequence_type; - buf->atoms.body.unit = 0; - buf->atoms.body.pad = 0; + buf->atoms.atom.type = buf->chunk_type; + } } @@ -88,12 +78,13 @@ void lv2_atom_buffer_reset ( LV2_Atom_Buffer *buf, bool input ) // static inline LV2_Atom_Buffer *lv2_atom_buffer_new ( - uint32_t capacity, uint32_t sequence_type, bool input ) + uint32_t capacity, uint32_t chunk_type, uint32_t sequence_type, bool input ) { LV2_Atom_Buffer *buf = (LV2_Atom_Buffer *) malloc(sizeof(LV2_Atom_Buffer) + sizeof(LV2_Atom_Sequence) + capacity); buf->capacity = capacity; + buf->chunk_type = chunk_type; buf->sequence_type = sequence_type; lv2_atom_buffer_reset(buf, input); @@ -116,7 +107,10 @@ void lv2_atom_buffer_free ( LV2_Atom_Buffer *buf ) static inline uint32_t lv2_atom_buffer_get_size ( LV2_Atom_Buffer *buf ) { - return buf->atoms.atom.size - sizeof(LV2_Atom_Sequence_Body); + if (buf->atoms.atom.type == buf->sequence_type) + return buf->atoms.atom.size - uint32_t(sizeof(LV2_Atom_Sequence_Body)); + else + return 0; } @@ -160,7 +154,7 @@ bool lv2_atom_buffer_end ( LV2_Atom_Buffer_Iterator *iter, LV2_Atom_Buffer *buf ) { iter->buf = buf; - iter->offset = lv2_atom_buffer_pad_size(lv2_atom_buffer_get_size(buf)); + iter->offset = lv2_atom_pad_size(lv2_atom_buffer_get_size(buf)); return (iter->offset < buf->capacity - sizeof(LV2_Atom_Event)); } @@ -187,7 +181,7 @@ bool lv2_atom_buffer_increment ( LV2_Atom_Buffer_Iterator *iter ) LV2_Atom_Sequence *atoms = &buf->atoms; uint32_t size = ((LV2_Atom_Event *) ((char *) LV2_ATOM_CONTENTS(LV2_Atom_Sequence, atoms) + iter->offset))->body.size; - iter->offset += lv2_atom_buffer_pad_size(sizeof(LV2_Atom_Event) + size); + iter->offset += lv2_atom_pad_size(uint32_t(sizeof(LV2_Atom_Event)) + size); return true; } @@ -239,7 +233,7 @@ bool lv2_atom_buffer_write ( memcpy(LV2_ATOM_BODY(&ev->body), data, size); - size = lv2_atom_buffer_pad_size(sizeof(LV2_Atom_Event) + size); + size = lv2_atom_pad_size(uint32_t(sizeof(LV2_Atom_Event)) + size); atoms->atom.size += size; iter->offset += size; diff --git a/libs/distrho/src/lv2/atom-util.h b/libs/distrho/src/lv2/atom-util.h index 417eca9..c47c0f6 100644 --- a/libs/distrho/src/lv2/atom-util.h +++ b/libs/distrho/src/lv2/atom-util.h @@ -1,5 +1,5 @@ /* - Copyright 2008-2012 David Robillard <http://drobilla.net> + Copyright 2008-2013 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -41,14 +41,14 @@ extern "C" { static inline uint32_t lv2_atom_pad_size(uint32_t size) { - return (size + 7) & (~7); + return (size + 7U) & (~7U); } /** Return the total size of @p atom, including the header. */ static inline uint32_t lv2_atom_total_size(const LV2_Atom* atom) { - return sizeof(LV2_Atom) + atom->size; + return (uint32_t)sizeof(LV2_Atom) + atom->size; } /** Return true iff @p atom is null. */ @@ -80,10 +80,10 @@ lv2_atom_sequence_begin(const LV2_Atom_Sequence_Body* body) } /** Get an iterator pointing to the end of a Sequence body. */ -static inline const LV2_Atom_Event* -lv2_atom_sequence_end(const LV2_Atom_Sequence_Body* body, uint32_t size) +static inline LV2_Atom_Event* +lv2_atom_sequence_end(LV2_Atom_Sequence_Body* body, uint32_t size) { - return (const LV2_Atom_Event*)((const uint8_t*)body + lv2_atom_pad_size(size)); + return (LV2_Atom_Event*)((uint8_t*)body + lv2_atom_pad_size(size)); } /** Return true iff @p i has reached the end of @p body. */ @@ -99,7 +99,6 @@ lv2_atom_sequence_is_end(const LV2_Atom_Sequence_Body* body, static inline const LV2_Atom_Event* lv2_atom_sequence_next(const LV2_Atom_Event* i) { - if (!i) return NULL; return (const LV2_Atom_Event*)((const uint8_t*)i + sizeof(LV2_Atom_Event) + lv2_atom_pad_size(i->body.size)); @@ -130,6 +129,52 @@ lv2_atom_sequence_next(const LV2_Atom_Event* i) /** @} + @name Sequence Utilities + @{ +*/ + +/** + Clear all events from @p sequence. + + This simply resets the size field, the other fields are left untouched. +*/ +static inline void +lv2_atom_sequence_clear(LV2_Atom_Sequence* seq) +{ + seq->atom.size = sizeof(LV2_Atom_Sequence_Body); +} + +/** + Append an event at the end of @p sequence. + + @param seq Sequence to append to. + @param capacity Total capacity of the sequence atom + (e.g. as set by the host for sequence output ports). + @param event Event to write. + + @return A pointer to the newly written event in @p seq, + or NULL on failure (insufficient space). +*/ +static inline LV2_Atom_Event* +lv2_atom_sequence_append_event(LV2_Atom_Sequence* seq, + uint32_t capacity, + const LV2_Atom_Event* event) +{ + const uint32_t total_size = (uint32_t)sizeof(*event) + event->body.size; + if (capacity - seq->atom.size < total_size) { + return NULL; + } + + LV2_Atom_Event* e = lv2_atom_sequence_end(&seq->body, seq->atom.size); + memcpy(e, event, total_size); + + seq->atom.size += lv2_atom_pad_size(total_size); + + return e; +} + +/** + @} @name Tuple Iterator @{ */ @@ -143,7 +188,7 @@ lv2_atom_tuple_begin(const LV2_Atom_Tuple* tup) /** Return true iff @p i has reached the end of @p body. */ static inline bool -lv2_atom_tuple_is_end(const void* body, uint32_t size, LV2_Atom* i) +lv2_atom_tuple_is_end(const void* body, uint32_t size, const LV2_Atom* i) { return (const uint8_t*)i >= ((const uint8_t*)body + size); } @@ -169,13 +214,13 @@ lv2_atom_tuple_next(const LV2_Atom* i) @endcode */ #define LV2_ATOM_TUPLE_FOREACH(tuple, iter) \ - for (LV2_Atom* (iter) = lv2_atom_tuple_begin(tuple); \ - !lv2_atom_tuple_is_end(LV2_ATOM_BODY(tuple), (tuple)->size, (iter)); \ + for (const LV2_Atom* (iter) = lv2_atom_tuple_begin(tuple); \ + !lv2_atom_tuple_is_end(LV2_ATOM_BODY_CONST(tuple), (tuple)->size, (iter)); \ (iter) = lv2_atom_tuple_next(iter)) /** Like LV2_ATOM_TUPLE_FOREACH but for a headerless tuple body. */ #define LV2_ATOM_TUPLE_BODY_FOREACH(body, size, iter) \ - for (LV2_Atom* (iter) = (LV2_Atom*)body; \ + for (const LV2_Atom* (iter) = (const LV2_Atom*)body; \ !lv2_atom_tuple_is_end(body, size, (iter)); \ (iter) = lv2_atom_tuple_next(iter)) @@ -208,8 +253,8 @@ lv2_atom_object_next(const LV2_Atom_Property_Body* i) const LV2_Atom* const value = (const LV2_Atom*)( (const uint8_t*)i + 2 * sizeof(uint32_t)); return (const LV2_Atom_Property_Body*)( - (const uint8_t*)i + lv2_atom_pad_size(sizeof(LV2_Atom_Property_Body) - + value->size)); + (const uint8_t*)i + lv2_atom_pad_size( + (uint32_t)sizeof(LV2_Atom_Property_Body) + value->size)); } /** diff --git a/libs/distrho/src/lv2/atom.h b/libs/distrho/src/lv2/atom.h index c6c536f..91c4fa3 100644 --- a/libs/distrho/src/lv2/atom.h +++ b/libs/distrho/src/lv2/atom.h @@ -189,7 +189,7 @@ typedef struct { /** The body of an atom:Object. May be cast to LV2_Atom. */ typedef struct { - uint32_t id; /**< URID (atom:Resource) or blank ID (atom:Blank). */ + uint32_t id; /**< URID, or 0 for blank. */ uint32_t otype; /**< Type URID (same as rdf:type, for fast dispatch). */ /* Contents (a series of property bodies) follow here. */ } LV2_Atom_Object_Body; diff --git a/libs/distrho/src/lv2/event-helpers.h b/libs/distrho/src/lv2/event-helpers.h index f9965f7..5caaab5 100644 --- a/libs/distrho/src/lv2/event-helpers.h +++ b/libs/distrho/src/lv2/event-helpers.h @@ -50,7 +50,7 @@ extern "C" { static inline uint16_t lv2_event_pad_size(uint16_t size) { - return (size + 7) & (~7); + return (uint16_t)(size + 7U) & (uint16_t)(~7U); } @@ -60,7 +60,7 @@ lv2_event_pad_size(uint16_t size) static inline void lv2_event_buffer_reset(LV2_Event_Buffer* buf, uint16_t stamp_type, - uint8_t *data) + uint8_t* data) { buf->data = data; buf->header_size = sizeof(LV2_Event_Buffer); @@ -130,7 +130,8 @@ lv2_event_increment(LV2_Event_Iterator* iter) LV2_Event* const ev = (LV2_Event*)( (uint8_t*)iter->buf->data + iter->offset); - iter->offset += lv2_event_pad_size(sizeof(LV2_Event) + ev->size); + iter->offset += lv2_event_pad_size( + (uint16_t)((uint16_t)sizeof(LV2_Event) + ev->size)); return true; } @@ -190,7 +191,7 @@ lv2_event_write(LV2_Event_Iterator* iter, memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size); ++iter->buf->event_count; - size = lv2_event_pad_size(sizeof(LV2_Event) + size); + size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + size)); iter->buf->size += size; iter->offset += size; @@ -208,11 +209,12 @@ lv2_event_reserve(LV2_Event_Iterator* iter, uint16_t type, uint16_t size) { - if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size) + const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + size); + if (iter->buf->capacity - iter->buf->size < total_size) return NULL; - LV2_Event* const ev = (LV2_Event*)((uint8_t*)iter->buf->data + - iter->offset); + LV2_Event* const ev = (LV2_Event*)( + (uint8_t*)iter->buf->data + iter->offset); ev->frames = frames; ev->subframes = subframes; @@ -220,9 +222,9 @@ lv2_event_reserve(LV2_Event_Iterator* iter, ev->size = size; ++iter->buf->event_count; - size = lv2_event_pad_size(sizeof(LV2_Event) + size); - iter->buf->size += size; - iter->offset += size; + const uint16_t padded_size = lv2_event_pad_size(total_size); + iter->buf->size += padded_size; + iter->offset += padded_size; return (uint8_t*)ev + sizeof(LV2_Event); } @@ -238,19 +240,20 @@ lv2_event_write_event(LV2_Event_Iterator* iter, const LV2_Event* ev, const uint8_t* data) { - if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + ev->size) + const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + ev->size); + if (iter->buf->capacity - iter->buf->size < total_size) return false; LV2_Event* const write_ev = (LV2_Event*)( - (uint8_t*)iter->buf->data + iter->offset); + (uint8_t*)iter->buf->data + iter->offset); *write_ev = *ev; memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size); ++iter->buf->event_count; - const uint16_t size = lv2_event_pad_size(sizeof(LV2_Event) + ev->size); - iter->buf->size += size; - iter->offset += size; + const uint16_t padded_size = lv2_event_pad_size(total_size); + iter->buf->size += padded_size; + iter->offset += padded_size; return true; } diff --git a/libs/distrho/src/lv2/logger.h b/libs/distrho/src/lv2/logger.h index fd41b59..9143544 100644 --- a/libs/distrho/src/lv2/logger.h +++ b/libs/distrho/src/lv2/logger.h @@ -1,5 +1,5 @@ /* - Copyright 2012 David Robillard <http://drobilla.net> + Copyright 2012-2013 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -28,6 +28,7 @@ #define LV2_ATOM_LOGGER_H #include <stdio.h> +#include <string.h> #include "log.h" diff --git a/libs/distrho/src/lv2/lv2-midifunctions.h b/libs/distrho/src/lv2/lv2-midifunctions.h index 2803af9..d068f49 100644 --- a/libs/distrho/src/lv2/lv2-midifunctions.h +++ b/libs/distrho/src/lv2/lv2-midifunctions.h @@ -50,7 +50,7 @@ inline double lv2midi_get_event(LV2_MIDIState* state, } *timestamp = *(double*)(state->midi->data + state->position); - *size = *(size_t*)(state->midi->data + state->position + sizeof(double)); + *size = (uint32_t)*(size_t*)(state->midi->data + state->position + sizeof(double)); *data = state->midi->data + state->position + sizeof(double) + sizeof(size_t); return *timestamp; @@ -64,10 +64,10 @@ inline double lv2midi_step(LV2_MIDIState* state) { return state->frame_count; } - state->position += sizeof(double); + state->position += (uint32_t)sizeof(double); size_t size = *(size_t*)(state->midi->data + state->position); - state->position += sizeof(size_t); - state->position += size; + state->position += (uint32_t)sizeof(size_t); + state->position += (uint32_t)size; return *(double*)(state->midi->data + state->position); } @@ -80,9 +80,9 @@ inline void lv2midi_put_event(LV2_MIDIState* state, if (state->midi->size + sizeof(double) + sizeof(size_t) + size < state->midi->capacity) { *((double*)(state->midi->data + state->midi->size)) = timestamp; - state->midi->size += sizeof(double); + state->midi->size += (uint32_t)sizeof(double); *((size_t*)(state->midi->data + state->midi->size)) = size; - state->midi->size += sizeof(size_t); + state->midi->size += (uint32_t)sizeof(size_t); memcpy(state->midi->data + state->midi->size, data, size); state->midi->size += size; diff --git a/libs/distrho/src/lv2/lv2.h b/libs/distrho/src/lv2/lv2.h index fb4df4d..220fbb0 100644 --- a/libs/distrho/src/lv2/lv2.h +++ b/libs/distrho/src/lv2/lv2.h @@ -21,7 +21,7 @@ /** @file lv2.h API for the LV2 specification <http://lv2plug.in/ns/lv2core>. - Revision: 6.5 + Revision: 12.0 */ #ifndef LV2_H_INCLUDED @@ -109,6 +109,7 @@ #define LV2_CORE__port LV2_CORE_PREFIX "port" #define LV2_CORE__portProperty LV2_CORE_PREFIX "portProperty" #define LV2_CORE__project LV2_CORE_PREFIX "project" +#define LV2_CORE__prototype LV2_CORE_PREFIX "prototype" #define LV2_CORE__reportsLatency LV2_CORE_PREFIX "reportsLatency" #define LV2_CORE__requiredFeature LV2_CORE_PREFIX "requiredFeature" #define LV2_CORE__sampleRate LV2_CORE_PREFIX "sampleRate" diff --git a/libs/distrho/src/lv2/lv2_external_ui.h b/libs/distrho/src/lv2/lv2_external_ui.h index 331c812..789cd3f 100755 --- a/libs/distrho/src/lv2/lv2_external_ui.h +++ b/libs/distrho/src/lv2/lv2_external_ui.h @@ -73,17 +73,19 @@ typedef struct _LV2_External_UI_Widget { */ typedef struct _LV2_External_UI_Host { /** - * Callback that plugin UI will call - * when UI (GUI window) is closed by user. + * Callback that plugin UI will call when UI (GUI window) is closed by user. * This callback will be called during execution of LV2_External_UI_Widget::run() * (i.e. not from background thread). * - * After this callback is called, UI is defunct. Host must call - * LV2UI_Descriptor::cleanup(). If host wants to make the UI visible - * again UI must be reinstantiated. + * After this callback is called, UI is defunct. Host must call LV2UI_Descriptor::cleanup(). + * If host wants to make the UI visible again, the UI must be reinstantiated. + * + * @note When using the depreated URI LV2_EXTERNAL_UI_DEPRECATED_URI, + * some hosts will not call LV2UI_Descriptor::cleanup() as they should, + * and may call show() again without re-initialization. * * @param controller Host context associated with plugin UI, as - * supplied to LV2UI_Descriptor::instantiate() + * supplied to LV2UI_Descriptor::instantiate(). */ void (*ui_closed)(LV2UI_Controller controller); diff --git a/libs/distrho/src/lv2/lv2_rtmempool.h b/libs/distrho/src/lv2/lv2_rtmempool.h index 5a06644..7988886 100644 --- a/libs/distrho/src/lv2/lv2_rtmempool.h +++ b/libs/distrho/src/lv2/lv2_rtmempool.h @@ -27,6 +27,9 @@ /** max size of memory pool name, in chars, including terminating zero char */ #define LV2_RTSAFE_MEMORY_POOL_NAME_MAX 128 +/** This extension used to be defined by a different URI */ +#define LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI "http://home.gna.org/lv2dynparam/rtmempool/v1" + #ifdef __cplusplus extern "C" { #else @@ -98,6 +101,17 @@ typedef struct _LV2_RtMemPool_Pool { } LV2_RtMemPool_Pool; +/** + * Deprecated feature for backwards compatibility. + */ +typedef struct _LV2_RtMemPool_Pool_Deprecated { + unsigned char (*create)(const char*,size_t,size_t,size_t,LV2_RtMemPool_Handle*); + void (*destroy)(LV2_RtMemPool_Handle); + void* (*allocate_atomic)(LV2_RtMemPool_Handle); + void* (*allocate_sleepy)(LV2_RtMemPool_Handle); + void (*deallocate)(LV2_RtMemPool_Handle,void*); +} LV2_RtMemPool_Pool_Deprecated; + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/libs/distrho/src/lv2/morph.h b/libs/distrho/src/lv2/morph.h index 6739d39..df888df 100644 --- a/libs/distrho/src/lv2/morph.h +++ b/libs/distrho/src/lv2/morph.h @@ -19,8 +19,8 @@ #include <stdint.h> -#include "lv2/lv2plug.in/ns/lv2core/lv2.h" -#include "lv2/lv2plug.in/ns/ext/urid/urid.h" +#include "lv2.h" +#include "urid.h" #define LV2_MORPH_URI "http://lv2plug.in/ns/ext/morph" #define LV2_MORPH_PREFIX LV2_MORPH_URI "#" diff --git a/libs/distrho/src/lv2/patch.h b/libs/distrho/src/lv2/patch.h index 1a7a893..3224264 100644 --- a/libs/distrho/src/lv2/patch.h +++ b/libs/distrho/src/lv2/patch.h @@ -28,28 +28,29 @@ #define LV2_PATCH_URI "http://lv2plug.in/ns/ext/patch" #define LV2_PATCH_PREFIX LV2_PATCH_URI "#" -#define LV2_PATCH__Ack LV2_PATCH_PREFIX "Ack" -#define LV2_PATCH__Delete LV2_PATCH_PREFIX "Delete" -#define LV2_PATCH__Error LV2_PATCH_PREFIX "Error" -#define LV2_PATCH__Get LV2_PATCH_PREFIX "Get" -#define LV2_PATCH__Message LV2_PATCH_PREFIX "Message" -#define LV2_PATCH__Move LV2_PATCH_PREFIX "Move" -#define LV2_PATCH__Patch LV2_PATCH_PREFIX "Patch" -#define LV2_PATCH__Post LV2_PATCH_PREFIX "Post" -#define LV2_PATCH__Put LV2_PATCH_PREFIX "Put" -#define LV2_PATCH__Request LV2_PATCH_PREFIX "Request" -#define LV2_PATCH__Response LV2_PATCH_PREFIX "Response" -#define LV2_PATCH__Set LV2_PATCH_PREFIX "Set" -#define LV2_PATCH__add LV2_PATCH_PREFIX "add" -#define LV2_PATCH__body LV2_PATCH_PREFIX "body" -#define LV2_PATCH__destination LV2_PATCH_PREFIX "destination" -#define LV2_PATCH__property LV2_PATCH_PREFIX "property" -#define LV2_PATCH__readable LV2_PATCH_PREFIX "readable" -#define LV2_PATCH__remove LV2_PATCH_PREFIX "remove" -#define LV2_PATCH__request LV2_PATCH_PREFIX "request" -#define LV2_PATCH__subject LV2_PATCH_PREFIX "subject" -#define LV2_PATCH__value LV2_PATCH_PREFIX "value" -#define LV2_PATCH__wildcard LV2_PATCH_PREFIX "wildcard" -#define LV2_PATCH__writable LV2_PATCH_PREFIX "writable" +#define LV2_PATCH__Ack LV2_PATCH_PREFIX "Ack" +#define LV2_PATCH__Delete LV2_PATCH_PREFIX "Delete" +#define LV2_PATCH__Error LV2_PATCH_PREFIX "Error" +#define LV2_PATCH__Get LV2_PATCH_PREFIX "Get" +#define LV2_PATCH__Message LV2_PATCH_PREFIX "Message" +#define LV2_PATCH__Move LV2_PATCH_PREFIX "Move" +#define LV2_PATCH__Patch LV2_PATCH_PREFIX "Patch" +#define LV2_PATCH__Post LV2_PATCH_PREFIX "Post" +#define LV2_PATCH__Put LV2_PATCH_PREFIX "Put" +#define LV2_PATCH__Request LV2_PATCH_PREFIX "Request" +#define LV2_PATCH__Response LV2_PATCH_PREFIX "Response" +#define LV2_PATCH__Set LV2_PATCH_PREFIX "Set" +#define LV2_PATCH__add LV2_PATCH_PREFIX "add" +#define LV2_PATCH__body LV2_PATCH_PREFIX "body" +#define LV2_PATCH__destination LV2_PATCH_PREFIX "destination" +#define LV2_PATCH__property LV2_PATCH_PREFIX "property" +#define LV2_PATCH__readable LV2_PATCH_PREFIX "readable" +#define LV2_PATCH__remove LV2_PATCH_PREFIX "remove" +#define LV2_PATCH__request LV2_PATCH_PREFIX "request" +#define LV2_PATCH__subject LV2_PATCH_PREFIX "subject" +#define LV2_PATCH__sequenceNumber LV2_PATCH_PREFIX "sequenceNumber" +#define LV2_PATCH__value LV2_PATCH_PREFIX "value" +#define LV2_PATCH__wildcard LV2_PATCH_PREFIX "wildcard" +#define LV2_PATCH__writable LV2_PATCH_PREFIX "writable" #endif /* LV2_PATCH_H */ diff --git a/libs/distrho/src/lv2/ui.h b/libs/distrho/src/lv2/ui.h index 28d9194..e2418d3 100644 --- a/libs/distrho/src/lv2/ui.h +++ b/libs/distrho/src/lv2/ui.h @@ -1,6 +1,6 @@ /* LV2 UI Extension - Copyright 2009-2012 David Robillard <d@drobilla.net> + Copyright 2009-2013 David Robillard <d@drobilla.net> Copyright 2006-2011 Lars Luthman <lars.luthman@gmail.com> Permission to use, copy, modify, and/or distribute this software for any @@ -51,8 +51,10 @@ #define LV2_UI__portNotification LV2_UI_PREFIX "portNotification" #define LV2_UI__portSubscribe LV2_UI_PREFIX "portSubscribe" #define LV2_UI__resize LV2_UI_PREFIX "resize" +#define LV2_UI__showInterface LV2_UI_PREFIX "showInterface" #define LV2_UI__touch LV2_UI_PREFIX "touch" #define LV2_UI__ui LV2_UI_PREFIX "ui" +#define LV2_UI__updateRate LV2_UI_PREFIX "updateRate" /** The index returned by LV2_UI_Port_Port::port_index() for unknown ports. @@ -260,7 +262,7 @@ typedef struct _LV2UI_Port_Map { /** Get the index for the port with the given @p symbol. - @return The index of the port, or LV2_UI_INVALID_PORT_INDEX if no such + @return The index of the port, or LV2UI_INVALID_PORT_INDEX if no such port is found. */ uint32_t (*port_index)(LV2UI_Feature_Handle handle, const char* symbol); @@ -339,7 +341,7 @@ typedef struct _LV2UI_Touch { } LV2UI_Touch; /** - UI Idle Feature (LV2_UI__idle) + UI Idle Feature (LV2_UI__idleInterface) This feature is an addition to the UI API that provides a callback for the host to call rapidly, e.g. to drive the idle callback of a toolkit. @@ -357,6 +359,31 @@ typedef struct _LV2UI_Idle_Interface { } LV2UI_Idle_Interface; /** + UI Show Interface (LV2_UI__showInterface) + + UIs can use this interface to provide show/hide methods to pop up a window, + which allows them to function in hosts unable to embed their widget type. + + If used, LV2UI_Idle_Interface should also be used to drive the UI. The UI + should return non-zero from idle() when the window has been closed. +*/ +typedef struct _LV2UI_Show_Interface { + /** + Show a window for this UI. + + @return 0 on success, or anything else to stop being called. + */ + int (*show)(LV2UI_Handle ui); + + /** + Hide the window for this UI. + + @return 0 on success, or anything else to stop being called. + */ + int (*hide)(LV2UI_Handle ui); +} LV2UI_Show_Interface; + +/** Peak data for a slice of time, the update format for ui:peakProtocol. */ typedef struct _LV2UI_Peak_Data { diff --git a/libs/distrho/src/lv2/uri-map.h b/libs/distrho/src/lv2/uri-map.h index 2fedc42..2062af3 100644 --- a/libs/distrho/src/lv2/uri-map.h +++ b/libs/distrho/src/lv2/uri-map.h @@ -92,7 +92,7 @@ typedef struct { } LV2_URI_Map_Feature; #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif #endif /* LV2_URI_MAP_H */ diff --git a/libs/distrho/src/lv2/urid.h b/libs/distrho/src/lv2/urid.h index e3466fb..c317f7f 100644 --- a/libs/distrho/src/lv2/urid.h +++ b/libs/distrho/src/lv2/urid.h @@ -123,7 +123,7 @@ typedef struct _LV2_URID_Unmap { } LV2_URID_Unmap; #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif #endif /* LV2_URID_H */ diff --git a/libs/distrho/src/lv2/worker.h b/libs/distrho/src/lv2/worker.h index b0edbe8..fc09d55 100644 --- a/libs/distrho/src/lv2/worker.h +++ b/libs/distrho/src/lv2/worker.h @@ -152,7 +152,7 @@ typedef struct _LV2_Worker_Schedule { } LV2_Worker_Schedule; #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif #endif /* LV2_WORKER_H */ diff --git a/plugins/Makefile.mk b/plugins/Makefile.mk index 489b58f..a818bff 100644 --- a/plugins/Makefile.mk +++ b/plugins/Makefile.mk @@ -19,8 +19,8 @@ BUILD_CXX_FLAGS += -I. -I../../libs/distrho -I../../libs/dgl # -------------------------------------------------------------- # Enable all plugin types -#all: ladspa lv2 dssi vst -all: lv2 +all: dssi lv2 vst +# all: lv2 # -------------------------------------------------------------- # Set plugin binary file targets |