From 240ee00a9177d6ff80ef48ce577b06d93cb554c2 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 5 Jan 2025 20:42:51 -0500 Subject: Temp fix for stream selection, compile fixes Signed-off-by: Andrew Opalach --- src/codec/ffmpeg/common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/codec/ffmpeg') diff --git a/src/codec/ffmpeg/common.c b/src/codec/ffmpeg/common.c index b2e727d..95bf247 100644 --- a/src/codec/ffmpeg/common.c +++ b/src/codec/ffmpeg/common.c @@ -10,18 +10,20 @@ void camu_ff_set_log_callback(void (*callback)(void *, s32, const char *, va_lis } static char *buf = NULL; -static s32 pos = 0; +static size_t pos = 0; // If a line takes more than 2 steps to print, make sure we stay within AL_LOG_MESSAGE_SIZE. -#define CHUNK_SIZE (AL_LOG_MESSAGE_SIZE / 2) +#define CHUNK_SIZE (AL_LOG_MESSAGE_SIZE / 2u) static void av_log_callback(void *userdata, s32 level, const char *fmt, va_list args) { (void)userdata; al_assert(buf); if (level < AV_LOG_DEBUG) { - pos += al_vsnprintf(&buf[pos], CHUNK_SIZE, fmt, args); - if (buf[pos - 1] == '\n' || pos >= CHUNK_SIZE) { + s32 ret = al_vsnprintf(&buf[pos], CHUNK_SIZE, fmt, args); + al_assert(ret > 0); + pos += ret; + if ((pos > 0 && buf[pos - 1] == '\n') || pos >= CHUNK_SIZE) { if (level <= AV_LOG_INFO) { al_log_info("ff", buf); } else { -- cgit v1.2.3-101-g0448