Browse code

buffersrc: warn when there are too many buffers.

Nicolas George authored on 2012/06/28 18:21:18
Showing 1 changed files
... ...
@@ -43,6 +43,7 @@ typedef struct {
43 43
     AVRational        time_base;     ///< time_base to set in the output link
44 44
     AVRational        frame_rate;    ///< frame_rate to set in the output link
45 45
     unsigned          nb_failed_requests;
46
+    unsigned          warning_limit;
46 47
 
47 48
     /* video only */
48 49
     int               w, h;
... ...
@@ -183,6 +184,14 @@ int av_buffersrc_add_ref(AVFilterContext *s, AVFilterBufferRef *buf, int flags)
183 183
         return ret;
184 184
     }
185 185
     c->nb_failed_requests = 0;
186
+    if (c->warning_limit &&
187
+        av_fifo_size(c->fifo) / sizeof(buf) >= c->warning_limit) {
188
+        av_log(s, AV_LOG_WARNING,
189
+               "%d buffers queued in %s, something may be wrong.\n",
190
+               c->warning_limit,
191
+               (char *)av_x_if_null(s->name, s->filter->name));
192
+        c->warning_limit *= 10;
193
+    }
186 194
 
187 195
     return 0;
188 196
 }
... ...
@@ -261,6 +270,7 @@ static av_cold int init_video(AVFilterContext *ctx, const char *args)
261 261
            c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
262 262
            c->time_base.num, c->time_base.den, c->frame_rate.num, c->frame_rate.den,
263 263
            c->pixel_aspect.num, c->pixel_aspect.den, (char *)av_x_if_null(c->sws_param, ""));
264
+    c->warning_limit = 100;
264 265
     return 0;
265 266
 
266 267
 fail:
... ...
@@ -320,6 +330,7 @@ static av_cold int init_audio(AVFilterContext *ctx, const char *args)
320 320
            "tb:%d/%d samplefmt:%s samplerate:%d chlayout:%s\n",
321 321
            s->time_base.num, s->time_base.den, s->sample_fmt_str,
322 322
            s->sample_rate, s->channel_layout_str);
323
+    s->warning_limit = 100;
323 324
 
324 325
 fail:
325 326
     av_opt_free(s);