[libav-commits] lavfi: amix: check active input count before calling request_samples

Justin Ruggles git at libav.org
Wed May 30 22:21:34 CEST 2012


Module: libav
Branch: master
Commit: c7bd556d482b3bb25bb6dd3bdf3542622d7cd482

Author:    Justin Ruggles <justin.ruggles at gmail.com>
Committer: Justin Ruggles <justin.ruggles at gmail.com>
Date:      Wed May 30 08:48:26 2012 -0400

lavfi: amix: check active input count before calling request_samples

fixes use of the amix filter with only 1 input

---

 libavfilter/af_amix.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 3399b7c..d4af9a4 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -389,6 +389,10 @@ static int request_frame(AVFilterLink *outlink)
     int ret;
     int wanted_samples, available_samples;
 
+    ret = calc_active_inputs(s);
+    if (ret < 0)
+        return ret;
+
     if (s->input_state[0] == INPUT_OFF) {
         ret = request_samples(ctx, 1);
         if (ret < 0)
@@ -419,15 +423,16 @@ static int request_frame(AVFilterLink *outlink)
     av_assert0(s->frame_list->nb_frames > 0);
 
     wanted_samples = frame_list_next_frame_size(s->frame_list);
-    ret = request_samples(ctx, wanted_samples);
-    if (ret < 0)
-        return ret;
-
-    ret = calc_active_inputs(s);
-    if (ret < 0)
-        return ret;
 
     if (s->active_inputs > 1) {
+        ret = request_samples(ctx, wanted_samples);
+        if (ret < 0)
+            return ret;
+
+        ret = calc_active_inputs(s);
+        if (ret < 0)
+            return ret;
+
         available_samples = get_available_samples(s);
         if (!available_samples)
             return 0;



More information about the libav-commits mailing list