From bd29f7e3c880ff58a80aca84d951e1da9df788e7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 25 Dec 2009 14:56:14 +0100 Subject: filter/route: check configured channel count in method init() Detect misconfiguration during MPD startup, not when playback begins. --- src/filter/route_filter_plugin.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/filter/route_filter_plugin.c') diff --git a/src/filter/route_filter_plugin.c b/src/filter/route_filter_plugin.c index a90abe56f..7fef2bc12 100644 --- a/src/filter/route_filter_plugin.c +++ b/src/filter/route_filter_plugin.c @@ -178,6 +178,14 @@ route_filter_parse(const struct config_param *param, g_strfreev(sd); } + if (!audio_valid_channel_count(filter->min_output_channels)) { + g_strfreev(tokens); + g_set_error(error_r, audio_format_quark(), 0, + "Invalid number of output channels requested: %d", + filter->min_output_channels); + return false; + } + // Allocate a map of "copy nothing to me" filter->sources = g_malloc(filter->min_output_channels * sizeof(signed char)); @@ -242,7 +250,7 @@ route_filter_finish(struct filter *_filter) static const struct audio_format * route_filter_open(struct filter *_filter, const struct audio_format *audio_format, - GError **error_r) + G_GNUC_UNUSED GError **error_r) { struct route_filter *filter = (struct route_filter *)_filter; @@ -251,13 +259,6 @@ route_filter_open(struct filter *_filter, filter->input_frame_size = audio_format_frame_size(&filter->input_format); - if (!audio_valid_channel_count(filter->min_output_channels)) { - g_set_error(error_r, audio_format_quark(), 2, - "Invalid number of output channels requested: %d", - filter->min_output_channels); - return NULL; - } - // Decide on an output format which has enough channels, // and is otherwise identical filter->output_format = *audio_format; -- cgit v1.2.3