From 96f71680f1b9988a473261520db062d53f34bb08 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Thu, 4 Jun 2026 03:28:33 -0400 Subject: [PATCH] Fix #2276 --- av/logging.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/av/logging.py b/av/logging.py index 2b565b9e8..295779444 100644 --- a/av/logging.py +++ b/av/logging.py @@ -81,6 +81,7 @@ def adapt_level(level: cython.int): level_threshold = cython.declare(object, None) +c_level_threshold = cython.declare(cython.int, lib.AV_LOG_QUIET) # ... but lets limit ourselves to WARNING (assuming nobody already did this). if "libav" not in logging.Logger.manager.loggerDict: @@ -107,12 +108,14 @@ def set_level(level): When developing your application. """ global level_threshold + global c_level_threshold if level is None: level_threshold = level lib.av_log_set_callback(nolog_callback) elif type(level) is int: level_threshold = level + c_level_threshold = level lib.av_log_set_callback(log_callback) else: raise ValueError("level must be: int | None") @@ -331,10 +334,8 @@ def log_callback( inited: cython.bint = Py_IsInitialized() if not inited: return - - with cython.gil: - if level > level_threshold and level != lib.AV_LOG_ERROR: - return + if level > c_level_threshold and level != lib.AV_LOG_ERROR: + return # Format the message. message: cython.char[1024]