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++;
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;
return h;
}
-
/**
* Returns current version of libhb.
* @param h Handle to hb_handle_t.