[libbluray-devel] Added handling of BD_PSR_WRITE events:

hpi1 git at videolan.org
Sat Jul 2 09:51:17 CEST 2011


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sat Jul  2 10:39:33 2011 +0300| [2120407ed20c85bf86703cd339e6cbb7dd1cf123] | committer: hpi1

Added handling of BD_PSR_WRITE events:
angle, title, chapter, playlist and playitem events are generated
every time register is written to.

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

 src/libbluray/bluray.c |   56 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index abfeada..6251c80 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1737,22 +1737,12 @@ static void _process_psr_restore_event(BLURAY *bd, BD_PSR_EVENT *ev)
  * notification events to APP
  */
 
-static void _process_psr_event(void *handle, BD_PSR_EVENT *ev)
+static void _process_psr_write_event(BLURAY *bd, BD_PSR_EVENT *ev)
 {
-    BLURAY *bd = (BLURAY*)handle;
-
-    switch (ev->ev_type) {
-        case BD_PSR_RESTORE:
-            _process_psr_restore_event(bd, ev);
-            return;
-
-        case BD_PSR_SAVE:
-        default:
-            return;
+    if (ev->ev_type == BD_PSR_WRITE) {
+        BD_DEBUG(DBG_BLURAY, "PSR write: psr%u = %u (%p)\n", ev->psr_idx, ev->new_val, bd);
     }
 
-    BD_DEBUG(DBG_BLURAY, "PSR event %d %d (%p)\n", ev->psr_idx, ev->new_val, bd);
-
     switch (ev->psr_idx) {
 
         /* current playback position */
@@ -1763,6 +1753,18 @@ static void _process_psr_event(void *handle, BD_PSR_EVENT *ev)
         case PSR_PLAYITEM:     _queue_event(bd, (BD_EVENT){BD_EVENT_PLAYITEM, ev->new_val}); break;
         case PSR_CHAPTER:      _queue_event(bd, (BD_EVENT){BD_EVENT_CHAPTER,  ev->new_val}); break;
 
+        default:;
+    }
+}
+
+static void _process_psr_change_event(BLURAY *bd, BD_PSR_EVENT *ev)
+{
+    BD_DEBUG(DBG_BLURAY, "PSR change: psr%u = %u (%p)\n", ev->psr_idx, ev->new_val, bd);
+
+    _process_psr_write_event(bd, ev);
+
+    switch (ev->psr_idx) {
+
         /* stream selection */
 
         case PSR_IG_STREAM_ID:
@@ -1798,6 +1800,30 @@ static void _process_psr_event(void *handle, BD_PSR_EVENT *ev)
     }
 }
 
+static void _process_psr_event(void *handle, BD_PSR_EVENT *ev)
+{
+    BLURAY *bd = (BLURAY*)handle;
+
+    switch(ev->ev_type) {
+        case BD_PSR_WRITE:
+            _process_psr_write_event(bd, ev);
+            break;
+        case BD_PSR_CHANGE:
+            _process_psr_change_event(bd, ev);
+            break;
+        case BD_PSR_RESTORE:
+            _process_psr_restore_event(bd, ev);
+            break;
+
+        case BD_PSR_SAVE:
+            BD_DEBUG(DBG_BLURAY, "PSR save event (%p)\n", bd);
+            break;
+        default:
+            BD_DEBUG(DBG_BLURAY, "PSR event %d: psr%u = %u (%p)\n", ev->ev_type, ev->psr_idx, ev->new_val, bd);
+            break;
+    }
+}
+
 static void _queue_initial_psr_events(BLURAY *bd)
 {
     const uint32_t psrs[] = {
@@ -1815,13 +1841,13 @@ static void _queue_initial_psr_events(BLURAY *bd)
 
     for (ii = 0; ii < sizeof(psrs) / sizeof(psrs[0]); ii++) {
         BD_PSR_EVENT ev = {
-            .ev_type = 0,
+            .ev_type = BD_PSR_CHANGE,
             .psr_idx = psrs[ii],
             .old_val = 0,
             .new_val = bd_psr_read(bd->regs, psrs[ii]),
         };
 
-        _process_psr_event(bd, &ev);
+        _process_psr_change_event(bd, &ev);
     }
 }
 



More information about the libbluray-devel mailing list