summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2015-06-12 20:52:01 +0000
committerjstebbins <[email protected]>2015-06-12 20:52:01 +0000
commit1be7a8e58feb0d26cac7067dcd289aec2aebb2e7 (patch)
tree07713faf52c6dd0dbf129ec35aecd217bf00b39e /libhb
parentf2b0998a8f4ef77d3ef791b64ad032c1bb8348ea (diff)
libhb: Allow log level changes and update checks *after* hb_init()
- In the CLI, this allows calling hb_init() before parsing args, which permits us to see any libhb log messages that are generated during option parsing. These messages were hidden before. - In the GUIs, this allows dynamic changes to log level. Previously an application restart was required. I have only updated the LinGui to take advantage of this. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7295 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.c6
-rw-r--r--libhb/hb.c125
-rw-r--r--libhb/hb.h3
3 files changed, 36 insertions, 98 deletions
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 );