summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-09-03 15:39:31 +0200
committerwm4 <wm4@nowhere>2020-09-03 15:39:31 +0200
commitd3afe34c09df6850c4038ba8e7888a7a8cabbc90 (patch)
treeb4472c057ccd61e5c42c05366bed35df98765b13 /audio/out
parent4b3500dd1414d8406f77ef3e68d606d3a69f1a5e (diff)
downloadmpv-d3afe34c09df6850c4038ba8e7888a7a8cabbc90.tar.bz2
mpv-d3afe34c09df6850c4038ba8e7888a7a8cabbc90.tar.xz
ao_lavc: slightly simplify filter use
Create a central function which pumps data through the filter. This also might fix bogus use of the filter API on flushing. (The filter is just used for convenience, but I guess the overall result is still simpler.)
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_lavc.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 8a98f0b67a..b49898fc5c 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -59,7 +59,7 @@ struct priv {
bool shutdown;
};
-static void read_frames(struct ao *ao);
+static bool write_frame(struct ao *ao, struct mp_frame frame);
static bool supports_format(const AVCodec *codec, int format)
{
@@ -188,9 +188,8 @@ static void uninit(struct ao *ao)
outpts += encoder_get_offset(ac->enc);
- if (!mp_pin_in_write(ac->fix_frame_size->pins[0], MP_EOF_FRAME))
+ if (!write_frame(ao, MP_EOF_FRAME))
MP_WARN(ao, "could not flush last frame\n");
- read_frames(ao);
encoder_encode(ac->enc, NULL);
}
@@ -230,10 +229,16 @@ static void encode(struct ao *ao, struct mp_aframe *af)
av_frame_free(&frame);
}
-static void read_frames(struct ao *ao)
+static bool write_frame(struct ao *ao, struct mp_frame frame)
{
struct priv *ac = ao->priv;
+ // Can't push in frame if it doesn't want it output one.
+ mp_pin_out_request_data(ac->fix_frame_size->pins[1]);
+
+ if (!mp_pin_in_write(ac->fix_frame_size->pins[0], frame))
+ return false; // shouldn't happen™
+
while (1) {
struct mp_frame fr = mp_pin_out_read(ac->fix_frame_size->pins[1]);
if (!fr.type)
@@ -244,6 +249,8 @@ static void read_frames(struct ao *ao)
encode(ao, af);
mp_frame_unref(&fr);
}
+
+ return true;
}
static bool audio_write(struct ao *ao, void **data, int samples)
@@ -295,14 +302,7 @@ static bool audio_write(struct ao *ao, void **data, int samples)
mp_aframe_set_pts(af, outpts);
- // Can't push in frame if it doesn't want it output one.
- mp_pin_out_request_data(ac->fix_frame_size->pins[1]);
-
- if (!mp_pin_in_write(ac->fix_frame_size->pins[0],
- MAKE_FRAME(MP_FRAME_AUDIO, af)))
- return false; // shouldn't happen™
- read_frames(ao);
- return true;
+ return write_frame(ao, MAKE_FRAME(MP_FRAME_AUDIO, af));
}
static void get_state(struct ao *ao, struct mp_pcm_state *state)