* logging routines. * these frontend hb_log because transport streams can have a lot of errors * so we want to rate limit messages. this routine limits the number of * messages to at most one per minute of video. other errors that occur * during the minute are counted & the count is output with the next * error msg we print. */
| 301 | * error msg we print. |
| 302 | */ |
| 303 | static void ts_warn_helper( hb_stream_t *stream, char *log, va_list args ) |
| 304 | { |
| 305 | // limit error printing to at most one per minute of video (at 30fps) |
| 306 | ++stream->errors; |
| 307 | if ( stream->frames - stream->last_error_frame >= 30*60 ) |
| 308 | { |
| 309 | char msg[256]; |
| 310 | |
| 311 | vsnprintf( msg, sizeof(msg), log, args ); |
| 312 | |
| 313 | if ( stream->errors - stream->last_error_count < 10 ) |
| 314 | { |
| 315 | hb_log( "stream: error near frame %d: %s", stream->frames, msg ); |
| 316 | } |
| 317 | else |
| 318 | { |
| 319 | int Edelta = stream->errors - stream->last_error_count; |
| 320 | double Epcnt = (double)Edelta * 100. / |
| 321 | (stream->frames - stream->last_error_frame); |
| 322 | hb_log( "stream: %d new errors (%.0f%%) up to frame %d: %s", |
| 323 | Edelta, Epcnt, stream->frames, msg ); |
| 324 | } |
| 325 | stream->last_error_frame = stream->frames; |
| 326 | stream->last_error_count = stream->errors; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | static void ts_warn( hb_stream_t*, char*, ... ) HB_WPRINTF(2,3); |
| 331 | static void ts_err( hb_stream_t*, int, char*, ... ) HB_WPRINTF(3,4); |