summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2015-09-25 14:02:19 -0700
committerJohn Stebbins <[email protected]>2015-09-29 09:47:56 -0700
commit291243c3fcd34282a700b059995c27a993b12e71 (patch)
tree3d4ec14d3df387ddb47b1611b69cc54c521dd137 /libhb
parentc349173bb641530a97f787e75e9aa14fff043506 (diff)
scan: fix rescan avoidance logic
We need to rescan when the number of previews changes.
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.h1
-rw-r--r--libhb/hb.c25
-rw-r--r--libhb/hb_json.c2
-rw-r--r--libhb/scan.c1
4 files changed, 23 insertions, 6 deletions
diff --git a/libhb/common.h b/libhb/common.h
index b540de9de..4f39c8944 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -962,6 +962,7 @@ struct hb_title_s
/* Exact duration (in 1/90000s) */
uint64_t duration;
+ int preview_count;
int has_resolution_change;
hb_geometry_t geometry;
hb_rational_t dar; // aspect ratio for the title's video
diff --git a/libhb/hb.c b/libhb/hb.c
index 2f4a71720..55800c832 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -610,14 +610,29 @@ void hb_scan( hb_handle_t * h, const char * path, int title_index,
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;
+ // In some cases, we don't care what the preview count is.
+ // E.g. when rescanning at the start of a job. In these
+ // cases, the caller can set preview_count to -1 to tell
+ // us to use the same count as the previous scan, if known.
+ if (preview_count < 0)
+ {
+ preview_count = title->preview_count;
+ }
+ if (preview_count == title->preview_count)
+ {
+ // Title has already been scanned.
+ hb_lock( h->state_lock );
+ h->state.state = HB_STATE_SCANDONE;
+ hb_unlock( h->state_lock );
+ return;
+ }
}
}
}
+ if (preview_count < 0)
+ {
+ preview_count = 10;
+ }
h->scan_die = 0;
diff --git a/libhb/hb_json.c b/libhb/hb_json.c
index a9d104b90..e5c64bb9f 100644
--- a/libhb/hb_json.c
+++ b/libhb/hb_json.c
@@ -751,7 +751,7 @@ void hb_json_job_scan( hb_handle_t * h, const char * json_job )
// If the job wants to use Hardware decode, it must also be
// enabled during scan. So enable it here.
hb_hwd_set_enable(h, use_hwd);
- hb_scan(h, path, title_index, 10, 0, 0);
+ hb_scan(h, path, title_index, -1, 0, 0);
// Wait for scan to complete
hb_state_t state;
diff --git a/libhb/scan.c b/libhb/scan.c
index 2280644ba..8626ccca8 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -240,6 +240,7 @@ static void ScanFunc( void * _data )
hb_title_close( &title );
continue;
}
+ title->preview_count = npreviews;
/* Make sure we found audio rates and bitrates */
for( j = 0; j < hb_list_count( title->list_audio ); )