changeset 116:4d711d0518e9 src

new event DVDNAV_WAIT
author mroi
date Tue, 25 Feb 2003 14:08:16 +0000
parents b527b7cbfb19
children 816d82ff7eed
files dvdnav.c dvdnav.h dvdnav_events.h dvdnav_internal.h.in highlight.c navigation.c
diffstat 6 files changed, 75 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/dvdnav.c	Mon Feb 24 18:19:27 2003 +0000
+++ b/dvdnav.c	Tue Feb 25 14:08:16 2003 +0000
@@ -55,6 +55,8 @@
   /* Set initial values of flags */
   this->position_current.still = 0;
   this->skip_still = 0;
+  this->sync_wait = 0;
+  this->sync_wait_skip = 0;
   this->spu_clut_changed = 0;
   this->started = 0;
 
@@ -402,7 +404,7 @@
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: POS-NEXT ");
   vm_position_print(this->vm, &this->position_next);
-  fprintf(MSG_OUT, "libdvdnav: POS-CUR ");
+  fprintf(MSG_OUT, "libdvdnav: POS-CUR  ");
   vm_position_print(this->vm, &this->position_current);
 #endif
 
@@ -448,10 +450,39 @@
     /* Make blockN > vobu_length to do expected_nav */
     this->vobu.vobu_length = 0;
     this->vobu.blockN      = 1;
+    this->sync_wait        = 0;
     pthread_mutex_unlock(&this->vm_lock); 
     return S_OK;
   }
 
+  /* Check the HIGHLIGHT flag */
+  if(this->position_current.button != this->position_next.button) {
+    dvdnav_highlight_event_t hevent;
+
+    (*event) = DVDNAV_HIGHLIGHT;
+#ifdef LOG_DEBUG
+    fprintf(MSG_OUT, "libdvdnav: HIGHLIGHT\n");
+#endif
+    (*len) = sizeof(hevent);
+    hevent.display = 1;
+    hevent.buttonN = this->position_next.button;
+    memcpy(*buf, &(hevent), sizeof(hevent));
+    this->position_current.button = this->position_next.button;
+    pthread_mutex_unlock(&this->vm_lock); 
+    return S_OK;
+  }
+  
+  /* Check the WAIT flag */
+  if(this->sync_wait) {
+    (*event) = DVDNAV_WAIT;
+#ifdef LOG_DEBUG
+    fprintf(MSG_OUT, "libdvdnav: WAIT\n");
+#endif
+    (*len) = 0;
+    pthread_mutex_unlock(&this->vm_lock);
+    return S_OK;
+  }
+
   /* Check to see if we need to change the currently opened VOB */
   if((this->position_current.vts != this->position_next.vts) || 
      (this->position_current.domain != this->position_next.domain)) {
@@ -613,23 +644,6 @@
     return S_OK;
   }
      
