[libbluray-devel] Added mutex to graphics controller.
hpi1
git at videolan.org
Wed Feb 9 17:22:37 CET 2011
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Feb 9 18:17:39 2011 +0200| [14c75a4096e8d0c9c219010dbf0f8b17b4a5b991] | committer: hpi1
Added mutex to graphics controller.
Only single thread at time can enter gc_run() and gc_decode_ts().
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=14c75a4096e8d0c9c219010dbf0f8b17b4a5b991
---
src/libbluray/decoders/graphics_controller.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/libbluray/decoders/graphics_controller.c b/src/libbluray/decoders/graphics_controller.c
index c9fbf80..fd41b61 100644
--- a/src/libbluray/decoders/graphics_controller.c
+++ b/src/libbluray/decoders/graphics_controller.c
@@ -25,6 +25,7 @@
#include "util/macro.h"
#include "util/logging.h"
+#include "util/mutex.h"
#include "../register.h"
#include "../keys.h"
@@ -42,6 +43,8 @@ struct graphics_controller_s {
BD_REGISTERS *regs;
+ BD_MUTEX mutex;
+
/* overlay output */
void *overlay_proc_handle;
void (*overlay_proc)(void *, const struct bd_overlay_s * const);
@@ -240,6 +243,8 @@ GRAPHICS_CONTROLLER *gc_init(BD_REGISTERS *regs, void *handle, gc_overlay_proc_f
p->overlay_proc_handle = handle;
p->overlay_proc = func;
+ bd_mutex_init(&p->mutex);
+
return p;
}
@@ -253,6 +258,8 @@ void gc_free(GRAPHICS_CONTROLLER **p)
(*p)->overlay_proc((*p)->overlay_proc_handle, NULL);
}
+ bd_mutex_destroy(&(*p)->mutex);
+
X_FREE(*p);
}
}
@@ -269,10 +276,14 @@ void gc_decode_ts(GRAPHICS_CONTROLLER *gc, uint16_t pid, uint8_t *block, unsigne
if (!gc->igp) {
gc->igp = graphics_processor_init();
}
+
+ bd_mutex_lock(&gc->mutex);
+
graphics_processor_decode_ts(gc->igp, &gc->igs,
pid, block, num_blocks,
stc);
if (!gc->igs || !gc->igs->complete) {
+ bd_mutex_unlock(&gc->mutex);
return;
}
@@ -283,6 +294,8 @@ void gc_decode_ts(GRAPHICS_CONTROLLER *gc, uint16_t pid, uint8_t *block, unsigne
_gc_clear_osd(gc, 1);
_reset_enabled_button(gc);
+
+ bd_mutex_unlock(&gc->mutex);
}
else if (pid >= 0x1200 && pid < 0x1300) {
@@ -761,10 +774,14 @@ int gc_run(GRAPHICS_CONTROLLER *gc, gc_ctrl_e ctrl, uint32_t param, GC_NAV_CMDS
cmds->sound_id_ref = -1;
}
+ bd_mutex_lock(&gc->mutex);
+
/* always accept reset */
switch (ctrl) {
case GC_CTRL_RESET:
_gc_reset(gc);
+
+ bd_mutex_unlock(&gc->mutex);
return 0;
default:;
}
@@ -772,6 +789,7 @@ int gc_run(GRAPHICS_CONTROLLER *gc, gc_ctrl_e ctrl, uint32_t param, GC_NAV_CMDS
/* other operations require complete display set */
if (!gc || !gc->igs || !gc->igs->ics || !gc->igs->complete) {
TRACE("gc_run(): no interactive composition\n");
+ bd_mutex_unlock(&gc->mutex);
return result;
}
@@ -830,5 +848,7 @@ int gc_run(GRAPHICS_CONTROLLER *gc, gc_ctrl_e ctrl, uint32_t param, GC_NAV_CMDS
break;
}
+ bd_mutex_unlock(&gc->mutex);
+
return result;
}
More information about the libbluray-devel
mailing list