⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searching.c

📁 linux下的MPEG1
💻 C
📖 第 1 页 / 共 2 页
字号:
        pthread_mutex_unlock(&this->vm_lock);        return DVDNAV_STATUS_OK;      }    }  }    fprintf(MSG_OUT, "libdvdnav: Error when seeking\n");  fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target);   printerr("Error when seeking.");  pthread_mutex_unlock(&this->vm_lock);  return DVDNAV_STATUS_ERR;}dvdnav_status_t dvdnav_part_search(dvdnav_t *this, int32_t part) {  int32_t title, old_part;    if (dvdnav_current_title_info(this, &title, &old_part) == DVDNAV_STATUS_OK)    return dvdnav_part_play(this, title, part);  return DVDNAV_STATUS_ERR;}dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) {  if(!this) {    printerr("Passed a NULL pointer.");    return DVDNAV_STATUS_ERR;  }    pthread_mutex_lock(&this->vm_lock);  if(!this->vm->state.pgc) {    printerr("No current PGC.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }#ifdef LOG_DEBUG  fprintf(MSG_OUT, "libdvdnav: previous chapter\n");#endif  if (!vm_jump_prev_pg(this->vm)) {    fprintf(MSG_OUT, "libdvdnav: previous chapter failed.\n");    printerr("Skip to previous chapter failed.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }  this->position_current.still = 0;  this->vm->hop_channel++;#ifdef LOG_DEBUG  fprintf(MSG_OUT, "libdvdnav: previous chapter done\n");#endif  pthread_mutex_unlock(&this->vm_lock);  return DVDNAV_STATUS_OK;}dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) {  if(!this) {    printerr("Passed a NULL pointer.");    return DVDNAV_STATUS_ERR;  }      pthread_mutex_lock(&this->vm_lock);  if(!this->vm->state.pgc) {    printerr("No current PGC.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }#ifdef LOG_DEBUG  fprintf(MSG_OUT, "libdvdnav: top chapter\n");#endif  if (!vm_jump_top_pg(this->vm)) {    fprintf(MSG_OUT, "libdvdnav: top chapter failed.\n");    printerr("Skip to top chapter failed.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }  this->position_current.still = 0;  this->vm->hop_channel++;#ifdef LOG_DEBUG  fprintf(MSG_OUT, "libdvdnav: top chapter done\n");#endif  pthread_mutex_unlock(&this->vm_lock);  return DVDNAV_STATUS_OK;}dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) {  vm_t *try_vm;  if(!this) {    printerr("Passed a NULL pointer.");    return DVDNAV_STATUS_ERR;  }  pthread_mutex_lock(&this->vm_lock);  if(!this->vm->state.pgc) {    printerr("No current PGC.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }#ifdef LOG_DEBUG  fprintf(MSG_OUT, "libdvdnav: next chapter\n");#endif  /* make a copy of current VM and try to navigate the copy to the next PG */  try_vm = vm_new_copy(this->vm);  if (!vm_jump_next_pg(try_vm) || try_vm->stopped) {    vm_free_copy(try_vm);    /* next_pg failed, try to jump at least to the next cell */    try_vm = vm_new_copy(this->vm);    vm_get_next_cell(try_vm);    if (try_vm->stopped) {      vm_free_copy(try_vm);      fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n");      printerr("Skip to next chapter failed.");      pthread_mutex_unlock(&this->vm_lock);      return DVDNAV_STATUS_ERR;    }  }  /* merge changes on success */  vm_merge(this->vm, try_vm);  vm_free_copy(try_vm);  this->position_current.still = 0;  this->vm->hop_channel++;#ifdef LOG_DEBUG  fprintf(MSG_OUT, "libdvdnav: next chapter done\n");#endif  pthread_mutex_unlock(&this->vm_lock);  return DVDNAV_STATUS_OK;}dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) {  vm_t *try_vm;    if(!this) {    printerr("Passed a NULL pointer.");    return DVDNAV_STATUS_ERR;  }  pthread_mutex_lock(&this->vm_lock);  if(!this->vm->state.pgc) {    printerr("No current PGC.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }    /* make a copy of current VM and try to navigate the copy to the menu */  try_vm = vm_new_copy(this->vm);  if ( (menu == DVD_MENU_Escape) && (this->vm->state.domain != VTS_DOMAIN)) {    /* Try resume */    if (vm_jump_resume(try_vm) && !try_vm->stopped) {        /* merge changes on success */        vm_merge(this->vm, try_vm);        vm_free_copy(try_vm);        this->position_current.still = 0;        this->vm->hop_channel++;        pthread_mutex_unlock(&this->vm_lock);         return DVDNAV_STATUS_OK;    }  }  if (menu == DVD_MENU_Escape) menu = DVD_MENU_Root;   if (vm_jump_menu(try_vm, menu) && !try_vm->stopped) {    /* merge changes on success */    vm_merge(this->vm, try_vm);    vm_free_copy(try_vm);    this->position_current.still = 0;    this->vm->hop_channel++;    pthread_mutex_unlock(&this->vm_lock);     return DVDNAV_STATUS_OK;  } else {    vm_free_copy(try_vm);    printerr("No such menu or menu not reachable.");    pthread_mutex_unlock(&this->vm_lock);     return DVDNAV_STATUS_ERR;  }}dvdnav_status_t dvdnav_get_position(dvdnav_t *this, uint32_t *pos,				    uint32_t *len) {  uint32_t cur_sector;  int32_t cell_nr, first_cell_nr, last_cell_nr;  cell_playback_t *cell;  dvd_state_t *state;  if(!this || !pos || !len) {    printerr("Passed a NULL pointer.");    return DVDNAV_STATUS_ERR;  }  if(!this->started) {    printerr("Virtual DVD machine not started.");    return DVDNAV_STATUS_ERR;  }  pthread_mutex_lock(&this->vm_lock);  state = &(this->vm->state);  if(!state->pgc || this->vm->stopped) {    printerr("No current PGC.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }  if (this->position_current.hop_channel  != this->vm->hop_channel ||      this->position_current.domain       != state->domain         ||      this->position_current.vts          != state->vtsN           ||      this->position_current.cell_restart != state->cell_restart) {    printerr("New position not yet determined.");    pthread_mutex_unlock(&this->vm_lock);    return DVDNAV_STATUS_ERR;  }  /* Get current sector */  cur_sector = this->vobu.vobu_start + this->vobu.blockN;  if (this->pgc_based) {    first_cell_nr = 1;    last_cell_nr = state->pgc->nr_of_cells;  } else {    /* Find start cell of program. */    first_cell_nr = state->pgc->program_map[state->pgN-1];    /* Find end cell of program */    if(state->pgN < state->pgc->nr_of_programs)      last_cell_nr = state->pgc->program_map[state->pgN] - 1;    else      last_cell_nr = state->pgc->nr_of_cells;  }  *pos = -1;  *len = 0;  for (cell_nr = first_cell_nr; cell_nr <= last_cell_nr; cell_nr++) {    cell = &(state->pgc->cell_playback[cell_nr-1]);    if (cell_nr == state->cellN) {      /* the current sector is in this cell,       * pos is length of PG up to here + sector's offset in this cell */      *pos = *len + cur_sector - cell->first_sector;    }    *len += cell->last_sector - cell->first_sector + 1;  }    assert((signed)*pos != -1);  pthread_mutex_unlock(&this->vm_lock);  return DVDNAV_STATUS_OK;}dvdnav_status_t dvdnav_get_position_in_title(dvdnav_t *this,					     uint32_t *pos,					     uint32_t *len) {  uint32_t cur_sector;  uint32_t first_cell_nr;  uint32_t last_cell_nr;  cell_playback_t *first_cell;  cell_playback_t *last_cell;  dvd_state_t *state;  if(!this || !pos || !len) {    printerr("Passed a NULL pointer.");    return DVDNAV_STATUS_ERR;  }  state = &(this->vm->state);  if(!state->pgc) {    printerr("No current PGC.");    return DVDNAV_STATUS_ERR;  }  /* Get current sector */  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];  first_cell = &(state->pgc->cell_playback[first_cell_nr-1]);  last_cell_nr = state->pgc->nr_of_cells;  last_cell = &(state->pgc->cell_playback[last_cell_nr-1]);    *pos = cur_sector - first_cell->first_sector;  *len = last_cell->last_sector - first_cell->first_sector;    return DVDNAV_STATUS_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -