mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
Use recursive mutex for user sources and displays
- Using a recursive mutex fixes issues where objects need to enter the main libobs sources mutex while already within the mutex in the same thread. Otherwise it would keep getting locked on itself on destruction.
This commit is contained in:
+14
-4
@@ -225,15 +225,25 @@ static void obs_free_audio(void)
|
||||
static bool obs_init_data(void)
|
||||
{
|
||||
struct obs_data *data = &obs->data;
|
||||
pthread_mutexattr_t attr;
|
||||
bool success = false;
|
||||
|
||||
pthread_mutex_init_value(&obs->data.displays_mutex);
|
||||
|
||||
if (pthread_mutex_init(&data->sources_mutex, NULL) != 0)
|
||||
return false;
|
||||
if (pthread_mutex_init(&data->displays_mutex, NULL) != 0)
|
||||
if (pthread_mutexattr_init(&attr) != 0)
|
||||
return false;
|
||||
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0)
|
||||
goto fail;
|
||||
if (pthread_mutex_init(&data->sources_mutex, &attr) != 0)
|
||||
goto fail;
|
||||
if (pthread_mutex_init(&data->displays_mutex, &attr) != 0)
|
||||
goto fail;
|
||||
|
||||
return true;
|
||||
success = true;
|
||||
|
||||
fail:
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return success;
|
||||
}
|
||||
|
||||
static void obs_free_data(void)
|
||||
|
||||
Reference in New Issue
Block a user