summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/alsa/alsa-transaction.c')
-rw-r--r--plugins/alsa/alsa-transaction.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/plugins/alsa/alsa-transaction.c b/plugins/alsa/alsa-transaction.c
index dcfd028..a630bdc 100644
--- a/plugins/alsa/alsa-transaction.c
+++ b/plugins/alsa/alsa-transaction.c
@@ -6,16 +6,19 @@
#include "wrap-json.h"
-void AlsaMixerTransactionDelete(AlsaMixerTransaction * transaction) {
+static void AlsaMixerTransactionFree(AlsaMixerTransaction * transaction) {
free((char*)transaction->uid);
free(transaction);
}
AlsaMixerTransaction * AlsaMixerTransactionNew(struct SoftMixerT_ * mixer, const char * uid) {
+
AlsaMixerTransaction * transaction = (AlsaMixerTransaction *) malloc(sizeof(AlsaMixerTransaction));
if (transaction == NULL)
goto fail;
+ AFB_API_INFO(mixer->api, "-------- NEW TRANSACTION %s --------", uid);
+
CDS_INIT_LIST_HEAD(&transaction->item_list);
transaction->uid = strdup(uid);
if (transaction->uid == NULL) {
@@ -33,14 +36,15 @@ fail:
return NULL;
}
-void AlsaMixerTransactionDataListDestroy(AlsaMixerTransaction* list) {
- free(list);
-}
-void AlsaMixerTransactionObjectForget(AlsaMixerTransaction* list, void * object) {
+void AlsaMixerTransactionObjectDelete(AlsaMixerTransaction* transaction, void * object, bool destructor) {
AlsaMixerTransactionDataItem *item, *tmp;
- cds_list_for_each_entry_safe(item, tmp, &list->item_list, list_entry)
+ cds_list_for_each_entry_safe(item, tmp, &transaction->item_list, list_entry)
if (item->object == object) {
+
+ if (destructor && item->destructor)
+ item->destructor(transaction->mixer, item->object);
+
cds_list_del(&item->list_entry);
free(item);
}
@@ -88,7 +92,7 @@ fail:
}
-void AlsaMixerTransactionDoCleanup(AlsaMixerTransaction* transaction) {
+static void AlsaMixerTransactionDoCleanup(AlsaMixerTransaction* transaction) {
AlsaMixerTransactionDataItem * item, *sav;
AFB_ApiInfo(transaction->mixer->api, "%s for transaction %s", __func__, transaction->uid);
@@ -127,11 +131,6 @@ void AlsaMixerTransactionVerbCB(AFB_ReqT request) {
}
if (strcmp(action, "remove") == 0) {
- AlsaMixerTransactionDoCleanup(transaction);
-
- // remove this transaction for the list of mixer
- cds_list_del(&transaction->transaction_node);
-
error = afb_api_del_verb(transaction->mixer->api, transaction->uid, (void**)NULL);
if (error) {
AFB_ReqFail(request, "verb deletion" , "verb was not removed");
@@ -154,3 +153,10 @@ fail:
return;
}
+
+void AlsaMixerTransactionDelete(AlsaMixerTransaction * transaction) {
+ AlsaMixerTransactionDoCleanup(transaction);
+ // remove this transaction for the list of mixer
+ cds_list_del(&transaction->transaction_node);
+ AlsaMixerTransactionFree(transaction);
+}