diff searching.c @ 22:3c1df0cb3aee src

Start of rewrite of libdvdnav. Still need to re-implement seeking.
author jcdutton
date Mon, 22 Apr 2002 22:01:28 +0000
parents 66708b4a1b5e
children 870a0a1eee41
line wrap: on
line diff
--- a/searching.c	Mon Apr 22 20:57:15 2002 +0000
+++ b/searching.c	Mon Apr 22 22:01:28 2002 +0000
@@ -33,13 +33,13 @@
 
 /* Searching API calls */
 
-dvdnav_status_t dvdnav_time_search(dvdnav_t *self,
+dvdnav_status_t dvdnav_time_search(dvdnav_t *this,
 				   unsigned long int time) {
 /* Time search the current PGC based on the xxx table */
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_sector_search(dvdnav_t *self,
+dvdnav_status_t dvdnav_sector_search(dvdnav_t *this,
 				   unsigned long int offset, int origin) {
 /* FIXME: Implement */
 
@@ -51,55 +51,55 @@
   dvd_state_t *state;
   dvdnav_status_t result;
 
-  if((!self) || (!self->vm) )
+  if((!this) || (!this->vm) )
     return -1;
   
-  state = &(self->vm->state);
+  state = &(this->vm->state);
   if((!state) || (!state->pgc) )
     return -1;
    
   if(offset == 0) 
     return -1;
 
-  if(self->still_frame != -1)
+  if(this->position_current.still != 0)
     /* Cannot do seeking in a still frame. */
     return -1;
 
-  pthread_mutex_lock(&self->vm_lock);
-  result = dvdnav_get_position(self, &target, &length);
+  pthread_mutex_lock(&this->vm_lock);
+  result = dvdnav_get_position(this, &target, &length);
   fprintf(stderr,"FIXME: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); 
   fprintf(stderr,"FIXME: Before cellN=%u blockN=%u\n" ,
       state->cellN,
       state->blockN);
   if(!result) {
-    pthread_mutex_unlock(&self->vm_lock);
+    pthread_mutex_unlock(&this->vm_lock);
     return -1;
   }
  
   switch(origin) {
    case SEEK_SET:
     if(offset > length) {
-      pthread_mutex_unlock(&self->vm_lock);
+      pthread_mutex_unlock(&this->vm_lock);
       return -1;
     }
     target = offset;
     break;
    case SEEK_CUR:
     if(target + offset > length) {
-      pthread_mutex_unlock(&self->vm_lock);
+      pthread_mutex_unlock(&this->vm_lock);
       return -1;
     }
     target += offset;
     break;
    case SEEK_END:
     if(length - offset < 0) {
-      pthread_mutex_unlock(&self->vm_lock);
+      pthread_mutex_unlock(&this->vm_lock);
       return -1;
     }
     target = length - offset;
    default:
     /* Error occured */
-    pthread_mutex_unlock(&self->vm_lock);
+    pthread_mutex_unlock(&this->vm_lock);
     return -1;
   }
 
@@ -127,20 +127,20 @@
   if(fnd_cell_nr <= last_cell_nr) {
     fprintf(stderr,"Seeking to cell %i from choice of %i to %i\n",
 	   fnd_cell_nr, first_cell_nr, last_cell_nr);
-    self->seekto_block = target;
-    self->seeking = 1;
+    this->seekto_block = target;
+    this->seeking = 1;
     /* 
      * Clut does not actually change,
      * but as the decoders have been closed then opened,
      * A new clut has to be sent.
      */
-    self->spu_clut_changed = 1;
+    this->spu_clut_changed = 1;
     //ogle_do_post_jump(ogle);
     fprintf(stderr,"FIXME: After cellN=%u blockN=%u\n" ,
       state->cellN,
       state->blockN);
     
-    pthread_mutex_unlock(&self->vm_lock);
+    pthread_mutex_unlock(&this->vm_lock);
     return target;
   } else {
     fprintf(stderr, "Error when seeking, asked to seek outside program\n");
@@ -150,20 +150,20 @@
 
   fprintf(stderr,"FIXME: Implement seeking to location %u\n", target); 
 
-//  self->seekto_block=target;
-//  self->seeking = 1;
+//  this->seekto_block=target;
+//  this->seeking = 1;
 
-  pthread_mutex_unlock(&self->vm_lock);
+  pthread_mutex_unlock(&this->vm_lock);
   return -1;
 }
 
-dvdnav_status_t dvdnav_part_search(dvdnav_t *self, int part) {
+dvdnav_status_t dvdnav_part_search(dvdnav_t *this, int part) {
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *self) {
+dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) {
   dvd_state_t *state;
-  state = &(self->vm->state);
+  state = &(this->vm->state);
   /* Make sure this is not the first chapter */
   
   if(state->pgN <= 1 ) {
@@ -171,54 +171,56 @@
     return S_ERR;
   }
   fprintf(stderr,"dvdnav: previous chapter\n");
-  vm_jump_prog(self->vm, state->pgN - 1);
-  dvdnav_do_post_jump(self);
+  vm_jump_prog(this->vm, state->pgN - 1);
+  dvdnav_do_post_jump(this);
+  this->vm->hop_channel++;
   fprintf(stderr,"dvdnav: previous chapter done\n");
 
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *self) {
+dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) {
 
   fprintf(stderr,"dvdnav: top chapter. NOP.\n");
   
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *self) {
+dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) {
   dvd_state_t *state;
-  state = &(self->vm->state);
+  state = &(this->vm->state);
   /* Make sure this is not the last chapter */
   if(state->pgN >= state->pgc->nr_of_programs) {
     fprintf(stderr,"dvdnav: at last chapter. next chapter failed.\n");
     return S_ERR;
   }
   fprintf(stderr,"dvdnav: next chapter\n");
-  vm_jump_prog(self->vm, state->pgN + 1);
-  dvdnav_do_post_jump(self);
+  vm_jump_prog(this->vm, state->pgN + 1);
+  dvdnav_do_post_jump(this);
+  this->vm->hop_channel++;
   fprintf(stderr,"dvdnav: next chapter done\n");
 
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_menu_call(dvdnav_t *self, DVDMenuID_t menu) {
+dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) {
   dvd_state_t *state;
 
-  pthread_mutex_lock(&self->vm_lock); 
-  state = &(self->vm->state);
-  vm_menu_call(self->vm, menu, 0); 
-  dvdnav_do_post_jump(self);
-  pthread_mutex_unlock(&self->vm_lock); 
+  pthread_mutex_lock(&this->vm_lock); 
+  state = &(this->vm->state);
+  vm_menu_call(this->vm, menu, 0); 
+  dvdnav_do_post_jump(this);
+  pthread_mutex_unlock(&this->vm_lock); 
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_current_title_info(dvdnav_t *self, int *tt, int *pr) {
+dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *tt, int *pr) {
 int vts_ttn = 0;
   int vts, i;
   domain_t domain;
   tt_srpt_t* srpt;
   
-  if(!self)
+  if(!this)
    return S_ERR;
 
   if(!tt || !pr) {
@@ -230,26 +232,26 @@
   if(*pr)
    *pr = -1;
 
-  domain = self->vm->state.domain;
+  domain = this->vm->state.domain;
   if((domain == FP_DOMAIN) || (domain == VMGM_DOMAIN)) {
     /* Not in a title */
     return S_OK;
   }
   
-  vts_ttn = self->vm->state.VTS_TTN_REG;
-  vts = self->vm->state.vtsN;
+  vts_ttn = this->vm->state.VTS_TTN_REG;
+  vts = this->vm->state.vtsN;
 
   if(pr) {
-    *pr = self->vm->state.pgN;
+    *pr = this->vm->state.pgN;
   }
 
   /* Search TT_SRPT for title */
-  if(!(vm_get_vmgi(self->vm))) {
+  if(!(vm_get_vmgi(this->vm))) {
     printerr("Oh poo, no SRPT");
     return S_ERR;
   }
   
-  srpt = vm_get_vmgi(self->vm)->tt_srpt;
+  srpt = vm_get_vmgi(this->vm)->tt_srpt;
   for(i=0; i<srpt->nr_of_srpts; i++) {
     title_info_t* info = &(srpt->title[i]);
     if((info->title_set_nr == vts) && (info->vts_ttn == vts_ttn)) {
@@ -263,8 +265,8 @@
 
 static char __title_str[] = "DVDNAV";
 
-dvdnav_status_t dvdnav_get_title_string(dvdnav_t *self, char **title_str) {
-  if(!self)
+dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, char **title_str) {
+  if(!this)
    return S_ERR;
 
   if(!title_str) {
@@ -277,7 +279,7 @@
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_get_position(dvdnav_t *self, unsigned int* pos,
+dvdnav_status_t dvdnav_get_position(dvdnav_t *this, unsigned int* pos,
 				    unsigned int *len) {
   uint32_t cur_sector;
   uint32_t first_cell_nr;
@@ -285,10 +287,10 @@
   cell_playback_t *first_cell;
   cell_playback_t *last_cell;
   dvd_state_t *state;
-  if((!self) || (!self->vm) )
+  if((!this) || (!this->vm) )
    return 0;
   
-  state = &(self->vm->state);
+  state = &(this->vm->state);
   if((!state) || (!state->pgc) )
    return 0;
    
@@ -298,7 +300,7 @@
   }
   
   /* Get current sector */
-  cur_sector = self->vobu_start + self->blockN;
+  cur_sector = this->vobu.vobu_start + this->vobu.blockN;
 
   /* Find start cell of program. */
   first_cell_nr = state->pgc->program_map[state->pgN-1];
@@ -318,7 +320,7 @@
   return S_OK;
 }
 
-dvdnav_status_t dvdnav_get_position_in_title(dvdnav_t *self,
+dvdnav_status_t dvdnav_get_position_in_title(dvdnav_t *this,
 					     unsigned int *pos,
 					     unsigned int *len) {
   uint32_t cur_sector;
@@ -327,10 +329,10 @@
   cell_playback_t *first_cell;
   cell_playback_t *last_cell;
   dvd_state_t *state;
-  if((!self) || (!self->vm) )
+  if((!this) || (!this->vm) )
    return S_ERR;
   
-  state = &(self->vm->state);
+  state = &(this->vm->state);
   if((!state) || (!state->pgc) )
    return S_ERR;
    
@@ -340,7 +342,7 @@
   }
   
   /* Get current sector */
-  cur_sector = self->vobu_start + self->blockN;
+  cur_sector = this->vobu.vobu_start + this->vobu.blockN;
 
   /* Now find first and last cells in title. */
   first_cell_nr = state->pgc->program_map[0];