]> granicus.if.org Git - handbrake/commitdiff
scan: skip scan if title has already been scanned
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 26 May 2015 17:10:09 +0000 (17:10 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 26 May 2015 17:10:09 +0000 (17:10 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7226 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.h
libhb/hb.c
libhb/hb_json.c
libhb/scan.c

index c9cf5079869b7e1d819ca4d80fc491ef52a262d4..ce5dc8841717fad59222015e2da91171014a03e1 100644 (file)
@@ -434,6 +434,7 @@ struct hb_title_set_s
 {
     hb_list_t   * list_title;
     int           feature;    // Detected DVD feature title
+    char          path[1024];
 };
 
 typedef enum
index f4ec2308fc7a1fa1e944f695b4addaa484c5c8d7..2512c45689006496db36b2de410411cf0f76fc16 100644 (file)
@@ -602,6 +602,26 @@ void hb_scan( hb_handle_t * h, const char * path, int title_index,
 {
     hb_title_t * title;
 
+    // Check if scanning is necessary.
+    if (!strcmp(h->title_set.path, path))
+    {
+        // Current title_set path matches requested path.
+        // Check if the requested title has already been scanned.
+        int ii;
+        for (ii = 0; ii < hb_list_count(h->title_set.list_title); ii++)
+        {
+            title = hb_list_item(h->title_set.list_title, ii);
+            if (title->index == title_index)
+            {
+                // Title has already been scanned.
+                hb_lock( h->state_lock );
+                h->state.state = HB_STATE_SCANDONE;
+                hb_unlock( h->state_lock );
+                return;
+            }
+        }
+    }
+
     h->scan_die = 0;
 
     /* Clean up from previous scan */
index 93673f371d15a80af922bb59710801c2a16624ac..69760cd83cc189f3ab8af07e1bec454186dc80fc 100644 (file)
@@ -391,8 +391,8 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job )
     "s:o,"
     // Destination {Mux, ChapterMarkers, ChapterList}
     "s:{s:o, s:o, s:[]},"
-    // Source {Title, Angle}
-    "s:{s:o, s:o,},"
+    // Source {Path, Title, Angle}
+    "s:{s:o, s:o, s:o,},"
     // PAR {Num, Den}
     "s:{s:o, s:o},"
     // Video {Codec, QSV {Decode, AsyncDepth}}
@@ -412,6 +412,7 @@ hb_dict_t* hb_job_to_dict( const hb_job_t * job )
             "ChapterMarkers",   hb_value_bool(job->chapter_markers),
             "ChapterList",
         "Source",
+            "Path",             hb_value_string(job->title->path),
             "Title",            hb_value_int(job->title->index),
             "Angle",            hb_value_int(job->angle),
         "PAR",
@@ -753,11 +754,12 @@ void hb_json_job_scan( hb_handle_t * h, const char * json_job )
 
     // Wait for scan to complete
     hb_state_t state;
-    do
+    hb_get_state2(h, &state);
+    while (state.state == HB_STATE_SCANNING)
     {
         hb_snooze(50);
         hb_get_state2(h, &state);
-    } while (state.state == HB_STATE_SCANNING);
+    }
 }
 
 static int validate_audio_codec_mux(int codec, int mux, int track)
index b747c72395c5406add3e8284ff65c5cf398cee16..3a19d9e19132915b0bfd220c4e3b90c7d799ea42 100644 (file)
@@ -288,6 +288,15 @@ static void ScanFunc( void * _data )
         title      = hb_list_item( data->title_set->list_title, i );
         title->flags |= HBTF_SCAN_COMPLETE;
     }
+    if (hb_list_count(data->title_set->list_title) > 0)
+    {
+        strncpy(data->title_set->path, data->path, 1024);
+        data->title_set->path[1023] = 0;
+    }
+    else
+    {
+        data->title_set->path[0] = 0;
+    }
 
 finish: