From 1a5e685b5465c52940089ced8181a2a402ad86b2 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Sat, 17 Apr 2010 19:41:43 +0000 Subject: [PATCH] fix some dvdnav hangs title changes seem to confuse the vm sometimes. so do a dvdnav_reset whenever a title change is going to happen. Also, fix dvdnav_reset since it would deadlock on a mutex when called. git-svn-id: svn://localhost/HandBrake/trunk@3240 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- contrib/libdvdnav/A06-reset-mutex.patch | 25 +++++++++++++++++++++++++ libhb/dvdnav.c | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 contrib/libdvdnav/A06-reset-mutex.patch diff --git a/contrib/libdvdnav/A06-reset-mutex.patch b/contrib/libdvdnav/A06-reset-mutex.patch new file mode 100644 index 00000000..76f55e34 --- /dev/null +++ b/contrib/libdvdnav/A06-reset-mutex.patch @@ -0,0 +1,25 @@ +Index: src/dvdnav.c +=================================================================== +--- libdvdnav.orig/src/dvdnav.c (revision 1168) ++++ libdvdnav/src/dvdnav.c (working copy) +@@ -178,9 +178,9 @@ + #ifdef LOG_DEBUG + fprintf(MSG_OUT, "libdvdnav: clearing dvdnav\n"); + #endif ++ pthread_mutex_unlock(&this->vm_lock); + result = dvdnav_clear(this); + +- pthread_mutex_unlock(&this->vm_lock); + return result; + } + +@@ -519,7 +519,8 @@ + } + + /* Check to see if we need to change the currently opened VOB */ +- if((this->position_current.vts != this->position_next.vts) || ++ if((this->file == NULL) || ++ (this->position_current.vts != this->position_next.vts) || + (this->position_current.domain != this->position_next.domain)) { + dvd_read_domain_t domain; + int32_t vtsN; diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c index 8d7ac70e..09d0ad2e 100644 --- a/libhb/dvdnav.c +++ b/libhb/dvdnav.c @@ -836,6 +836,7 @@ static int hb_dvdnav_start( hb_dvd_t * e, hb_title_t *title, int c ) { return 0; } + dvdnav_reset( d->dvdnav ); chapter = hb_list_item( title->list_chapter, c - 1); if (chapter != NULL) result = dvdnav_program_play(d->dvdnav, t, chapter->pgcn, chapter->pgn); @@ -905,6 +906,13 @@ static int hb_dvdnav_seek( hb_dvd_t * e, float f ) 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 we find ourselves in a new title, it means a title + // transition was made while reading data. Jumping between + // titles can cause the vm to get into a bad state. So + // reset the vm in this case. + if ( d->title != title ) + dvdnav_reset( d->dvdnav ); + if ( d->title != title || chapter->pgcn != pgcn ) { // this chapter is in a different pgc - switch to it. @@ -1088,6 +1096,16 @@ static int hb_dvdnav_read( hb_dvd_t * e, hb_buffer_t * b ) * event can be used to query such information only when * necessary and update the decoding/displaying accordingly. */ + { + int tt = 0, pgcn = 0, pgn = 0, c; + + dvdnav_current_title_program(d->dvdnav, &tt, &pgcn, &pgn); + if (tt != d->title) + { + // Transition to another title signals that we are done. + return 0; + } + } break; case DVDNAV_CELL_CHANGE: -- 2.11.0