1 diff -Naur libdvdnav.orig/src/searching.c libdvdnav/src/searching.c
2 --- libdvdnav.orig/src/searching.c 2009-01-08 14:57:11.000000000 -0800
3 +++ libdvdnav/src/searching.c 2009-09-12 12:35:12.483551884 -0700
5 /* Return placed in vobu. */
6 /* Returns error status */
7 /* FIXME: Maybe need to handle seeking outside current cell. */
8 -static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, uint32_t *vobu) {
9 +static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, uint8_t next, uint32_t *vobu) {
10 vobu_admap_t *admap = NULL;
14 vobu_start = next_vobu;
22 return DVDNAV_STATUS_OK;
24 fprintf(MSG_OUT, "libdvdnav: admap not located\n");
26 fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
27 cell_nr, first_cell_nr, last_cell_nr);
29 - if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
30 + if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
31 uint32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
33 if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {
36 /* convert the target sector from Cell-relative to absolute physical sector */
37 target += cell->first_sector;
38 + if (origin == SEEK_CUR && offset > 0) {
40 + /* if we are seeking forward from the current position, make sure
41 + * we move to a new position that is after our current position.
42 + * simply truncating to the vobu will go backwards */
43 + if (dvdnav_scan_admap(this, state->domain, target, 1, &vobu) == DVDNAV_STATUS_OK) {
44 + if (vobu > cell->last_sector) {
45 + if (cell_nr == last_cell_nr) {
49 + cell = &(state->pgc->cell_playback[cell_nr-1]);
50 + target = cell->first_sector;
63 fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
64 cell_nr, first_cell_nr, last_cell_nr);
66 - if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
67 + if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
68 int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
70 if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {