remove unneeded strlen

This commit is contained in:
Isaac Connor 2021-02-22 20:40:22 -05:00
parent 64c601fc7b
commit 0ac3e6fd5b
1 changed files with 9 additions and 5 deletions

View File

@ -64,11 +64,15 @@ void log_libav_callback(void *ptr, int level, const char *fmt, va_list vargs) {
if ( log ) {
char logString[8192];
vsnprintf(logString, sizeof(logString)-1, fmt, vargs);
int length = strlen(logString);
// ffmpeg logs have a carriage return, so replace it with terminator
logString[length-1] = 0;
log->logPrint(false, __FILE__, __LINE__, log_level, logString);
int length = vsnprintf(logString, sizeof(logString)-1, fmt, vargs);
if ( length > 0 ) {
if ( static_cast<size_t>(length) > sizeof(logString)-1 ) length = sizeof(logString)-1;
// ffmpeg logs have a carriage return, so replace it with terminator
logString[length-1] = 0;
log->logPrint(false, __FILE__, __LINE__, log_level, logString);
} else {
log->logPrint(false, __FILE__, __LINE__, AV_LOG_ERROR, "Can't encode log from av. fmt was %s", fmt);
}
}
}