-  /* Check the HIGHLIGHT flag */
-  if(this->position_current.button != this->position_next.button) {
-    dvdnav_highlight_event_t hevent;
-
-    (*event) = DVDNAV_HIGHLIGHT;
-#ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: HIGHLIGHT\n");
-#endif
-    (*len) = sizeof(hevent);
-    hevent.display = 1;
-    hevent.buttonN = this->position_next.button;
-    memcpy(*buf, &(hevent), sizeof(hevent));
-    this->position_current.button = this->position_next.button;
-    pthread_mutex_unlock(&this->vm_lock); 
-    return S_OK;
-  }
-
   /* Check the STILLFRAME flag */
   if(this->position_current.still != 0) {
     dvdnav_still_event_t still_event;
@@ -656,11 +670,19 @@
 #endif
       this->position_current.still = this->position_next.still;
 
-      if( this->position_current.still == 0 || this->skip_still ) {
-        /* no active cell still -> get us to the next cell */
-	vm_get_next_cell(this->vm);
-	this->position_current.still = 0; /* still gets activated at end of cell */
-	this->skip_still = 0;
+      /* we are about to leave a cell, so a lot of state changes could occur;
+       * under certain conditions, the application should get in sync with us before this,
+       * otherwise it might show stills or menus too shortly */
+      if ((this->position_current.still || this->pci.hli.hl_gi.hli_ss) && !this->sync_wait_skip) {
+        this->sync_wait = 1;
+      } else {
+	if( this->position_current.still == 0 || this->skip_still ) {
+	  /* no active cell still -> get us to the next cell */
+	  vm_get_next_cell(this->vm);
+	  this->position_current.still = 0; /* still gets activated at end of cell */
+	  this->skip_still = 0;
+	  this->sync_wait_skip = 0;
+	}
       }
       /* handle related state changes in next iteration */
       (*event) = DVDNAV_NOP;
@@ -957,8 +979,8 @@
 
 /*
  * $Log$
- * Revision 1.41  2003/02/24 18:19:27  mroi
- * fix seek detection
+ * Revision 1.42  2003/02/25 14:08:14  mroi
+ * new event DVDNAV_WAIT
  *
  * Revision 1.40  2003/02/20 15:32:15  mroi
  * big libdvdnav cleanup, quoting the ChangeLog:
--- a/dvdnav.h	Mon Feb 24 18:19:27 2003 +0000
+++ b/dvdnav.h	Tue Feb 25 14:08:16 2003 +0000
@@ -297,6 +297,15 @@
 dvdnav_status_t dvdnav_still_skip(dvdnav_t *self);
 
 /**
+ * If we are currently in WAIT state, that is: the application is required to
+ * wait for its fifos to become empty, calling this signals libdvdnav that this
+ * is achieved and that it can continue.
+ *
+ * \param self Pointer to dvdnav_t associated with this operation.
+ */
+dvdnav_status_t dvdnav_wait_skip(dvdnav_t *self);
+
+/**
  * Returns the still time status from the next cell
  *
  * \param self Pointer to dvdnav_t associated with this operation.
--- a/dvdnav_events.h	Mon Feb 24 18:19:27 2003 +0000
+++ b/dvdnav_events.h	Tue Feb 25 14:08:16 2003 +0000
@@ -47,6 +47,7 @@
 #define DVDNAV_HIGHLIGHT		 9 /*!< Change highlight region */
 #define DVDNAV_SPU_CLUT_CHANGE		10 /*!< SPU CLUT changed */
 #define DVDNAV_HOP_CHANNEL		12 /*!< Sent when non-seemless stream change has happed */
+#define DVDNAV_WAIT			13 /*!< The application should wait for its fifos to run dry */
 
 
 /*** EVENT TYPES ***/
--- a/dvdnav_internal.h.in	Mon Feb 24 18:19:27 2003 +0000
+++ b/dvdnav_internal.h.in	Tue Feb 25 14:08:16 2003 +0000
@@ -141,6 +141,8 @@
   
   /* Flags */
   int skip_still;                 /* Set when skipping a still */
+  int sync_wait;                  /* applications should wait till they are in sync with us */
+  int sync_wait_skip;             /* Set when skipping wait state */
   int spu_clut_changed;           /* The SPU CLUT changed */ 
   int started;                    /* vm_start has been called? */
   int use_read_ahead;             /* 1 - use read-ahead cache, 0 - don't */
--- a/highlight.c	Mon Feb 24 18:19:27 2003 +0000
+++ b/highlight.c	Tue Feb 25 14:08:16 2003 +0000
@@ -372,6 +372,7 @@
       /* In still, but no buttons. */
       vm_get_next_cell(this->vm);
       this->position_current.still = 0;
+      this->sync_wait = 0;
       pthread_mutex_unlock(&this->vm_lock);
       /* clear error message */
       printerr("");
@@ -419,6 +420,7 @@
   }
   /* Always remove still, because some still menus have no buttons. */
   this->position_current.still = 0;
+  this->sync_wait = 0;
   pthread_mutex_unlock(&this->vm_lock);
   return S_OK;
 }  
--- a/navigation.c	Mon Feb 24 18:19:27 2003 +0000
+++ b/navigation.c	Tue Feb 25 14:08:16 2003 +0000
@@ -39,6 +39,20 @@
 
   this->position_current.still = 0;
   this->skip_still = 1;
+  this->sync_wait = 0;
+  this->sync_wait_skip = 1;
+
+  return S_OK;
+}
+
+dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) {
+  if(!this) {
+    printerr("Passed a NULL pointer.");
+    return S_ERR;
+  }
+
+  this->sync_wait = 0;
+  this->sync_wait_skip = 1;
 
   return S_OK;
 }