diff options
author | eddyg <[email protected]> | 2007-08-27 22:06:37 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2007-08-27 22:06:37 +0000 |
commit | 629a658bc0afc640ed599637832c201711b5f1bd (patch) | |
tree | 1ce2a395fe48cec25dbe36953b5ff772f51cff28 | |
parent | 9f3728e88693ae501dce5a83d7d2852566167238 (diff) |
Enable jam to work by changing the error handling to use a callback rather than a direct call outside of libhb.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@880 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/common.c | 18 | ||||
-rw-r--r-- | libhb/common.h | 4 | ||||
-rw-r--r-- | macosx/main.mm | 4 | ||||
-rw-r--r-- | test/test.c | 25 |
4 files changed, 34 insertions, 17 deletions
diff --git a/libhb/common.c b/libhb/common.c index 45d207cb2..7a9679f3a 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -36,6 +36,8 @@ int hb_audio_bitrates_count = sizeof( hb_audio_bitrates ) / sizeof( hb_rate_t ); int hb_audio_bitrates_default = 8; /* 128 kbps */ +static hb_error_handler_t *error_handler = NULL; + hb_mixdown_t hb_audio_mixdowns[] = { { "Mono", "HB_AMIXDOWN_MONO", "mono", HB_AMIXDOWN_MONO }, { "Stereo", "HB_AMIXDOWN_STEREO", "stereo", HB_AMIXDOWN_STEREO }, @@ -530,12 +532,8 @@ void hb_log( char * log, ... ) void hb_error( char * log, ... ) { char string[181]; /* 180 chars + \0 */ - time_t _now; - struct tm * now; va_list args; - extern void hb_error_handler(const char *errmsg); - /* Convert the message to a string */ va_start( args, log ); vsnprintf( string, 180, log, args ); @@ -544,7 +542,17 @@ void hb_error( char * log, ... ) /* * Got the error in a single string, send it off to be dispatched. */ - hb_error_handler(string); + if( error_handler ) + { + error_handler( string ); + } else { + hb_log( string ); + } +} + +void hb_register_error_handler( hb_error_handler_t * handler ) +{ + error_handler = handler; } /********************************************************************** diff --git a/libhb/common.h b/libhb/common.h index 416a93eb6..0fc36473d 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -550,4 +550,8 @@ extern hb_filter_object_t hb_filter_deinterlace; extern hb_filter_object_t hb_filter_deblock; extern hb_filter_object_t hb_filter_denoise; +typedef void hb_error_handler_t( const char *errmsg ); + +extern void hb_register_error_handler( hb_error_handler_t * handler ); + #endif diff --git a/macosx/main.mm b/macosx/main.mm index 7880214f9..d4a05b5d2 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -5,6 +5,7 @@ It may be used under the terms of the GNU General Public License. */ #include <Cocoa/Cocoa.h> +#import "hb.h" void SigHandler( int signal ) { @@ -20,12 +21,13 @@ void SigHandler( int signal ) extern "C" { void hb_error_handler( const char *errmsg ) { - fprintf(stderr, "ERROR: %s\n", errmsg ); + fprintf(stderr, "GUI ERROR dialog: %s\n", errmsg ); } } int main( int argc, const char ** argv ) { signal( SIGINT, SigHandler ); + hb_register_error_handler(&hb_error_handler); return NSApplicationMain( argc, argv ); } diff --git a/test/test.c b/test/test.c index 49b787a3b..8694dc085 100644 --- a/test/test.c +++ b/test/test.c @@ -77,6 +77,17 @@ static int ParseOptions( int argc, char ** argv ); static int CheckOptions( int argc, char ** argv ); static int HandleEvents( hb_handle_t * h ); +/**************************************************************************** + * hb_error_handler + * + * When using the CLI just display using hb_log as we always did in the past + * make sure that we prefix with a nice ERROR message to catch peoples eyes. + ****************************************************************************/ +static void hb_cli_error_handler ( const char *errmsg ) +{ + hb_log( "ERROR: %s", errmsg ); +} + int main( int argc, char ** argv ) { hb_handle_t * h; @@ -90,6 +101,9 @@ int main( int argc, char ** argv ) return 1; } + /* Register our error handler */ + hb_register_error_handler(&hb_cli_error_handler); + /* Init libhb */ h = hb_init( debug, update ); @@ -1344,14 +1358,3 @@ static int CheckOptions( int argc, char ** argv ) return 0; } - -/**************************************************************************** - * hb_error_handler - * - * When using the CLI just display using hb_log as we always did in the past - * make sure that we prefix with a nice ERROR message to catch peoples eyes. - ****************************************************************************/ -void hb_error_handler ( const char *errmsg ) -{ - hb_log( "ERROR: %s", errmsg ); -} |