From 08e84ece27b4c9f4b00af3d3b5a4cc82f4d54964 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Fri, 1 Feb 2019 21:07:13 +0000 Subject: [PATCH] add a volume control mutex to serialise multiple attempts to change the volume --- rtsp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rtsp.c b/rtsp.c index c60f859e..67e2a88a 100644 --- a/rtsp.c +++ b/rtsp.c @@ -2164,7 +2164,10 @@ void rtsp_conversation_thread_cleanup_function(void *arg) { } // remove flow control and mutexes - int rc = pthread_cond_destroy(&conn->flowcontrol); + int rc = pthread_mutex_destroy(&conn->volume_control_mutex); + if (rc) + debug(1, "Connection %d: error %d destroying volume_control_mutex.", conn->connection_number, rc); + rc = pthread_cond_destroy(&conn->flowcontrol); if (rc) debug(1, "Connection %d: error %d destroying flow control condition variable.", conn->connection_number, rc); @@ -2227,6 +2230,9 @@ static void *rtsp_conversation_thread_func(void *pconn) { if (rc) die("Connection %d: error %d initialising flow control condition variable.", conn->connection_number, rc); + rc = pthread_mutex_init(&conn->volume_control_mutex, NULL); + if (rc) + die("Connection %d: error %d initialising volume_control_mutex.", conn->connection_number, rc); // nothing before this is cancellable pthread_cleanup_push(rtsp_conversation_thread_cleanup_function, (void *)conn);