diff options
author | konablend <[email protected]> | 2009-06-25 03:36:26 +0000 |
---|---|---|
committer | konablend <[email protected]> | 2009-06-25 03:36:26 +0000 |
commit | eef252057e08aeffc4a8b43d6eba838012debc28 (patch) | |
tree | 711122c860cc6fa878a0681046da0e0f20ed7ed4 /libhb | |
parent | 1f5936650ac23cec965a8934b36a21b4f4bcfa16 (diff) |
Format cleanup.
- fixed ports.c to use a more portable method of getting integral pthread_t representation; resolves mingw crash.
- added GCC attribute to generate compiler warnings for invalid usage of hb_log, hb_deep_log and hb_errror;
see new macro HB_WPRINTF(s,v) in common.h.
- fixed various invalid usage of above functions on osx i386/x86_64, and mingw.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2618 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.c | 4 | ||||
-rw-r--r-- | libhb/common.h | 6 | ||||
-rw-r--r-- | libhb/decsrtsub.c | 3 | ||||
-rw-r--r-- | libhb/dvd.c | 2 | ||||
-rw-r--r-- | libhb/dvdnav.c | 2 | ||||
-rw-r--r-- | libhb/internal.h | 6 | ||||
-rw-r--r-- | libhb/muxcommon.c | 3 | ||||
-rw-r--r-- | libhb/platform/macosx/encca_aac.c | 2 | ||||
-rw-r--r-- | libhb/ports.c | 28 |
9 files changed, 40 insertions, 16 deletions
diff --git a/libhb/common.c b/libhb/common.c index 824996352..1da836ece 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -124,8 +124,8 @@ void hb_fix_aspect( hb_job_t * job, int keep ) if ( title->height == 0 || title->width == 0 || title->aspect == 0 ) { hb_log( "hb_fix_aspect: incomplete info for title %d: " - "height = %d, width = %d, aspect = %d", - title->height, title->width, title->aspect ); + "height = %d, width = %d, aspect = %.3f", + title->index, title->height, title->width, title->aspect ); return; } diff --git a/libhb/common.h b/libhb/common.h index 808714ee7..fb1f21198 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -18,6 +18,12 @@ #include <sys/stat.h> #include <dirent.h> +#if defined( __GNUC__ ) && !(defined( _WIN32 ) || defined( __MINGW32__ )) +# define HB_WPRINTF(s,v) __attribute__((format(printf,s,v))) +#else +# define HB_WPRINTF(s,v) +#endif + #if defined( SYS_MINGW ) # define fseek fseeko64 # define ftell ftello64 diff --git a/libhb/decsrtsub.c b/libhb/decsrtsub.c index 190c2df80..51aaeeb90 100644 --- a/libhb/decsrtsub.c +++ b/libhb/decsrtsub.c @@ -123,8 +123,7 @@ static hb_buffer_t *srt_read( hb_work_private_t *pv ) hb_error( "Invalid shift sequence" ); } else if ( ( retval == -1 ) && ( errno == EILSEQ ) ) { - hb_error( "Invalid byte for codeset in input, %d bytes discarded", - in_size); + hb_error( "Invalid byte for codeset in input, %"PRId64" bytes discarded", (int64_t)in_size); } else if ( ( retval == -1 ) && ( errno == E2BIG ) ) { hb_error( "Not enough space in output buffer"); diff --git a/libhb/dvd.c b/libhb/dvd.c index 2d5fb8c9d..b26725da9 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -232,7 +232,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t ) pgn = vts->vts_ptt_srpt->title[title->ttn-1].ptt[0].pgn; d->pgc = vts->vts_pgcit->pgci_srp[pgc_id-1].pgc; - hb_log("pgc_id: %d, pgn: %d: pgc: 0x%x", pgc_id, pgn, d->pgc); + hb_log("pgc_id: %d, pgn: %d: pgc: %p", pgc_id, pgn, d->pgc); if( !d->pgc ) { diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c index dfe847d8a..805e8f2bf 100644 --- a/libhb/dvdnav.c +++ b/libhb/dvdnav.c @@ -425,7 +425,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t ) pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc; - hb_log("pgc_id: %d, pgn: %d: pgc: 0x%x", pgcn, pgn, pgc); + hb_log("pgc_id: %d, pgn: %d: pgc: %p", pgcn, pgn, pgc); if (pgn > pgc->nr_of_programs) { hb_error( "invalid PGN %d for title %d, skipping", pgn, t ); diff --git a/libhb/internal.h b/libhb/internal.h index c68d9fa82..9a03074bf 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -7,7 +7,7 @@ /*********************************************************************** * common.c **********************************************************************/ -void hb_log( char * log, ... ); +void hb_log( char * log, ... ) HB_WPRINTF(1,2); extern int global_verbosity_level; // Global variable for hb_deep_log typedef enum hb_debug_level_s { @@ -15,8 +15,8 @@ typedef enum hb_debug_level_s HB_HOUSEKEEPING_LOG = 2, // stuff we hate scrolling through HB_GRANULAR_LOG = 3 // sample-by-sample } hb_debug_level_t; -void hb_deep_log( hb_debug_level_t level, char * log, ... ); -void hb_error( char * fmt, ...); +void hb_deep_log( hb_debug_level_t level, char * log, ... ) HB_WPRINTF(2,3); +void hb_error( char * fmt, ...) HB_WPRINTF(1,2); int hb_list_bytes( hb_list_t * ); void hb_list_seebytes( hb_list_t * l, uint8_t * dst, int size ); diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index da390c500..4c2c68009 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -355,8 +355,7 @@ finished: { /* Video */ hb_deep_log( 2, "mux: video bitrate error, %+lld bytes", - track->bytes - mux->pts * job->vbitrate * - 125 / 90000 ); + (int64_t)(track->bytes - mux->pts * job->vbitrate * 125 / 90000) ); } bytes_total += track->bytes; frames_total += track->frames; diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c index 26aff207a..aee157d18 100644 --- a/libhb/platform/macosx/encca_aac.c +++ b/libhb/platform/macosx/encca_aac.c @@ -130,7 +130,7 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job ) err = AudioConverterNew( &input, &output, &pv->converter ); if( err != noErr) { - hb_log( "Error creating an AudioConverter %x %d", err, output.mBytesPerFrame ); + hb_log( "Error creating an AudioConverter err=%"PRId64" %"PRIu64, (int64_t)err, (uint64_t)output.mBytesPerFrame ); *job->die = 1; return 0; } diff --git a/libhb/ports.c b/libhb/ports.c index 2e6b65329..40183015f 100644 --- a/libhb/ports.c +++ b/libhb/ports.c @@ -54,6 +54,8 @@ #include <netinet/in.h> #endif +#include <stddef.h> + #include "hb.h" /************************************************************************ @@ -261,6 +263,25 @@ struct hb_thread_s #endif }; +/* Get a unique identifier to thread and represent as 64-bit unsigned. + * If unsupported, the value 0 is be returned. + * Caller should use result only for display/log purposes. + */ +static uint64_t hb_thread_to_integer( const hb_thread_t* t ) +{ +#if defined( USE_PTHREAD ) + #if defined( _WIN32 ) || defined( __MINGW32__ ) + return (uint64_t)(ptrdiff_t)t->thread.p; + #elif defined( SYS_DARWIN ) + return (uint64_t)(ptrdiff_t)t->thread; + #else + return (uint64_t)t->thread; + #endif +#else + return 0; +#endif +} + /************************************************************************ * hb_thread_func() ************************************************************************ @@ -291,7 +312,7 @@ static void hb_thread_func( void * _t ) t->function( t->arg ); /* Inform that the thread can be joined now */ - hb_deep_log( 2, "thread %x exited (\"%s\")", t->thread, t->name ); + hb_deep_log( 2, "thread %"PRIx64" exited (\"%s\")", hb_thread_to_integer( t ), t->name ); hb_lock( t->lock ); t->exited = 1; hb_unlock( t->lock ); @@ -336,7 +357,7 @@ hb_thread_t * hb_thread_init( char * name, void (* function)(void *), // SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL ); #endif - hb_deep_log( 2, "thread %x started (\"%s\")", t->thread, t->name ); + hb_deep_log( 2, "thread %"PRIx64" started (\"%s\")", hb_thread_to_integer( t ), t->name ); return t; } @@ -361,8 +382,7 @@ void hb_thread_close( hb_thread_t ** _t ) // WaitForSingleObject( t->thread, INFINITE ); #endif - hb_deep_log( 2, "thread %x joined (\"%s\")", - t->thread, t->name ); + hb_deep_log( 2, "thread %"PRIx64" joined (\"%s\")", hb_thread_to_integer( t ), t->name ); hb_lock_close( &t->lock ); free( t->name ); |