[libbluray-devel] Changed HDMV suspend/resume: do not always store/restore PSRs

hpi1 git at videolan.org
Tue Apr 26 15:25:57 CEST 2011


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Apr 26 16:20:24 2011 +0300| [9d56655e5a249bbc5c5689cb2de859f9d1309b73] | committer: hpi1

Changed HDMV suspend/resume: do not always store/restore PSRs
- PSRs are stored when calling title or object, or suspending with hdmv_vm_suspend() call
- PSRs are not stored when starting playlist playback
- PSRs are restored only with HDMV RESUME instruction, not with hdmv_vm_resume()
This is still not complete, but a step to right direction ...

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

 src/libbluray/hdmv/hdmv_vm.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/libbluray/hdmv/hdmv_vm.c b/src/libbluray/hdmv/hdmv_vm.c
index f20bef9..4d685f9 100644
--- a/src/libbluray/hdmv/hdmv_vm.c
+++ b/src/libbluray/hdmv/hdmv_vm.c
@@ -278,7 +278,7 @@ void hdmv_vm_free(HDMV_VM **p)
  * suspend/resume ("function call")
  */
 
-static void _suspend_object(HDMV_VM *p)
+static void _suspend_object(HDMV_VM *p, int psr_backup)
 {
     BD_DEBUG(DBG_HDMV, "_suspend_object()\n");
 
@@ -287,7 +287,9 @@ static void _suspend_object(HDMV_VM *p)
         // [execute the call, discard old suspended object (10.2.4.2.2)].
     }
 
-    bd_psr_save_state(p->regs);
+    if (psr_backup) {
+        bd_psr_save_state(p->regs);
+    }
 
     p->suspended_object = p->object;
     p->suspended_pc     = p->pc;
@@ -295,7 +297,7 @@ static void _suspend_object(HDMV_VM *p)
     p->object = NULL;
 }
 
-static int _resume_object(HDMV_VM *p)
+static int _resume_object(HDMV_VM *p, int psr_restore)
 {
     if (!p->suspended_object) {
         BD_DEBUG(DBG_HDMV|DBG_CRIT, "_resume_object: no suspended object!\n");
@@ -305,7 +307,9 @@ static int _resume_object(HDMV_VM *p)
     p->object = p->suspended_object;
     p->pc     = p->suspended_pc + 1;
 
-    bd_psr_restore_state(p->regs);
+    if (psr_restore) {
+        bd_psr_restore_state(p->regs);
+    }
 
     BD_DEBUG(DBG_HDMV, "resuming object %p at %d\n", p->object, p->pc + 1);
 
@@ -333,6 +337,8 @@ static int _jump_object(HDMV_VM *p, int object)
     p->pc     = 0;
     p->object = &p->movie_objects->objects[object];
 
+    /* suspended object is not discarded */
+
     return 0;
 }
 
@@ -358,7 +364,7 @@ static int _call_object(HDMV_VM *p, int object)
 {
     BD_DEBUG(DBG_HDMV, "_call_object(%d)\n", object);
 
-    _suspend_object(p);
+    _suspend_object(p, 1);
 
     return _jump_object(p, object);
 }
@@ -368,7 +374,7 @@ static int _call_title(HDMV_VM *p, int title)
     if (title >= 0 && title <= 0xffff) {
         BD_DEBUG(DBG_HDMV, "_call_title(%d)\n", title);
 
-        _suspend_object(p);
+        _suspend_object(p, 1);
 
         _queue_event(p, HDMV_EVENT_TITLE, title);
         return 0;
@@ -404,7 +410,7 @@ static int _play_at(HDMV_VM *p, int playlist, int playitem, int playmark)
 
     if (playlist >= 0) {
         _queue_event(p, HDMV_EVENT_PLAY_PL, playlist);
-        _suspend_object(p);
+        _suspend_object(p, 0);
     }
 
     if (playitem >= 0) {
@@ -759,7 +765,7 @@ static int _hdmv_step(HDMV_VM *p)
                     switch (insn->branch_opt) {
                         case INSN_JUMP_TITLE:  _jump_title(p, dst); break;
                         case INSN_CALL_TITLE:  _call_title(p, dst); break;
-                        case INSN_RESUME:      _resume_object(p);   break;
+                        case INSN_RESUME:      _resume_object(p, 1);   break;
                         case INSN_JUMP_OBJECT: if (!_jump_object(p, dst)) { inc_pc = 0; } break;
                         case INSN_CALL_OBJECT: if (!_call_object(p, dst)) { inc_pc = 0; } break;
                         default:
@@ -946,7 +952,7 @@ int hdmv_vm_resume(HDMV_VM *p)
     int result;
     bd_mutex_lock(&p->mutex);
 
-    result = _resume_object(p);
+    result = _resume_object(p, 0);
 
     bd_mutex_unlock(&p->mutex);
     return result;
@@ -958,7 +964,7 @@ int hdmv_vm_suspend(HDMV_VM *p)
     bd_mutex_lock(&p->mutex);
 
     if (p->object && !p->ig_object) {
-        _suspend_object(p);
+        _suspend_object(p, 1);
         result = 0;
     }
 



More information about the libbluray-devel mailing list