X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fcommon.c;h=073abb9777c76c0ed0d67ed79edd3b01397c2bd6;hb=533776bbad20db93fe964bc69975f108b2a30888;hp=c8cc8dddc810b82c24f2b50f018c94b20285f4fe;hpb=27f82628e116613e7e333a52d75b7aebca7e7fb8;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/common.c b/libhb/common.c index c8cc8ddd..073abb97 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -549,6 +549,44 @@ void hb_log( char * log, ... ) fprintf( stderr, "%s", string ); } +int global_verbosity_level; //Necessary for hb_deep_log +/********************************************************************** + * hb_deep_log + ********************************************************************** + * If verbose mode is >= level, print message with timestamp. Messages + * longer than 360 characters are stripped ;p + *********************************************************************/ +void hb_deep_log( hb_debug_level_t level, char * log, ... ) +{ + char string[362]; /* 360 chars + \n + \0 */ + time_t _now; + struct tm * now; + va_list args; + + if( global_verbosity_level < level ) + { + /* Hiding message */ + return; + } + + /* Get the time */ + _now = time( NULL ); + now = localtime( &_now ); + sprintf( string, "[%02d:%02d:%02d] ", + now->tm_hour, now->tm_min, now->tm_sec ); + + /* Convert the message to a string */ + va_start( args, log ); + vsnprintf( string + 11, 349, log, args ); + va_end( args ); + + /* Add the end of line */ + strcat( string, "\n" ); + + /* Print it */ + fprintf( stderr, "%s", string ); +} + /********************************************************************** * hb_error ********************************************************************** @@ -667,8 +705,13 @@ void hb_filter_close( hb_filter_object_t ** _f ) *********************************************************************/ hb_audio_t *hb_audio_copy(const hb_audio_t *src) { - hb_audio_t *audio = calloc(1, sizeof(*audio)); - memcpy(audio, src, sizeof(*audio)); + hb_audio_t *audio = NULL; + + if( src ) + { + audio = calloc(1, sizeof(*audio)); + memcpy(audio, src, sizeof(*audio)); + } return audio; }