From 91ebb5c5e0011e0ed90938a73080c30dbbe2b1d8 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 16 Jan 2016 10:53:28 -0800 Subject: [PATCH] libobs: Add comment warning about scene mutex lock ordering A comment that serves as a reminder to anyone who might need to edit the scene code. If the graphics mutex must be locked, it must be locked first before entering the scene mutexes, or outside of the scene mutexes. --- libobs/obs-scene.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index 272d97f13..d2f9c72e9 100644 --- a/libobs/obs-scene.c +++ b/libobs/obs-scene.c @@ -20,6 +20,17 @@ #include "graphics/math-defs.h" #include "obs-scene.h" +/* NOTE: For proper mutex lock order (preventing mutual cross-locks), never + * lock the graphics mutex inside either of the scene mutexes. + * + * Another thing that must be done to prevent that cross-lock (and improve + * performance), is to not create/release/update sources within the scene + * mutexes. + * + * It's okay to lock the graphics mutex before locking either of the scene + * mutexes, but not after. + */ + static const char *obs_scene_signals[] = { "void item_add(ptr scene, ptr item)", "void item_remove(ptr scene, ptr item)",