[FFmpeg-devel] [PATCH 11/13] doc/examples: removing polling from filtering examples.

Clément Bœsch ubitux at gmail.com
Sat May 12 23:15:33 CEST 2012


FIXME: untested for audio since audio filtering is broken at the moment.
---
 doc/examples/filtering_audio.c |   14 ++++++++------
 doc/examples/filtering_video.c |   14 ++++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c
index e8e6259..d03b1b3 100644
--- a/doc/examples/filtering_audio.c
+++ b/doc/examples/filtering_audio.c
@@ -210,13 +210,15 @@ int main(int argc, char **argv)
                 }
 
                 /* pull filtered audio from the filtergraph */
-                while (avfilter_poll_frame(buffersink_ctx->inputs[0])) {
-                    av_buffersink_get_buffer_ref(buffersink_ctx, &samplesref, 0);
-                    if (samplesref) {
-                        print_samplesref(samplesref);
-                        avfilter_unref_buffer(samplesref);
+                do {
+                    ret = av_buffersink_get_buffer_ref(buffersink_ctx, &samplesref, 0);
+                    if (ret < 0 && ret != AVERROR(EAGAIN)) {
+                        av_log(NULL, AV_LOG_ERROR, "Error while getting buffer ref\n");
+                        break;
                     }
-                }
+                    print_samplesref(samplesref);
+                    avfilter_unref_buffer(samplesref);
+                } while (ret == AVERROR(EAGAIN));
             }
         }
     }
diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
index 2ca6a05..d8f466f 100644
--- a/doc/examples/filtering_video.c
+++ b/doc/examples/filtering_video.c
@@ -205,13 +205,15 @@ int main(int argc, char **argv)
                 av_vsrc_buffer_add_frame(buffersrc_ctx, &frame, 0);
 
                 /* pull filtered pictures from the filtergraph */
-                while (avfilter_poll_frame(buffersink_ctx->inputs[0])) {
-                    av_buffersink_get_buffer_ref(buffersink_ctx, &picref, 0);
-                    if (picref) {
-                        display_picref(picref, buffersink_ctx->inputs[0]->time_base);
-                        avfilter_unref_buffer(picref);
+                do {
+                    ret = av_buffersink_get_buffer_ref(buffersink_ctx, &picref, 0);
+                    if (ret < 0 && ret != AVERROR(EAGAIN)) {
+                        av_log(NULL, AV_LOG_ERROR, "Error while getting buffer ref\n");
+                        break;
                     }
-                }
+                    display_picref(picref, buffersink_ctx->inputs[0]->time_base);
+                    avfilter_unref_buffer(picref);
+                } while (ret == AVERROR(EAGAIN));
             }
         }
     }
-- 
1.7.10.1



More information about the ffmpeg-devel mailing list