summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-11 13:15:37 +0100
committerwm4 <wm4@nowhere>2015-02-11 16:31:35 +0100
commit8c055f873f9ec66842c08e157a943ce2c5301f55 (patch)
treec571cea6b38f9a06588ee88e462c04a5c7dcdaac
parentcf881396b5566f678c09adf8b5c8c9a4c8003c40 (diff)
downloadmpv-8c055f873f9ec66842c08e157a943ce2c5301f55.tar.bz2
mpv-8c055f873f9ec66842c08e157a943ce2c5301f55.tar.xz
af_rubberband: improve EOF handling
In theory it could happen that draining on EOF happens incrementally, and then the unconditional reset could have dropped the remaining buffered audio.
-rw-r--r--audio/filter/af_rubberband.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/audio/filter/af_rubberband.c b/audio/filter/af_rubberband.c
index 551461d326..754fb39c06 100644
--- a/audio/filter/af_rubberband.c
+++ b/audio/filter/af_rubberband.c
@@ -97,22 +97,28 @@ static int filter_out(struct af_instance *af)
{
struct priv *p = af->priv;
- if (p->needs_reset)
- rubberband_reset(p->rubber);
- p->needs_reset = false;
-
while (!rubberband_available(p->rubber)) {
const float *dummy[MP_NUM_CHANNELS] = {0};
const float **in_data = dummy;
size_t in_samples = 0;
if (p->pending) {
if (!p->pending->samples)
- return 0;
+ break;
+
+ // recover from previous EOF
+ if (p->needs_reset)
+ rubberband_reset(p->rubber);
+ p->needs_reset = false;
+
size_t needs = rubberband_get_samples_required(p->rubber);
in_data = (void *)&p->pending->planes;
in_samples = MPMIN(p->pending->samples, needs);
}
+
+ if (p->needs_reset)
+ break; // previous EOF
p->needs_reset = !p->pending; // EOF
+
rubberband_process(p->rubber, in_data, in_samples, p->needs_reset);
if (!p->pending)
break;