+ // XXX the current version of libdvdnav can't seek outside the current
+ // PGC. Check if the place we're seeking to is in a different
+ // PGC. Position there & adjust the offset if so.
+ hb_chapter_t *pgc_change = hb_list_item(d->list_chapter, 0 );
+ for ( ii = 0; ii < hb_list_count( d->list_chapter ); ++ii )
+ {
+ hb_chapter_t *chapter = hb_list_item( d->list_chapter, ii );
+
+ if ( chapter->pgcn != pgc_change->pgcn )
+ {
+ // this chapter's in a different pgc from the previous - note the
+ // change so we can make sector offset's be pgc relative.
+ pgc_change = chapter;
+ }
+ if ( chapter->block_start <= sector && sector <= chapter->block_end )
+ {
+ // this chapter contains the sector we want - see if it's in a
+ // different pgc than the one we're currently in.
+ int32_t title, pgcn, pgn;
+ if (dvdnav_current_title_program( d->dvdnav, &title, &pgcn, &pgn ) != DVDNAV_STATUS_OK)
+ hb_log("dvdnav cur pgcn err: %s", dvdnav_err_to_string(d->dvdnav));
+ if ( d->title != title || chapter->pgcn != pgcn )
+ {
+ // this chapter is in a different pgc - switch to it.
+ if (dvdnav_program_play(d->dvdnav, d->title, chapter->pgcn, chapter->pgn) != DVDNAV_STATUS_OK)
+ hb_log("dvdnav prog play err: %s", dvdnav_err_to_string(d->dvdnav));
+ }
+ // seek sectors are pgc-relative so remove the pgc start sector.
+ sector -= pgc_change->block_start;
+ break;
+ }
+ }
+