OSDN Git Service

dvdnav: add read error recovery
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 28 Jun 2009 21:28:03 +0000 (21:28 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 28 Jun 2009 21:28:03 +0000 (21:28 +0000)
- a single read error was causing early encode termination.
  try to continue reading at next sector on an error.

git-svn-id: svn://localhost/HandBrake/trunk@2639 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/dvdnav.c

index 8cc5995..fa6aa83 100644 (file)
@@ -971,6 +971,7 @@ static int hb_dvdnav_read( hb_dvd_t * e, hb_buffer_t * b )
     hb_dvdnav_t * d = &(e->dvdnav);
     int result, event, len;
     int chapter = 0;
+    int error_count = 0;
 
     while ( 1 )
     {
@@ -982,8 +983,21 @@ static int hb_dvdnav_read( hb_dvd_t * e, hb_buffer_t * b )
         if ( result == DVDNAV_STATUS_ERR )
         {
             hb_log("dvdnav: Read Error, %s", dvdnav_err_to_string(d->dvdnav));
-            return 0;
+            if (dvdnav_sector_search(d->dvdnav, 1, SEEK_CUR) != DVDNAV_STATUS_OK)
+            {
+                hb_error( "dvd: dvdnav_sector_search failed - %s", 
+                        dvdnav_err_to_string(d->dvdnav) );
+                return 0;
+            }
+            error_count++;
+            if (error_count > 10)
+            {
+                hb_log("dvdnav: Error, too many consecutive read errors");
+                return 0;
+            }
+            continue;
         }
+        error_count = 0;
         switch ( event )
         {
         case DVDNAV_BLOCK_OK: