# HG changeset patch # User mroi # Date 1048524179 0 # Node ID d09a81cf65ced6a973b625dd745f027b4af155a5 # Parent f22458f928b81aef99d68659977beeeec5f8c740 determine correct PG and PTT numbers when seeking across PG boundaries diff -r f22458f928b8 -r d09a81cf65ce navigation.c --- a/navigation.c Sun Mar 23 15:24:31 2003 +0000 +++ b/navigation.c Mon Mar 24 16:42:59 2003 +0000 @@ -156,6 +156,8 @@ return S_ERR; } retval = vm_jump_title_part(this->vm, title, part); + if (retval) + this->vm->hop_channel++; pthread_mutex_unlock(&this->vm_lock); return retval ? S_OK : S_ERR; diff -r f22458f928b8 -r d09a81cf65ce searching.c --- a/searching.c Sun Mar 23 15:24:31 2003 +0000 +++ b/searching.c Mon Mar 24 16:42:59 2003 +0000 @@ -77,7 +77,7 @@ int found = 0; /* Search through ADMAP for best sector */ - vobu_start = 0x3fffffff; + vobu_start = SRI_END_OF_CELL; /* FIXME: Implement a faster search algorithm */ while((!found) && ((address<<2) < admap->last_byte)) { next_vobu = admap->vobu_start_sectors[address]; @@ -120,10 +120,6 @@ } result = dvdnav_get_position(this, &target, &length); -#ifdef LOG_DEBUG - fprintf(MSG_OUT, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); - fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN); -#endif if(!result) { return S_ERR; } @@ -135,6 +131,10 @@ pthread_mutex_unlock(&this->vm_lock); return S_ERR; } +#ifdef LOG_DEBUG + fprintf(MSG_OUT, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); + fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN); +#endif switch(origin) { case SEEK_SET: @@ -167,7 +167,7 @@ pthread_mutex_unlock(&this->vm_lock); return S_ERR; } - + if (this->pgc_based) { first_cell_nr = 1; last_cell_nr = state->pgc->nr_of_cells; @@ -196,31 +196,27 @@ } if(found) { - int32_t vobu, start; + int32_t vobu; #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", cell_nr, first_cell_nr, last_cell_nr); #endif - dvdnav_scan_admap(this, state->domain, target, &vobu); - - start = state->pgc->cell_playback[cell_nr-1].first_sector; - state->blockN = vobu - start; - state->cellN = cell_nr; - state->cell_restart++; + if (dvdnav_scan_admap(this, state->domain, target, &vobu) == S_OK) { + int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector; + + if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) { #ifdef LOG_DEBUG - fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , - state->cellN, - state->blockN, - target, - vobu, - start); + fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , + state->cellN, state->blockN, target, vobu, start); #endif - this->vm->hop_channel += HOP_SEEK; - pthread_mutex_unlock(&this->vm_lock); - return S_OK; + this->vm->hop_channel += HOP_SEEK; + pthread_mutex_unlock(&this->vm_lock); + return S_OK; + } + } } - fprintf(MSG_OUT, "libdvdnav: Error when seeking, asked to seek outside program\n"); + 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); diff -r f22458f928b8 -r d09a81cf65ce vm.c --- a/vm.c Sun Mar 23 15:24:31 2003 +0000 +++ b/vm.c Mon Mar 24 16:42:59 2003 +0000 @@ -471,6 +471,13 @@ return 1; } +int vm_jump_cell_block(vm_t *vm, int cell, int block) { + (vm->state).cellN = cell; + process_command(vm, play_Cell(vm)); + (vm->state).blockN = block; + return 1; +} + int vm_jump_title_part(vm_t *vm, int title, int part) { int vtsN; @@ -479,7 +486,6 @@ if(!set_VTS_PTT(vm, vtsN, title, part)) return 0; process_command(vm, play_PGC_PG(vm, (vm->state).pgN)); - vm->hop_channel++; return 1; } @@ -1799,6 +1805,9 @@ /* * $Log$ + * Revision 1.47 2003/03/24 16:42:59 mroi + * determine correct PG and PTT numbers when seeking across PG boundaries + * * Revision 1.46 2003/03/15 20:21:44 mroi * - do not rely on 1:1 mappings between PTTs and PGs * - fix get_PGCN for cases where get_PGCIT returns NULL diff -r f22458f928b8 -r d09a81cf65ce vm.h --- a/vm.h Sun Mar 23 15:24:31 2003 +0000 +++ b/vm.h Mon Mar 24 16:42:59 2003 +0000 @@ -139,6 +139,7 @@ /* Jumping - all these return 1, if a hop has been performed */ int vm_jump_pg(vm_t *vm, int pg); +int vm_jump_cell_block(vm_t *vm, int cell, int block); int vm_jump_title_part(vm_t *vm, int title, int part); int vm_jump_top_pg(vm_t *vm); int vm_jump_next_pg(vm_t *vm);