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 },
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 );
/*
* 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;
}
/**********************************************************************
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
It may be used under the terms of the GNU General Public License. */
#include <Cocoa/Cocoa.h>
+#import "hb.h"
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 );
}
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;
return 1;
}
+ /* Register our error handler */
+ hb_register_error_handler(&hb_cli_error_handler);
+
/* Init libhb */
h = hb_init( debug, update );
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 );
-}