[libbluray-devel] Added missing locking to PG decoder enable/disable

hpi1 git at videolan.org
Wed Jun 19 15:21:16 CEST 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Jun 19 15:05:23 2013 +0300| [4236b5a689430d9489dbb980e1bd110146a2d162] | committer: hpi1

Added missing locking to PG decoder enable/disable

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

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

diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index e13c491..bca1e48 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -2506,16 +2506,23 @@ int bd_set_player_setting(BLURAY *bd, uint32_t idx, uint32_t value)
     };
 
     unsigned i;
+    int result;
 
     if (idx == BLURAY_PLAYER_SETTING_DECODE_PG) {
+        bd_mutex_lock(&bd->mutex);
         bd->decode_pg = !!value;
-        value = (bd_psr_read(bd->regs, PSR_PG_STREAM) & (0x7fffffff)) | (value<<31);
-        return !bd_psr_setting_write(bd->regs, PSR_PG_STREAM, value);
+
+        bd_psr_lock(bd->regs);
+        value = (bd_psr_read(bd->regs, PSR_PG_STREAM) & (0x7fffffff)) | ((!!value)<<31);
+        result = !bd_psr_setting_write(bd->regs, PSR_PG_STREAM, value);
+        bd_psr_unlock(bd->regs);
+
+        bd_mutex_unlock(&bd->mutex);
+        return result;
     }
 
     for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
         if (idx == map[i].idx) {
-            int result;
             bd_mutex_lock(&bd->mutex);
             result = !bd_psr_setting_write(bd->regs, idx, value);
             bd_mutex_unlock(&bd->mutex);



More information about the libbluray-devel mailing list