[FFmpeg-devel] [PATCH 2/3] ffmpeg: notify when the thread message queue blocks.

Nicolas George george at nsup.org
Mon Feb 16 22:22:16 CET 2015


This can help finding the source of A-V desync with live input.

Signed-off-by: Nicolas George <george at nsup.org>
---
 ffmpeg.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index becd5df..a52de20 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3356,6 +3356,7 @@ static int check_keyboard_interaction(int64_t cur_time)
 static void *input_thread(void *arg)
 {
     InputFile *f = arg;
+    unsigned flags = f->non_blocking ? AV_THREAD_MESSAGE_NONBLOCK : 0;
     int ret = 0;
 
     while (1) {
@@ -3371,7 +3372,12 @@ static void *input_thread(void *arg)
             break;
         }
         av_dup_packet(&pkt);
-        ret = av_thread_message_queue_send(f->in_thread_queue, &pkt, 0);
+        ret = av_thread_message_queue_send(f->in_thread_queue, &pkt, flags);
+        if (flags && ret == AVERROR(EAGAIN)) {
+            flags = 0;
+            ret = av_thread_message_queue_send(f->in_thread_queue, &pkt, flags);
+            av_log(f->ctx, AV_LOG_WARNING, "Thread message queue blocking\n");
+        }
         if (ret < 0) {
             if (ret != AVERROR_EOF)
                 av_log(f->ctx, AV_LOG_ERROR,
-- 
2.1.4



More information about the ffmpeg-devel mailing list