diff options
-rw-r--r-- | gtk/src/callbacks.c | 8 | ||||
-rw-r--r-- | gtk/src/ghb-3.12.ui | 2 | ||||
-rw-r--r-- | gtk/src/ghb-3.14.ui | 2 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 2 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 9 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 1 | ||||
-rw-r--r-- | libhb/common.c | 6 | ||||
-rw-r--r-- | libhb/hb.c | 125 | ||||
-rw-r--r-- | libhb/hb.h | 3 | ||||
-rw-r--r-- | test/test.c | 8 |
10 files changed, 63 insertions, 103 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 2e0d36000..72bd33a6f 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -4082,6 +4082,14 @@ pref_changed_cb(GtkWidget *widget, signal_user_data_t *ud) } G_MODULE_EXPORT void +log_level_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + pref_changed_cb(widget, ud); + int level = ghb_dict_get_int(ud->prefs, "LoggingLevel"); + ghb_log_level_set(level); +} + +G_MODULE_EXPORT void use_m4v_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { g_debug("use_m4v_changed_cb"); diff --git a/gtk/src/ghb-3.12.ui b/gtk/src/ghb-3.12.ui index e66881fad..6b886d6c1 100644 --- a/gtk/src/ghb-3.12.ui +++ b/gtk/src/ghb-3.12.ui @@ -7444,7 +7444,7 @@ This file may be reloaded at a later time to edit your jobs and re-encode.</prop <property name="width_request">55</property> <property name="visible">True</property> <property name="can_focus">False</property> - <signal name="changed" handler="pref_changed_cb" swapped="no"/> + <signal name="changed" handler="log_level_changed_cb" swapped="no"/> </object> <packing> <property name="expand">False</property> diff --git a/gtk/src/ghb-3.14.ui b/gtk/src/ghb-3.14.ui index 9a3cf537d..8a153c978 100644 --- a/gtk/src/ghb-3.14.ui +++ b/gtk/src/ghb-3.14.ui @@ -7450,7 +7450,7 @@ This file may be reloaded at a later time to edit your jobs and re-encode.</prop <property name="width_request">55</property> <property name="visible">True</property> <property name="can_focus">False</property> - <signal name="changed" handler="pref_changed_cb" swapped="no"/> + <signal name="changed" handler="log_level_changed_cb" swapped="no"/> </object> <packing> <property name="expand">False</property> diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index add5b6c6c..03524f78e 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -7444,7 +7444,7 @@ This file may be reloaded at a later time to edit your jobs and re-encode.</prop <property name="width_request">55</property> <property name="visible">True</property> <property name="can_focus">False</property> - <signal name="changed" handler="pref_changed_cb" swapped="no"/> + <signal name="changed" handler="log_level_changed_cb" swapped="no"/> </object> <packing> <property name="expand">False</property> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index ecb33f791..839b4e052 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -149,6 +149,7 @@ static options_map_t d_logging_opts[] = {"0", "0", 0, "0"}, {"1", "1", 1, "1"}, {"2", "2", 2, "2"}, + {"3", "3", 3, "3"}, }; combo_opts_t logging_opts = { @@ -2866,6 +2867,14 @@ ghb_backend_init(gint debug) } void +ghb_log_level_set(int level) +{ + hb_log_level_set(h_scan, level); + hb_log_level_set(h_queue, level); + hb_log_level_set(h_live, level); +} + +void ghb_backend_close() { hb_close(&h_live); diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 940a4340a..42fefe965 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -89,6 +89,7 @@ float ghb_vquality_default(signal_user_data_t *ud); void ghb_combo_init(signal_user_data_t *ud); void ghb_backend_init(gint debug); +void ghb_log_level_set(int level); void ghb_backend_close(void); void ghb_add_job(hb_handle_t *h, GhbValue *js, gint unique_id); void ghb_remove_job(gint unique_id); diff --git a/libhb/common.c b/libhb/common.c index dae8d42b5..6b7859461 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -2839,12 +2839,6 @@ void hb_valog( hb_debug_level_t level, const char * prefix, const char * log, va struct tm * now; char preamble[362]; - if( !getenv( "HB_DEBUG" ) ) - { - /* We don't want to print it */ - return; - } - if( global_verbosity_level < level ) { /* Hiding message */ diff --git a/libhb/hb.c b/libhb/hb.c index 2512c4568..33fe42007 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -377,92 +377,56 @@ void hb_register_logger( void (*log_cb)(const char* message) ) hb_thread_init("ioredirect", redirect_thread_func, NULL, HB_NORMAL_PRIORITY); } -/** - * libhb initialization routine. - * @param verbose HB_DEBUG_NONE or HB_DEBUG_ALL. - * @param update_check signals libhb to check for updated version from HandBrake website. - * @return Handle to hb_handle_t for use on all subsequent calls to libhb. - */ -hb_handle_t * hb_init( int verbose, int update_check ) +void hb_log_level_set(hb_handle_t *h, int level) { - hb_handle_t * h = calloc( sizeof( hb_handle_t ), 1 ); - uint64_t date; + global_verbosity_level = level; +} - /* See hb_deep_log() and hb_log() in common.c */ - global_verbosity_level = verbose; - if( verbose ) - putenv( "HB_DEBUG=1" ); - - h->id = hb_instance_counter++; - - /* Check for an update on the website if asked to */ - h->build = -1; +void hb_update_poll(hb_handle_t *h) +{ + uint64_t date; - /* Initialize opaque for PowerManagement purposes */ - h->system_sleep_opaque = hb_system_sleep_opaque_init(); + hb_log( "hb_update_poll: checking for updates" ); + date = hb_get_date(); + h->update_thread = hb_update_init( &h->build, h->version ); - if( update_check ) + for( ;; ) { - hb_log( "hb_init: checking for updates" ); - date = hb_get_date(); - h->update_thread = hb_update_init( &h->build, h->version ); - - for( ;; ) + if (h->update_thread == 0) { - if( hb_thread_has_exited( h->update_thread ) ) - { - /* Immediate success or failure */ - hb_thread_close( &h->update_thread ); - break; - } - if( hb_get_date() > date + 1000 ) - { - /* Still nothing after one second. Connection problem, - let the thread die */ - hb_log( "hb_init: connection problem, not waiting for " - "update_thread" ); - break; - } - hb_snooze( 500 ); + // Closed by thread_func + break; + } + if (hb_thread_has_exited(h->update_thread)) + { + /* Immediate success or failure */ + hb_thread_close( &h->update_thread ); + break; + } + if (hb_get_date() > date + 1000) + { + /* Still nothing after one second. Connection problem, + let the thread die */ + hb_log( "hb_update_poll: connection problem, not waiting for " + "update_thread" ); + break; } + hb_snooze( 500 ); } - - h->title_set.list_title = hb_list_init(); - h->jobs = hb_list_init(); - - h->state_lock = hb_lock_init(); - h->state.state = HB_STATE_IDLE; - - h->pause_lock = hb_lock_init(); - - h->interjob = calloc( sizeof( hb_interjob_t ), 1 ); - - /* Start library thread */ - hb_log( "hb_init: starting libhb thread" ); - h->die = 0; - h->main_thread = hb_thread_init( "libhb", thread_func, h, - HB_NORMAL_PRIORITY ); - - return h; } /** * libhb initialization routine. - * This version is to use when calling the dylib, the macro hb_init isn't available from a dylib call! * @param verbose HB_DEBUG_NONE or HB_DEBUG_ALL. * @param update_check signals libhb to check for updated version from HandBrake website. * @return Handle to hb_handle_t for use on all subsequent calls to libhb. */ -hb_handle_t * hb_init_dl( int verbose, int update_check ) +hb_handle_t * hb_init( int verbose, int update_check ) { hb_handle_t * h = calloc( sizeof( hb_handle_t ), 1 ); - uint64_t date; - /* See hb_log() in common.c */ - if( verbose > HB_DEBUG_NONE ) - { - putenv( "HB_DEBUG=1" ); - } + /* See hb_deep_log() and hb_log() in common.c */ + hb_log_level_set(h, verbose); h->id = hb_instance_counter++; @@ -474,39 +438,19 @@ hb_handle_t * hb_init_dl( int verbose, int update_check ) if( update_check ) { - hb_log( "hb_init: checking for updates" ); - date = hb_get_date(); - h->update_thread = hb_update_init( &h->build, h->version ); - - for( ;; ) - { - if( hb_thread_has_exited( h->update_thread ) ) - { - /* Immediate success or failure */ - hb_thread_close( &h->update_thread ); - break; - } - if( hb_get_date() > date + 1000 ) - { - /* Still nothing after one second. Connection problem, - let the thread die */ - hb_log( "hb_init: connection problem, not waiting for " - "update_thread" ); - break; - } - hb_snooze( 500 ); - } + hb_update_poll(h); } h->title_set.list_title = hb_list_init(); h->jobs = hb_list_init(); - h->current_job = NULL; h->state_lock = hb_lock_init(); h->state.state = HB_STATE_IDLE; h->pause_lock = hb_lock_init(); + h->interjob = calloc( sizeof( hb_interjob_t ), 1 ); + /* Start library thread */ hb_log( "hb_init: starting libhb thread" ); h->die = 0; @@ -516,7 +460,6 @@ hb_handle_t * hb_init_dl( int verbose, int update_check ) return h; } - /** * Returns current version of libhb. * @param h Handle to hb_handle_t. diff --git a/libhb/hb.h b/libhb/hb.h index a838c943d..cbf25f712 100644 --- a/libhb/hb.h +++ b/libhb/hb.h @@ -31,7 +31,8 @@ extern "C" { void hb_register( hb_work_object_t * ); void hb_register_logger( void (*log_cb)(const char* message) ); hb_handle_t * hb_init( int verbose, int update_check ); -hb_handle_t * hb_init_dl ( int verbose, int update_check ); // hb_init for use with dylib +void hb_update_poll(hb_handle_t *h); +void hb_log_level_set(hb_handle_t *h, int level); void hb_hwd_set_enable( hb_handle_t *h, uint8_t enable ); int hb_hwd_enabled( hb_handle_t *h ); diff --git a/test/test.c b/test/test.c index 2748ea8b7..4d72283b9 100644 --- a/test/test.c +++ b/test/test.c @@ -257,6 +257,9 @@ int main( int argc, char ** argv ) hb_global_init(); hb_presets_builtin_update(); + /* Init libhb */ + h = hb_init(4, 0); // Show all logging until debug level is parsed + // Get utf8 command line if windows get_argv_utf8(&argc, &argv); @@ -267,11 +270,11 @@ int main( int argc, char ** argv ) return 1; } + hb_log_level_set(h, debug); + /* Register our error handler */ hb_register_error_handler(&hb_cli_error_handler); - /* Init libhb */ - h = hb_init( debug, update ); hb_dvd_set_dvdnav( dvdnav ); /* Show version */ @@ -281,6 +284,7 @@ int main( int argc, char ** argv ) /* Check for update */ if( update ) { + hb_update_poll(h); if( ( build = hb_check_update( h, &version ) ) > -1 ) { fprintf( stderr, "You are using an old version of " |