changeset 191:dbea22936623 src

when a command has been issued to leave a menu, filter all further commands for this menu
author mroi
date Tue, 06 May 2003 14:11:44 +0000
parents c575bd95911d
children a3d7b149cc0f
files dvdnav.c dvdnav_internal.h.in highlight.c
diffstat 3 files changed, 30 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/dvdnav.c	Tue May 06 02:28:28 2003 +0000
+++ b/dvdnav.c	Tue May 06 14:11:44 2003 +0000
@@ -51,6 +51,7 @@
 
   memset(&this->pci,0,sizeof(this->pci));
   memset(&this->dsi,0,sizeof(this->dsi));
+  this->last_cmd_nav_lbn = 0;
 
   /* Set initial values of flags */
   this->position_current.still = 0;
@@ -779,6 +780,10 @@
      */
     dvdnav_pre_cache_blocks(this->cache, this->vobu.vobu_start+1, this->vobu.vobu_length+1);
     
+    /* release NAV menu filter, when we reach the same NAV packet again */
+    if (this->last_cmd_nav_lbn == this->pci.pci_gi.nv_pck_lbn)
+      this->last_cmd_nav_lbn = 0;
+    
     /* Successfully got a NAV packet */
     (*event) = DVDNAV_NAV_PACKET;
 #ifdef LOG_DEBUG
--- a/dvdnav_internal.h.in	Tue May 06 02:28:28 2003 +0000
+++ b/dvdnav_internal.h.in	Tue May 06 14:11:44 2003 +0000
@@ -139,6 +139,7 @@
   /* NAV data */
   pci_t pci;
   dsi_t dsi;
+  uint32_t last_cmd_nav_lbn;      /* detects when a command is issued on an already left NAV */
   
   /* Flags */
   int skip_still;                 /* Set when skipping a still */
--- a/highlight.c	Tue May 06 02:28:28 2003 +0000
+++ b/highlight.c	Tue May 06 14:11:44 2003 +0000
@@ -207,7 +207,7 @@
 
 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int *button) {
   
-  if(!this) {
+  if(!this || !button) {
     printerr("Passed a NULL pointer.");
     return S_ERR;
   }
@@ -221,7 +221,7 @@
 static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) {
   int button = 0;
 
-  if(!this) {
+  if(!this || !pci) {
     printerr("Passed a NULL pointer.");
     return S_ERR;
   }
@@ -229,6 +229,10 @@
     printerr("Not in a menu.");
     return S_ERR;
   }
+  if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
+    printerr("This NAV has already been left.");
+    return S_ERR;
+  }
 
   button = this->vm->state.HL_BTNN_REG >> 10;
 #ifdef BUTTON_TESTING
@@ -246,11 +250,6 @@
 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
-  if(!this) {
-    printerr("Passed a NULL pointer.");
-    return S_ERR;
-  }
-
   if(!(button_ptr = get_current_button(this, pci)))
     return S_ERR;
 
@@ -263,11 +262,6 @@
 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
-  if(!this) {
-    printerr("Passed a NULL pointer.");
-    return S_ERR;
-  }
-
   if(!(button_ptr = get_current_button(this, pci)))
     return S_ERR;
 
@@ -280,11 +274,6 @@
 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
-  if(!this) {
-    printerr("Passed a NULL pointer.");
-    return S_ERR;
-  }
-
   if(!(button_ptr = get_current_button(this, pci)))
     return S_ERR;
 
@@ -297,11 +286,6 @@
 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) {
   btni_t *button_ptr;
   
-  if(!this) {
-    printerr("Passed a NULL pointer.");
-    return S_ERR;
-  }
-
   if(!(button_ptr = get_current_button(this, pci)))
     return S_ERR;
 
@@ -353,7 +337,7 @@
   int button;
   btni_t *button_ptr = NULL;
 
-  if(!this) {
+  if(!this || !pci) {
     printerr("Passed a NULL pointer.");
     return S_ERR;
   }
@@ -361,6 +345,10 @@
     printerr("Not in a menu.");
     return S_ERR;
   }
+  if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
+    printerr("This NAV has already been left.");
+    return S_ERR;
+  }
 
   pthread_mutex_lock(&this->vm_lock); 
 
@@ -381,6 +369,7 @@
       vm_get_next_cell(this->vm);
       this->position_current.still = 0;
       this->sync_wait = 0;
+      this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn;
       pthread_mutex_unlock(&this->vm_lock);
       /* clear error message */
       printerr("");
@@ -400,6 +389,7 @@
     /* Command caused a jump */
     this->vm->hop_channel++;
     this->position_current.still = 0;
+    this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn;
   }
   
   pthread_mutex_unlock(&this->vm_lock); 
@@ -408,7 +398,7 @@
 
 dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd)
 {
-  if(!this) {
+  if(!this || !cmd) {
     printerr("Passed a NULL pointer.");
     return S_ERR;
   }
@@ -435,7 +425,7 @@
 
 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) {
   
-  if(!this) {
+  if(!this || !pci) {
     printerr("Passed a NULL pointer.");
     return S_ERR;
   }
@@ -443,6 +433,10 @@
     printerr("Not in a menu.");
     return S_ERR;
   }
+  if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
+    printerr("This NAV has already been left.");
+    return S_ERR;
+  }
  
 #ifdef BUTTON_TESTING
   fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); 
@@ -472,7 +466,7 @@
   int best,dist,d;
   int mx,my,dx,dy;
 
-  if(!this) {
+  if(!this || !pci) {
     printerr("Passed a NULL pointer.");
     return S_ERR;
   }
@@ -480,6 +474,10 @@
     printerr("Not in a menu.");
     return S_ERR;
   }
+  if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
+    printerr("This NAV has already been left.");
+    return S_ERR;
+  }
 
   cur_button = this->vm->state.HL_BTNN_REG >> 10;