From 2eac58eaa97ec667a2512cd27c35f006a22ec074 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Jul 2016 18:39:50 +0200 Subject: audio: cleanup audio filter format negotiation The algorithm and functionality is the same, but the code becomes much simpler and easier to follow. The assumption that there is only 1 conversion filter (lavrresample) helps with the simplification, but the main change is to use the same code for format/channels/rate. Get rid of the different AF_CONTROL_SET_* controls, and change the af->data parameters directly. (af->data is badly named, but essentially is a placeholder for the output format.) Also, instead of trying to use the af_reinit() loop to init inserted conversion filters or filters with changed output formats, do it inline, and move the common code to a filter_reinit() function. This gets rid of the awful retry variable. In general, this should not change any runtime behavior. --- audio/filter/af_lavrresample.c | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'audio/filter/af_lavrresample.c') diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 6fbb445563..fdef69a16b 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -173,12 +173,6 @@ static int check_output_conversion(int mp_format) return af_to_avformat(mp_format); } -bool af_lavrresample_test_conversion(int src_format, int dst_format) -{ - return af_to_avformat(src_format) != AV_SAMPLE_FMT_NONE && - check_output_conversion(dst_format) != AV_SAMPLE_FMT_NONE; -} - static struct mp_chmap fudge_pairs[][2] = { {MP_CHMAP2(BL, BR), MP_CHMAP2(SL, SR)}, {MP_CHMAP2(SL, SR), MP_CHMAP2(BL, BR)}, @@ -407,21 +401,6 @@ static int control(struct af_instance *af, int cmd, void *arg) r = configure_lavrr(af, in, out, true); return r; } - case AF_CONTROL_SET_FORMAT: { - int format = *(int *)arg; - if (format && check_output_conversion(format) == AV_SAMPLE_FMT_NONE) - return AF_FALSE; - - mp_audio_set_format(af->data, format); - return AF_OK; - } - case AF_CONTROL_SET_CHANNELS: { - mp_audio_set_channels(af->data, (struct mp_chmap *)arg); - return AF_OK; - } - case AF_CONTROL_SET_RESAMPLE_RATE: - af->data->rate = *(int *)arg; - return AF_OK; case AF_CONTROL_SET_PLAYBACK_SPEED_RESAMPLE: { s->playback_speed = *(double *)arg; return AF_OK; -- cgit v1.2.3