Browse code

ffmpeg: notify when the thread message queue blocks.

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

Nicolas George authored on 2015/02/17 05:53:27
Showing 1 changed files
... ...
@@ -3356,6 +3356,7 @@ static int check_keyboard_interaction(int64_t cur_time)
3356 3356
 static void *input_thread(void *arg)
3357 3357
 {
3358 3358
     InputFile *f = arg;
3359
+    unsigned flags = f->non_blocking ? AV_THREAD_MESSAGE_NONBLOCK : 0;
3359 3360
     int ret = 0;
3360 3361
 
3361 3362
     while (1) {
... ...
@@ -3371,7 +3372,15 @@ static void *input_thread(void *arg)
3371 3371
             break;
3372 3372
         }
3373 3373
         av_dup_packet(&pkt);
3374
-        ret = av_thread_message_queue_send(f->in_thread_queue, &pkt, 0);
3374
+        ret = av_thread_message_queue_send(f->in_thread_queue, &pkt, flags);
3375
+        if (flags && ret == AVERROR(EAGAIN)) {
3376
+            flags = 0;
3377
+            ret = av_thread_message_queue_send(f->in_thread_queue, &pkt, flags);
3378
+            av_log(f->ctx, AV_LOG_WARNING,
3379
+                   "Thread message queue blocking; consider raising the "
3380
+                   "thread_queue_size option (current value: %d)\n",
3381
+                   f->thread_queue_size);
3382
+        }
3375 3383
         if (ret < 0) {
3376 3384
             if (ret != AVERROR_EOF)
3377 3385
                 av_log(f->ctx, AV_LOG_ERROR,