[libbluray-devel] Cache new PSR values in bd_psr_restore_state() (-> callback functions can' t change restore event values).

hpi1 git at videolan.org
Fri May 6 10:59:07 CEST 2011


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed May  4 14:31:34 2011 +0300| [5d12de25dff26710e74b65d2daecb772445ebc63] | committer: hpi1

Cache new PSR values in bd_psr_restore_state() (-> callback functions can't change restore event values).
Save some stack space (cache only 13 first registers).

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

 src/libbluray/register.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/libbluray/register.c b/src/libbluray/register.c
index bfe4b89..aec8e89 100644
--- a/src/libbluray/register.c
+++ b/src/libbluray/register.c
@@ -268,17 +268,23 @@ void bd_psr_reset_backup_registers(BD_REGISTERS *p)
 
 void bd_psr_restore_state(BD_REGISTERS *p)
 {
-    uint32_t old_psr[BD_PSR_COUNT];
+    uint32_t old_psr[13];
+    uint32_t new_psr[13];
 
     bd_psr_lock(p);
 
-    if (p->num_cb)
-        memcpy(old_psr, p->psr, sizeof(old_psr));
+    if (p->num_cb) {
+        memcpy(old_psr, p->psr, sizeof(old_psr[0]) * 13);
+    }
 
     /* restore backup registers */
     memcpy(p->psr + 4,  p->psr + 36, sizeof(uint32_t) * 5);
     memcpy(p->psr + 10, p->psr + 42, sizeof(uint32_t) * 3);
 
+    if (p->num_cb) {
+        memcpy(new_psr, p->psr, sizeof(new_psr[0]) * 13);
+    }
+
     /* init backup registers to default */
     memcpy(p->psr + 36, bd_psr_init + 36, sizeof(uint32_t) * 5);
     memcpy(p->psr + 42, bd_psr_init + 42, sizeof(uint32_t) * 3);
@@ -291,11 +297,11 @@ void bd_psr_restore_state(BD_REGISTERS *p)
         ev.ev_type = BD_PSR_RESTORE;
 
         for (i = 4; i < 13; i++) {
-            if (i != 9) {
+            if (i != PSR_NAV_TIMER) {
 
                 ev.psr_idx = i;
                 ev.old_val = old_psr[i];
-                ev.new_val = p->psr[i];
+                ev.new_val = new_psr[i];
 
                 for (j = 0; j < p->num_cb; j++) {
                     p->cb[j].cb(p->cb[j].handle, &ev);



More information about the libbluray-devel mailing list