diff options
author | Rodeo <[email protected]> | 2013-06-03 15:37:38 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2013-06-03 15:37:38 +0000 |
commit | 16deb214281cd72ffaf2a11d3a5556c5b950a966 (patch) | |
tree | f673787fe7a92a894ec2ccace325af298831ef92 /libhb/hb.c | |
parent | 812134ffba931aa603e67f541e7a2f0f03215fbb (diff) |
libhb/common: improve fallback mechanism.
API changes:
- added hb_global_init(), must be called before any other libhb function
- removed (somewhat pointless) hb_mixdown_t.internal_name
- some hb_*_get_from_name() functions now return 0 instead of -1.
Instead of hardcoded fallbacks, list items now have a specific fallback, and a generic ID for when the specific fallback is unavailable.
Encoder availability is checked at runtime (hb_global_init calling hb_common_global_init) and the item's value/fallback is sanity-checked and updated if necessary.
See https://reviews.handbrake.fr/r/506/ for more detailed information.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5547 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb.c')
-rw-r--r-- | libhb/hb.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/libhb/hb.c b/libhb/hb.c index 35e341b8a..bf8845609 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -70,7 +70,6 @@ struct hb_handle_s hb_work_object_t * hb_objects = NULL; int hb_instance_counter = 0; -int hb_process_initialized = 0; static void thread_func( void * ); @@ -355,26 +354,6 @@ void hb_register( hb_work_object_t * w ) hb_objects = w; } -/** - * Ensures that the process has been initialized. - */ -static void process_init() -{ - if (!hb_process_initialized) - { -#if defined( SYS_MINGW ) && defined( PTW32_STATIC_LIB ) - pthread_win32_process_attach_np(); -#endif - -#if defined( _WIN32 ) || defined( __MINGW32__ ) - setvbuf( stdout, NULL, _IONBF, 0 ); - setvbuf( stderr, NULL, _IONBF, 0 ); -#endif - hb_process_initialized = 1; - } - -} - void (*hb_log_callback)(const char* message); static void redirect_thread_func(void *); @@ -388,8 +367,6 @@ static void redirect_thread_func(void *); */ void hb_register_logger( void (*log_cb)(const char* message) ) { - process_init(); - hb_log_callback = log_cb; hb_thread_init("ioredirect", redirect_thread_func, NULL, HB_NORMAL_PRIORITY); } @@ -402,8 +379,6 @@ void hb_register_logger( void (*log_cb)(const char* message) ) */ hb_handle_t * hb_init( int verbose, int update_check ) { - process_init(); - hb_handle_t * h = calloc( sizeof( hb_handle_t ), 1 ); uint64_t date; @@ -1694,6 +1669,22 @@ void hb_close( hb_handle_t ** _h ) *_h = NULL; } +int hb_global_init() +{ + int result = 0; + + result = hb_platform_init(); + if (result < 0) + { + hb_error("Platform specific initialization failed!"); + return -1; + } + + hb_common_global_init(); + + return result; +} + /** * Cleans up libhb at a process level. Call before the app closes. Removes preview directory. */ |