0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

af: verify filter input formats

Just to make sure all filters get the correct format. Together wih the
check in af_add_output_frame(), this asserts that

    af->prev->fmt_out == af->fmt_in

This also requires setting the "in" pseudo-filter (s->first) formats
correctly. Before this commit, the fmt_in/fmt_out fields weren't used
for this filter.
This commit is contained in:
wm4 2015-01-15 20:10:46 +01:00
parent 66c8a87485
commit ba0e8b754c

View File

@ -513,6 +513,7 @@ static int af_reinit(struct af_stream *s)
{
remove_auto_inserted_filters(s);
af_chain_forget_frames(s);
s->first->fmt_in = s->first->fmt_out = s->input;
// Start with the second filter, as the first filter is the special input
// filter which needs no initialization.
struct af_instance *af = s->first->next;
@ -774,7 +775,7 @@ void af_control_all(struct af_stream *s, int cmd, void *arg)
void af_add_output_frame(struct af_instance *af, struct mp_audio *frame)
{
if (frame) {
assert(mp_audio_config_equals(af->data, frame));
assert(mp_audio_config_equals(&af->fmt_out, frame));
MP_TARRAY_APPEND(af, af->out_queued, af->num_out_queued, frame);
}
}
@ -800,6 +801,8 @@ static struct mp_audio *af_dequeue_output_frame(struct af_instance *af)
static int af_do_filter(struct af_instance *af, struct mp_audio *frame)
{
if (frame)
assert(mp_audio_config_equals(&af->fmt_in, frame));
int r = 0;
if (af->filter_frame) {
r = af->filter_frame(af, frame);