}
else
{
- status_str = g_strdup_printf ("Scanning title %d of %d...",
+ if (status.scan.preview_cur == 0)
+ status_str = g_strdup_printf("Scanning title %d of %d...",
status.scan.title_cur, status.scan.title_count );
+ else
+ status_str = g_strdup_printf(
+ "Scanning title %d of %d preview %d...",
+ status.scan.title_cur, status.scan.title_count,
+ status.scan.preview_cur);
+
}
gtk_label_set_text (label, status_str);
g_free(status_str);
if (status.scan.title_count > 0)
{
- gtk_progress_bar_set_fraction (scan_prog,
- (gdouble)status.scan.title_cur / status.scan.title_count);
+ gtk_progress_bar_set_fraction (scan_prog, status.scan.progress);
}
}
else if (status.scan.state & GHB_STATE_SCANDONE)
// when computing progress
hb_status.scan.title_count = 1;
hb_status.scan.title_cur = 0;
+ hb_status.scan.preview_count = 1;
+ hb_status.scan.preview_cur = 0;
+ hb_status.scan.progress = 0;
}
void
hb_status.scan.state |= GHB_STATE_SCANNING;
hb_status.scan.title_count = p.title_count;
hb_status.scan.title_cur = p.title_cur;
+ hb_status.scan.preview_count = p.preview_count;
+ hb_status.scan.preview_cur = p.preview_cur;
+ hb_status.scan.progress = p.progress;
} break;
#undef p
hb_status.queue.state |= GHB_STATE_SCANNING;
hb_status.queue.title_count = p.title_count;
hb_status.queue.title_cur = p.title_cur;
+ hb_status.queue.preview_count = p.preview_count;
+ hb_status.queue.preview_cur = p.preview_cur;
+ hb_status.queue.progress = p.progress;
} break;
#undef p
// SCANNING
gint title_count;
gint title_cur;
+ gint preview_count;
+ gint preview_cur;
// WORKING
gint unique_id;
g_idle_add((GSourceFunc)ghb_reload_queue, ud);
// Start timer for monitoring libhb status, 500ms
- g_timeout_add(500, ghb_timer_cb, (gpointer)ud);
+ g_timeout_add(200, ghb_timer_cb, (gpointer)ud);
// Add dvd devices to File menu
ghb_volname_cache_init();
struct
{
/* HB_STATE_SCANNING */
+ float progress;
+ int preview_cur;
+ int preview_count;
int title_cur;
int title_count;
} scanning;
static int DecodePreviews( hb_scan_t *, hb_title_t * title );
static void LookForAudio( hb_title_t * title, hb_buffer_t * b );
static int AllAudioOK( hb_title_t * title );
+static void UpdateState1(hb_scan_t *scan, int title);
+static void UpdateState2(hb_scan_t *scan, int title);
+static void UpdateState3(hb_scan_t *scan, int preview);
static const char *aspect_to_string( double aspect )
{
data->path = strdup( path );
data->title_index = title_index;
data->title_set = title_set;
-
+
data->preview_count = preview_count;
data->store_previews = store_previews;
data->min_title_duration = min_duration;
/* Scan all titles */
for( i = 0; i < hb_bd_title_count( data->bd ); i++ )
{
+ UpdateState1(data, i + 1);
hb_list_add( data->title_set->list_title,
hb_bd_title_scan( data->bd,
i + 1, data->min_title_duration ) );
/* Scan all titles */
for( i = 0; i < hb_dvd_title_count( data->dvd ); i++ )
{
+ UpdateState1(data, i + 1);
hb_list_add( data->title_set->list_title,
hb_dvd_title_scan( data->dvd,
i + 1, data->min_title_duration ) );
{
hb_title_t * title;
+ UpdateState1(data, i + 1);
title = hb_batch_title_scan( data->batch, i + 1 );
if ( title != NULL )
{
}
else
{
- hb_title_t * title = hb_title_init( data->path, 0 );
+ data->title_index = 1;
+ hb_title_t * title = hb_title_init( data->path, data->title_index );
if ( (data->stream = hb_stream_open( data->path, title, 1 ) ) != NULL )
{
title = hb_stream_title_scan( data->stream, title );
for( i = 0; i < hb_list_count( data->title_set->list_title ); )
{
int j;
- hb_state_t state;
hb_audio_t * audio;
if ( *data->die )
}
title = hb_list_item( data->title_set->list_title, i );
-#define p state.param.scanning
- /* Update the UI */
- state.state = HB_STATE_SCANNING;
- p.title_cur = title->index;
- p.title_count = data->dvd ? hb_dvd_title_count( data->dvd ) :
- data->bd ? hb_bd_title_count( data->bd ) :
- data->batch ? hb_batch_title_count( data->batch ) :
- hb_list_count(data->title_set->list_title);
- hb_set_state( data->h, &state );
-#undef p
+ UpdateState2(data, i + 1);
/* Decode previews */
/* this will also detect more AC3 / DTS information */
{
int j;
+ UpdateState3(data, i + 1);
+
if ( *data->die )
{
free( info_list );
hb_buffer_close( &vid_buf );
}
}
+ UpdateState3(data, i);
+
vid_decoder->close( vid_decoder );
free( vid_decoder );
}
return 1;
}
+
+static void UpdateState1(hb_scan_t *scan, int title)
+{
+ hb_state_t state;
+
+#define p state.param.scanning
+ /* Update the UI */
+ state.state = HB_STATE_SCANNING;
+ p.title_cur = title;
+ p.title_count = scan->dvd ? hb_dvd_title_count( scan->dvd ) :
+ scan->bd ? hb_bd_title_count( scan->bd ) :
+ scan->batch ? hb_batch_title_count( scan->batch ) :
+ hb_list_count(scan->title_set->list_title);
+ p.preview_cur = 0;
+ p.preview_count = 1;
+ p.progress = 0.5 * ((float)p.title_cur + ((float)p.preview_cur / p.preview_count)) / p.title_count;
+#undef p
+
+ hb_set_state(scan->h, &state);
+}
+
+static void UpdateState2(hb_scan_t *scan, int title)
+{
+ hb_state_t state;
+
+#define p state.param.scanning
+ /* Update the UI */
+ state.state = HB_STATE_SCANNING;
+ p.title_cur = title;
+ p.title_count = hb_list_count( scan->title_set->list_title );
+ p.preview_cur = 1;
+ p.preview_count = scan->preview_count;
+ if (scan->title_index)
+ p.progress = (float)p.title_cur / p.title_count;
+ else
+ p.progress = 0.5 + 0.5 * (float)p.title_cur / p.title_count;
+#undef p
+
+ hb_set_state(scan->h, &state);
+}
+
+static void UpdateState3(hb_scan_t *scan, int preview)
+{
+ hb_state_t state;
+
+ hb_get_state2(scan->h, &state);
+#define p state.param.scanning
+ p.preview_cur = preview;
+ p.preview_count = scan->preview_count;
+ if (scan->title_index)
+ p.progress = ((float)p.title_cur - 1 + ((float)p.preview_cur / p.preview_count)) / p.title_count;
+ else
+ p.progress = 0.5 + 0.5 * ((float)p.title_cur - 1 + ((float)p.preview_cur / p.preview_count)) / p.title_count;
+#undef p
+
+ hb_set_state(scan->h, &state);
+}
#define p s.param.scanning
case HB_STATE_SCANNING:
{
- [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
- NSLocalizedString( @"Scanning title %d of %d…", @"" ),
- p.title_cur, p.title_count]];
+ if( p.preview_cur )
+ {
+ [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
+ NSLocalizedString( @"Scanning title %d of %d, preview %d…", @"" ),
+ p.title_cur, p.title_count,
+ p.preview_cur]];
+ }
+ else
+ {
+ [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
+ NSLocalizedString( @"Scanning title %d of %d…", @"" ),
+ p.title_cur, p.title_count]];
+ }
[fScanIndicator setHidden: NO];
[fScanHorizontalLine setHidden: YES];
- [fScanIndicator setDoubleValue: 100.0 * ((double)( p.title_cur - 1 ) / p.title_count)];
+ [fScanIndicator setDoubleValue: 100.0 * p.progress];
break;
}
#undef p
#define p s.param.scanning
case HB_STATE_SCANNING:
{
- [fStatusField setStringValue: [NSString stringWithFormat:
- NSLocalizedString( @"Queue Scanning title %d of %d…", @"" ),
- p.title_cur, p.title_count]];
+ NSString *scan_status;
+ if( p.preview_cur )
+ {
+ scan_status = [NSString stringWithFormat:
+ NSLocalizedString( @"Queue Scanning title %d of %d, preview %d…", @"" ),
+ p.title_cur, p.title_count, p.preview_cur];
+ }
+ else
+ {
+ scan_status = [NSString stringWithFormat:
+ NSLocalizedString( @"Queue Scanning title %d of %d…", @"" ),
+ p.title_cur, p.title_count];
+ }
+ [fStatusField setStringValue: scan_status];
- /* Set the status string in fQueueController as well */
- [fQueueController setQueueStatusString: [NSString stringWithFormat:
- NSLocalizedString( @"Queue Scanning title %d of %d…", @"" ),
- p.title_cur, p.title_count]];
+ /* Set the status string in fQueueController as well */
+ [fQueueController setQueueStatusString: scan_status];
break;
}
#undef p
#define p s.param.scanning
case HB_STATE_SCANNING:
/* Show what title is currently being scanned */
- fprintf( stderr, "Scanning title %d", p.title_cur );
- if( !titleindex || titlescan )
- fprintf( stderr, " of %d", p.title_count );
- fprintf( stderr, "...\n" );
+ if (p.preview_cur)
+ {
+ fprintf(stdout, "\rScanning title %d of %d, preview %d, %.2f %%",
+ p.title_cur, p.title_count, p.preview_cur, 100 * p.progress);
+ }
+ else
+ {
+ fprintf(stdout, "\rScanning title %d of %d, %.2f %%",
+ p.title_cur, p.title_count, 100 * p.progress);
+ }
+ fflush(stdout);
break;
#undef p