bluez a2dp - destroy thread resources at exit
The dynamically created pthread mutex and condition variables
consume pthread resources. They should be destroyed prior to
freeing the structure containing them.
diff --git a/audio/liba2dp.c b/audio/liba2dp.c
index d7cab1b..5c4ef51 100755
--- a/audio/liba2dp.c
+++ b/audio/liba2dp.c
@@ -934,6 +934,16 @@
return -err;
}
+static void a2dp_free(struct bluetooth_data *data)
+{
+ pthread_cond_destroy(&data->client_wait);
+ pthread_cond_destroy(&data->thread_wait);
+ pthread_cond_destroy(&data->thread_start);
+ pthread_mutex_destroy(&data->mutex);
+ free(data);
+ return;
+}
+
static void* a2dp_thread(void *d)
{
struct bluetooth_data* data = (struct bluetooth_data*)d;
@@ -992,7 +1002,7 @@
case A2DP_CMD_QUIT:
bluetooth_close(data);
sbc_finish(&data->sbc);
- free(data);
+ a2dp_free(data);
goto done;
default:
@@ -1064,7 +1074,7 @@
error:
bluetooth_close(data);
sbc_finish(&data->sbc);
- free(data);
+ a2dp_free(data);
return err;
}