| @@ -116,28 +116,29 @@ const uint32_t kFeatureIdLogs = 7; | |||||
| const uint32_t kFeatureIdOptions = 8; | const uint32_t kFeatureIdOptions = 8; | ||||
| const uint32_t kFeatureIdPrograms = 9; | const uint32_t kFeatureIdPrograms = 9; | ||||
| const uint32_t kFeatureIdRtMemPool = 10; | const uint32_t kFeatureIdRtMemPool = 10; | ||||
| const uint32_t kFeatureIdStateMakePath = 11; | |||||
| const uint32_t kFeatureIdStateMapPath = 12; | |||||
| const uint32_t kFeatureIdStrictBounds = 13; | |||||
| const uint32_t kFeatureIdUriMap = 14; | |||||
| const uint32_t kFeatureIdUridMap = 15; | |||||
| const uint32_t kFeatureIdUridUnmap = 16; | |||||
| const uint32_t kFeatureIdWorker = 17; | |||||
| const uint32_t kFeatureCountPlugin = 18; | |||||
| const uint32_t kFeatureIdUiDataAccess = 18; | |||||
| const uint32_t kFeatureIdUiInstanceAccess = 19; | |||||
| const uint32_t kFeatureIdUiIdle = 20; | |||||
| const uint32_t kFeatureIdUiFixedSize = 21; | |||||
| const uint32_t kFeatureIdUiMakeResident = 22; | |||||
| const uint32_t kFeatureIdUiNoUserResize = 23; | |||||
| const uint32_t kFeatureIdUiParent = 24; | |||||
| const uint32_t kFeatureIdUiPortMap = 25; | |||||
| const uint32_t kFeatureIdUiPortSubscribe = 26; | |||||
| const uint32_t kFeatureIdUiResize = 27; | |||||
| const uint32_t kFeatureIdUiTouch = 28; | |||||
| const uint32_t kFeatureIdExternalUi = 29; | |||||
| const uint32_t kFeatureIdExternalUiOld = 30; | |||||
| const uint32_t kFeatureCountAll = 31; | |||||
| const uint32_t kFeatureIdRtMemPoolOld = 11; | |||||
| const uint32_t kFeatureIdStateMakePath = 12; | |||||
| const uint32_t kFeatureIdStateMapPath = 13; | |||||
| const uint32_t kFeatureIdStrictBounds = 14; | |||||
| const uint32_t kFeatureIdUriMap = 15; | |||||
| const uint32_t kFeatureIdUridMap = 16; | |||||
| const uint32_t kFeatureIdUridUnmap = 17; | |||||
| const uint32_t kFeatureIdWorker = 18; | |||||
| const uint32_t kFeatureCountPlugin = 19; | |||||
| const uint32_t kFeatureIdUiDataAccess = 19; | |||||
| const uint32_t kFeatureIdUiInstanceAccess = 20; | |||||
| const uint32_t kFeatureIdUiIdle = 21; | |||||
| const uint32_t kFeatureIdUiFixedSize = 22; | |||||
| const uint32_t kFeatureIdUiMakeResident = 23; | |||||
| const uint32_t kFeatureIdUiNoUserResize = 24; | |||||
| const uint32_t kFeatureIdUiParent = 25; | |||||
| const uint32_t kFeatureIdUiPortMap = 26; | |||||
| const uint32_t kFeatureIdUiPortSubscribe = 27; | |||||
| const uint32_t kFeatureIdUiResize = 28; | |||||
| const uint32_t kFeatureIdUiTouch = 29; | |||||
| const uint32_t kFeatureIdExternalUi = 30; | |||||
| const uint32_t kFeatureIdExternalUiOld = 31; | |||||
| const uint32_t kFeatureCountAll = 32; | |||||
| // ----------------------------------------------------- | // ----------------------------------------------------- | ||||
| @@ -461,6 +462,9 @@ public: | |||||
| if (fFeatures[kFeatureIdRtMemPool] != nullptr && fFeatures[kFeatureIdRtMemPool]->data != nullptr) | if (fFeatures[kFeatureIdRtMemPool] != nullptr && fFeatures[kFeatureIdRtMemPool]->data != nullptr) | ||||
| delete (LV2_RtMemPool_Pool*)fFeatures[kFeatureIdRtMemPool]->data; | delete (LV2_RtMemPool_Pool*)fFeatures[kFeatureIdRtMemPool]->data; | ||||
| if (fFeatures[kFeatureIdRtMemPoolOld] != nullptr && fFeatures[kFeatureIdRtMemPoolOld]->data != nullptr) | |||||
| delete (LV2_RtMemPool_Pool_Deprecated*)fFeatures[kFeatureIdRtMemPoolOld]->data; | |||||
| if (fFeatures[kFeatureIdUriMap] != nullptr && fFeatures[kFeatureIdUriMap]->data != nullptr) | if (fFeatures[kFeatureIdUriMap] != nullptr && fFeatures[kFeatureIdUriMap]->data != nullptr) | ||||
| delete (LV2_URI_Map_Feature*)fFeatures[kFeatureIdUriMap]->data; | delete (LV2_URI_Map_Feature*)fFeatures[kFeatureIdUriMap]->data; | ||||
| @@ -4161,6 +4165,9 @@ public: | |||||
| LV2_RtMemPool_Pool* const rtMemPoolFt = new LV2_RtMemPool_Pool; | LV2_RtMemPool_Pool* const rtMemPoolFt = new LV2_RtMemPool_Pool; | ||||
| lv2_rtmempool_init(rtMemPoolFt); | lv2_rtmempool_init(rtMemPoolFt); | ||||
| LV2_RtMemPool_Pool_Deprecated* const rtMemPoolOldFt = new LV2_RtMemPool_Pool_Deprecated; | |||||
| lv2_rtmempool_init_deprecated(rtMemPoolOldFt); | |||||
| LV2_URI_Map_Feature* const uriMapFt = new LV2_URI_Map_Feature; | LV2_URI_Map_Feature* const uriMapFt = new LV2_URI_Map_Feature; | ||||
| uriMapFt->callback_data = this; | uriMapFt->callback_data = this; | ||||
| uriMapFt->uri_to_id = carla_lv2_uri_to_id; | uriMapFt->uri_to_id = carla_lv2_uri_to_id; | ||||
| @@ -4216,6 +4223,9 @@ public: | |||||
| fFeatures[kFeatureIdRtMemPool]->URI = LV2_RTSAFE_MEMORY_POOL__Pool; | fFeatures[kFeatureIdRtMemPool]->URI = LV2_RTSAFE_MEMORY_POOL__Pool; | ||||
| fFeatures[kFeatureIdRtMemPool]->data = rtMemPoolFt; | fFeatures[kFeatureIdRtMemPool]->data = rtMemPoolFt; | ||||
| fFeatures[kFeatureIdRtMemPoolOld]->URI = LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI; | |||||
| fFeatures[kFeatureIdRtMemPoolOld]->data = rtMemPoolOldFt; | |||||
| fFeatures[kFeatureIdStateMakePath]->URI = LV2_STATE__makePath; | fFeatures[kFeatureIdStateMakePath]->URI = LV2_STATE__makePath; | ||||
| fFeatures[kFeatureIdStateMakePath]->data = stateMakePathFt; | fFeatures[kFeatureIdStateMakePath]->data = stateMakePathFt; | ||||
| @@ -27,6 +27,9 @@ | |||||
| /** max size of memory pool name, in chars, including terminating zero char */ | /** max size of memory pool name, in chars, including terminating zero char */ | ||||
| #define LV2_RTSAFE_MEMORY_POOL_NAME_MAX 128 | #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 | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| #else | #else | ||||
| @@ -98,6 +101,17 @@ typedef struct _LV2_RtMemPool_Pool { | |||||
| } 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 | #ifdef __cplusplus | ||||
| } /* extern "C" */ | } /* extern "C" */ | ||||
| #endif | #endif | ||||
| @@ -28,4 +28,6 @@ | |||||
| */ | */ | ||||
| void lv2_rtmempool_init(LV2_RtMemPool_Pool* poolPtr); | void lv2_rtmempool_init(LV2_RtMemPool_Pool* poolPtr); | ||||
| void lv2_rtmempool_init_deprecated(LV2_RtMemPool_Pool_Deprecated* poolPtr); | |||||
| #endif // __RTMEMPOOL_LV2_H__ | #endif // __RTMEMPOOL_LV2_H__ | ||||
| @@ -55,19 +55,10 @@ typedef struct _RtMemPool | |||||
| } RtMemPool; | } RtMemPool; | ||||
| // ------------------------------------------------------------------------------------------------ | |||||
| // additional function prototypes | |||||
| void rtsafe_memory_pool_sleepy(RtMemPool* poolPtr); | |||||
| bool rtsafe_memory_pool_create2(RtMemPool_Handle* handlePtr, const char* poolName, | |||||
| size_t dataSize, size_t minPreallocated, size_t maxPreallocated, | |||||
| int enforceThreadSafety); | |||||
| // ------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------ | ||||
| // adjust unused list size | // adjust unused list size | ||||
| void rtsafe_memory_pool_sleepy(RtMemPool* poolPtr) | |||||
| static void rtsafe_memory_pool_sleepy(RtMemPool* poolPtr) | |||||
| { | { | ||||
| k_list_head* nodePtr; | k_list_head* nodePtr; | ||||
| unsigned int count; | unsigned int count; | ||||
| @@ -144,12 +135,12 @@ void rtsafe_memory_pool_sleepy(RtMemPool* poolPtr) | |||||
| // ------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------ | ||||
| bool rtsafe_memory_pool_create2(RtMemPool_Handle* handlePtr, | |||||
| const char* poolName, | |||||
| size_t dataSize, | |||||
| size_t minPreallocated, | |||||
| size_t maxPreallocated, | |||||
| int enforceThreadSafety) | |||||
| static bool rtsafe_memory_pool_create2(RtMemPool_Handle* handlePtr, | |||||
| const char* poolName, | |||||
| size_t dataSize, | |||||
| size_t minPreallocated, | |||||
| size_t maxPreallocated, | |||||
| int enforceThreadSafety) | |||||
| { | { | ||||
| assert(minPreallocated <= maxPreallocated); | assert(minPreallocated <= maxPreallocated); | ||||
| assert(poolName == NULL || strlen(poolName) < RTSAFE_MEMORY_POOL_NAME_MAX); | assert(poolName == NULL || strlen(poolName) < RTSAFE_MEMORY_POOL_NAME_MAX); | ||||
| @@ -206,6 +197,13 @@ bool rtsafe_memory_pool_create2(RtMemPool_Handle* handlePtr, | |||||
| // ------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------ | ||||
| static unsigned char rtsafe_memory_pool_create_old(const char* poolName, size_t dataSize, size_t minPreallocated, size_t maxPreallocated, RtMemPool_Handle* handlePtr) | |||||
| { | |||||
| return rtsafe_memory_pool_create2(handlePtr, poolName, dataSize, minPreallocated, maxPreallocated, 0); | |||||
| } | |||||
| // ------------------------------------------------------------------------------------------------ | |||||
| bool rtsafe_memory_pool_create(RtMemPool_Handle* handlePtr, | bool rtsafe_memory_pool_create(RtMemPool_Handle* handlePtr, | ||||
| const char* poolName, | const char* poolName, | ||||
| size_t dataSize, | size_t dataSize, | ||||
| @@ -385,4 +383,13 @@ void lv2_rtmempool_init(LV2_RtMemPool_Pool* poolPtr) | |||||
| poolPtr->allocate_sleepy = rtsafe_memory_pool_allocate_sleepy; | poolPtr->allocate_sleepy = rtsafe_memory_pool_allocate_sleepy; | ||||
| poolPtr->deallocate = rtsafe_memory_pool_deallocate; | poolPtr->deallocate = rtsafe_memory_pool_deallocate; | ||||
| } | } | ||||
| void lv2_rtmempool_init_deprecated(LV2_RtMemPool_Pool_Deprecated* poolPtr) | |||||
| { | |||||
| poolPtr->create = rtsafe_memory_pool_create_old; | |||||
| poolPtr->destroy = rtsafe_memory_pool_destroy; | |||||
| poolPtr->allocate_atomic = rtsafe_memory_pool_allocate_atomic; | |||||
| poolPtr->allocate_sleepy = rtsafe_memory_pool_allocate_sleepy; | |||||
| poolPtr->deallocate = rtsafe_memory_pool_deallocate; | |||||
| } | |||||
| #endif | #endif | ||||
| @@ -1291,6 +1291,8 @@ bool is_lv2_feature_supported(const LV2_URI uri) | |||||
| return true; | return true; | ||||
| if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL__Pool) == 0) | if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL__Pool) == 0) | ||||
| return true; | return true; | ||||
| if (std::strcmp(uri, LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI) == 0) | |||||
| return true; | |||||
| if (std::strcmp(uri, LV2_STATE__makePath) == 0) | if (std::strcmp(uri, LV2_STATE__makePath) == 0) | ||||
| return true; | return true; | ||||
| if (std::strcmp(uri, LV2_STATE__mapPath) == 0) | if (std::strcmp(uri, LV2_STATE__mapPath) == 0) | ||||