[libbluray-devel] Added proper locking to bd_user_input() and bd_mouse_select()

hpi1 git at videolan.org
Mon Jan 14 09:08:26 CET 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Jan 14 09:59:39 2013 +0200| [217254bccfb04f421d30b94708f108f5c48e72ad] | committer: hpi1

Added proper locking to bd_user_input() and bd_mouse_select()

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=217254bccfb04f421d30b94708f108f5c48e72ad
---

 src/libbluray/bluray.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 1272689..21fbc45 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -2756,26 +2756,34 @@ int bd_mouse_select(BLURAY *bd, int64_t pts, uint16_t x, uint16_t y)
 {
     int result = -1;
 
+    bd_mutex_lock(&bd->mutex);
+
     bd_set_scr(bd, pts);
 
     if (bd->title_type == title_hdmv) {
         result = _run_gc(bd, GC_CTRL_MOUSE_MOVE, (x << 16) | y);
     }
 
+    bd_mutex_unlock(&bd->mutex);
+
     return result;
 }
 
 int bd_user_input(BLURAY *bd, int64_t pts, uint32_t key)
 {
+    int result = -1;
+
+    bd_mutex_lock(&bd->mutex);
+
     bd_set_scr(bd, pts);
 
     if (bd->title_type == title_hdmv) {
-        return _run_gc(bd, GC_CTRL_VK_KEY, key);
+        result = _run_gc(bd, GC_CTRL_VK_KEY, key);
     } else if (bd->title_type == title_bdj) {
         _bdj_event(bd, BDJ_EVENT_VK_KEY, key);
-        return 0;
+        result = 0;
     }
-    return -1;
+    return result;
 }
 
 void bd_register_overlay_proc(BLURAY *bd, void *handle, bd_overlay_proc_f func)



More information about the libbluray-devel mailing list