From b9676b45242506e331c4d1f7712cffe485492d8f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 7 Jun 2018 13:07:28 +0100 Subject: [PATCH] Fix a threading deadlock causing a recording playback hang --- player.cc | 1 + threadp.cc | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/player.cc b/player.cc index 491650b..f796190 100644 --- a/player.cc +++ b/player.cc @@ -1182,6 +1182,7 @@ void Player::threadFeedPlay() { // demuxer is full and can't take anymore threadLock(); + if (!threadActive) { threadUnlock(); threadCheckExit(); } threadWaitForSignal(); threadUnlock(); } diff --git a/threadp.cc b/threadp.cc index a40a681..e57cfdd 100644 --- a/threadp.cc +++ b/threadp.cc @@ -45,7 +45,11 @@ int ThreadP::threadStart() void ThreadP::threadStop() { if (threadActive) { // we need this, on some implementations this will fail, if already stopped - threadActive = 0; + + threadLock(); + threadActive = 0; // New locking around this fixes a player lockup but could badly affect other things + threadUnlock(); + // Signal thread here in case it's waiting threadSignal(); pthread_join(pthread, NULL); -- 2.39.2