From 1dcb38b4f19660d3c94468ad7de422ed2c1f7451 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 13 Sep 2012 10:30:03 +0100 Subject: [PATCH] Carla: Fix rtmempool --- c++/carla-backend/lv2.cpp | 6 +----- c++/carla-backend/rtmempool/rtmempool.c | 25 ++++++++++--------------- c++/carla-backend/rtmempool/rtmempool.h | 4 ---- c++/carla-includes/lv2/lv2_rtmempool.h | 12 ++---------- src/jacksettings.py | 2 +- 5 files changed, 14 insertions(+), 35 deletions(-) diff --git a/c++/carla-backend/lv2.cpp b/c++/carla-backend/lv2.cpp index 4ddcc2e..bd7e970 100644 --- a/c++/carla-backend/lv2.cpp +++ b/c++/carla-backend/lv2.cpp @@ -404,11 +404,7 @@ public: delete (LV2_Programs_Host*)features[lv2_feature_id_programs]->data; if (features[lv2_feature_id_rtmempool] && features[lv2_feature_id_rtmempool]->data) - { - const LV2_RtMemPool_Pool* const rtmempool = (const LV2_RtMemPool_Pool*)features[lv2_feature_id_rtmempool]->data; - rtmempool_allocator_free(rtmempool); - delete rtmempool; - } + delete (LV2_RtMemPool_Pool*)features[lv2_feature_id_rtmempool]->data; if (features[lv2_feature_id_state_make_path] && features[lv2_feature_id_state_make_path]->data) delete (LV2_State_Make_Path*)features[lv2_feature_id_state_make_path]->data; diff --git a/c++/carla-backend/rtmempool/rtmempool.c b/c++/carla-backend/rtmempool/rtmempool.c index ca9fe46..9e9d1eb 100644 --- a/c++/carla-backend/rtmempool/rtmempool.c +++ b/c++/carla-backend/rtmempool/rtmempool.c @@ -59,12 +59,13 @@ struct rtsafe_memory_pool static void -rtsafe_memory_pool_sleepy(); +rtsafe_memory_pool_sleepy( + LV2_RtMemPool_Handle pool_handle); static bool rtsafe_memory_pool_create( - LV2_RtMemPool_Handle pool_handle, + LV2_RtMemPool_Handle * pool_handle_ptr, const char * pool_name, size_t data_size, size_t min_preallocated, @@ -86,7 +87,7 @@ rtsafe_memory_pool_create( (unsigned int)max_preallocated, enforce_thread_safety ? "true" : "false"); - pool_ptr = (struct rtsafe_memory_pool *)pool_handle; + pool_ptr = malloc(sizeof(struct rtsafe_memory_pool)); if (pool_ptr == NULL) { return false; @@ -127,7 +128,8 @@ rtsafe_memory_pool_create( pool_ptr->used_size = 0; - rtsafe_memory_pool_sleepy(); + rtsafe_memory_pool_sleepy((LV2_RtMemPool_Handle)pool_ptr); + *pool_handle_ptr = (LV2_RtMemPool_Handle)pool_ptr; return true; } @@ -186,6 +188,8 @@ rtsafe_memory_pool_destroy( assert(ret == 0); } + free(pool_ptr); + // unused variable (void)ret; } @@ -373,31 +377,22 @@ rtsafe_memory_pool_allocate_sleepy( static bool rtsafe_memory_pool_create2( - LV2_RtMemPool_Handle pool_handle, + LV2_RtMemPool_Handle * pool_handle_ptr, const char * pool_name, size_t data_size, size_t min_preallocated, size_t max_preallocated) { - return rtsafe_memory_pool_create(pool_handle, pool_name, data_size, min_preallocated, max_preallocated, false); + return rtsafe_memory_pool_create(pool_handle_ptr, pool_name, data_size, min_preallocated, max_preallocated, false); } void rtmempool_allocator_init( struct _LV2_RtMemPool_Pool * allocator_ptr) { - allocator_ptr->handle = (LV2_RtMemPool_Handle)malloc(sizeof(struct rtsafe_memory_pool)); allocator_ptr->create = rtsafe_memory_pool_create2; allocator_ptr->destroy = rtsafe_memory_pool_destroy; allocator_ptr->allocate_atomic = rtsafe_memory_pool_allocate_atomic; allocator_ptr->allocate_sleepy = rtsafe_memory_pool_allocate_sleepy; allocator_ptr->deallocate = rtsafe_memory_pool_deallocate; } - -void -rtmempool_allocator_free( - const struct _LV2_RtMemPool_Pool * allocator_ptr) -{ - if (allocator_ptr->handle) - free((struct rtsafe_memory_pool *)allocator_ptr->handle); -} diff --git a/c++/carla-backend/rtmempool/rtmempool.h b/c++/carla-backend/rtmempool/rtmempool.h index addb35a..336d8fb 100644 --- a/c++/carla-backend/rtmempool/rtmempool.h +++ b/c++/carla-backend/rtmempool/rtmempool.h @@ -32,10 +32,6 @@ void rtmempool_allocator_init( struct _LV2_RtMemPool_Pool * allocator_ptr); -void -rtmempool_allocator_free( - const struct _LV2_RtMemPool_Pool * allocator_ptr); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/c++/carla-includes/lv2/lv2_rtmempool.h b/c++/carla-includes/lv2/lv2_rtmempool.h index 21fdade..c4e695d 100644 --- a/c++/carla-includes/lv2/lv2_rtmempool.h +++ b/c++/carla-includes/lv2/lv2_rtmempool.h @@ -43,14 +43,6 @@ typedef void* LV2_RtMemPool_Handle; * LV2_Feature::data must be pointer to LV2_RtMemPool_Pool. */ typedef struct _LV2_RtMemPool_Pool { - /** - * Opaque pointer to host data. - * - * This MUST be passed to methods in this struct whenever they are called. - * Otherwise, it must not be interpreted in any way. - */ - LV2_RtMemPool_Handle handle; - /** * This function is called when plugin wants to create memory pool * @@ -61,9 +53,9 @@ typedef struct _LV2_RtMemPool_Pool { * @param min_preallocated min chunks preallocated * @param max_preallocated max chunks preallocated * - * @return Success status + * @return Success status, true if successful */ - bool (*create)(LV2_RtMemPool_Handle handle, + bool (*create)(LV2_RtMemPool_Handle * handle_ptr, const char * pool_name, size_t data_size, size_t min_preallocated, diff --git a/src/jacksettings.py b/src/jacksettings.py index 86a5079..ec77774 100755 --- a/src/jacksettings.py +++ b/src/jacksettings.py @@ -608,7 +608,7 @@ class JackSettingsW(QDialog, ui_settings_jack.Ui_JackSettingsW): device_index = device_info[0].replace("device ", "") device_name = device_info[1].split(" [")[0] - if (card_name != "Loopback"): + if card_name != "Loopback": full_name = "hw:%s,%s [%s]" % (card_name, device_index, device_name) alsa_dev_list.append(full_name)