diff searching.c @ 113:ec2df154be56 src

slightly improved logic of program skipping: previous program: -> if PG > 1, jump to PG - 1 -> otherwise, if prev_PGC is set, jump to last PG of prev_PGC -> otherwise fail next program: -> if PG < last_PG, jump to PG + 1 -> otherwise, if next_PGC is set, jump to first PG of next_PGC -> otherwise, move to last Cell of current PG and ask the VM for the next Cell
author mroi
date Mon, 13 Jan 2003 13:33:45 +0000
parents 06cba5cee071
children b6834e6359cf
line wrap: on
line diff
--- a/searching.c	Mon Jan 06 19:59:28 2003 +0000
+++ b/searching.c	Mon Jan 13 13:33:45 2003 +0000
@@ -238,14 +238,12 @@
     return S_ERR;
 
   pthread_mutex_lock(&this->vm_lock);
-  /* Make sure this is not the first chapter */
-  if(state->pgN <= 1 ) {
-    fprintf(MSG_OUT, "libdvdnav: at first chapter. prev chapter failed.\n");
+  fprintf(MSG_OUT, "libdvdnav: previous chapter\n");
+  if (!vm_prev_pg(this->vm)) {
+    fprintf(MSG_OUT, "libdvdnav: prev chapter failed.\n");
     pthread_mutex_unlock(&this->vm_lock);
     return S_ERR;
   }
-  fprintf(MSG_OUT, "libdvdnav: previous chapter\n");
-  vm_jump_prog(this->vm, state->pgN - 1);
   this->position_current.still = 0;
   this->vm->hop_channel++;
   fprintf(MSG_OUT, "libdvdnav: previous chapter done\n");
@@ -275,14 +273,11 @@
     return S_ERR;
 
   pthread_mutex_lock(&this->vm_lock);
-  /* Make sure this is not the last chapter */
-  if(state->pgN >= state->pgc->nr_of_programs) {
-    fprintf(MSG_OUT, "libdvdnav: at last chapter. jumping to end of last cell.\n");
-    this->vm->state.cellN = this->vm->state.pgc->nr_of_cells;
-    vm_get_next_cell(this->vm);
-  } else {
-    fprintf(MSG_OUT, "libdvdnav: next chapter\n");
-    vm_jump_prog(this->vm, state->pgN + 1);
+  fprintf(MSG_OUT, "libdvdnav: next chapter\n");
+  if (!vm_next_pg(this->vm)) {
+    fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n");
+    pthread_mutex_unlock(&this->vm_lock);
+    return S_ERR;
   }
   this->position_current.still = 0;
   this->vm->hop_channel++;