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:
parent
f3dc5227e9
commit
21fd6cd2f5
18
libobs/obs.c
18
libobs/obs.c
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user