Browse code

sink_buffer: warn when there are too many buffers.

Nicolas George authored on 2012/06/28 18:21:42
Showing 1 changed files
... ...
@@ -56,6 +56,7 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void)
56 56
 
57 57
 typedef struct {
58 58
     AVFifoBuffer *fifo;                      ///< FIFO buffer of video frame references
59
+    unsigned warning_limit;
59 60
 
60 61
     /* only used for video */
61 62
     enum PixelFormat *pixel_fmts;           ///< list of accepted pixel formats, must be terminated with -1
... ...
@@ -76,6 +77,7 @@ static av_cold int common_init(AVFilterContext *ctx)
76 76
         av_log(ctx, AV_LOG_ERROR, "Failed to allocate fifo\n");
77 77
         return AVERROR(ENOMEM);
78 78
     }
79
+    buf->warning_limit = 100;
79 80
     return 0;
80 81
 }
81 82
 
... ...
@@ -113,6 +115,14 @@ static void end_frame(AVFilterLink *inlink)
113 113
     /* cache frame */
114 114
     av_fifo_generic_write(buf->fifo,
115 115
                           &inlink->cur_buf, sizeof(AVFilterBufferRef *), NULL);
116
+    if (buf->warning_limit &&
117
+        av_fifo_size(buf->fifo) / sizeof(AVFilterBufferRef *) >= buf->warning_limit) {
118
+        av_log(ctx, AV_LOG_WARNING,
119
+               "%d buffers queued in %s, something may be wrong.\n",
120
+               buf->warning_limit,
121
+               (char *)av_x_if_null(ctx->name, ctx->filter->name));
122
+        buf->warning_limit *= 10;
123
+    }
116 124
 }
117 125
 
118 126
 int av_buffersink_get_buffer_ref(AVFilterContext *ctx,