Compilation warning fixes and various cosmetic buffs on the code
>From 6c33b60f8a046e6b05b16dd3637797d201aaf6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Eldst=C3=A5l-Damlin?= <laeder.k...@gmail.com> Date: Mon, 14 Dec 2009 13:45:59 +0100 Subject: [PATCH] Compilation warning fixes
--- src/filter/chain_filter_plugin.c | 3 +- src/filter/route_filter_plugin.c | 80 ++++++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/src/filter/chain_filter_plugin.c b/src/filter/chain_filter_plugin.c index ce88457..df220be 100644 --- a/src/filter/chain_filter_plugin.c +++ b/src/filter/chain_filter_plugin.c @@ -226,11 +226,12 @@ filter_chain_parse(struct filter *chain, const char *spec) { const char *plugin_name; const struct filter_plugin *fp; struct filter *f; + const struct config_param *cfg; // Squeeze whitespace g_strstrip(*template_names); - const struct config_param *cfg = filter_plugin_config(*template_names); + cfg = filter_plugin_config(*template_names); if (cfg == NULL) { g_error("Unable to locate filter template %s", *template_names); diff --git a/src/filter/route_filter_plugin.c b/src/filter/route_filter_plugin.c index 8c51274..a681dd2 100644 --- a/src/filter/route_filter_plugin.c +++ b/src/filter/route_filter_plugin.c @@ -120,9 +120,9 @@ struct route_filter { * where a... are non-unique, non-negative integers * and input channel a gets copied to output channel b, etc. * @param param the configuration block to read - * @param filter a route_filter whose min_channels and sources[] values to allocate and set up + * @param filter a route_filter whose min_channels and sources[] to set */ -void +static void route_filter_parse(const struct config_param *param, struct route_filter *filter) { /* TODO: @@ -135,7 +135,8 @@ route_filter_parse(const struct config_param *param, struct route_filter *filter int number_of_copies; // A cowardly default, just passthrough stereo - const char *routes = config_get_block_string(param, "routes", "0>0, 1>1"); + const char *routes = + config_get_block_string(param, "routes", "0>0, 1>1"); filter->min_input_channels = 0; filter->min_output_channels = 0; @@ -145,15 +146,18 @@ route_filter_parse(const struct config_param *param, struct route_filter *filter // Start by figuring out a few basic things about the routing set for (int c=0; c<number_of_copies; ++c) { + + // String and int representations of the source/destination + gchar **sd; int source, dest; // Squeeze whitespace g_strstrip(tokens[c]); // Split the a>b string into source and destination - gchar **sd = g_strsplit(tokens[c], ">", 2); + sd = g_strsplit(tokens[c], ">", 2); if (g_strv_length(sd) != 2) { - g_error("Invalid copy operation around line %d in routes spec: %s", + g_error("Invalid copy around %d in routes spec: %s", param->line, tokens[c]); continue; } @@ -161,26 +165,35 @@ route_filter_parse(const struct config_param *param, struct route_filter *filter source = strtol(sd[0], NULL, 10); dest = strtol(sd[1], NULL, 10); - // Keep track of the highest channel numbers seen as either in- or outputs - if (source >= filter->min_input_channels) filter->min_input_channels = source + 1; - if (dest >= filter->min_output_channels) filter->min_output_channels = dest + 1; + // Keep track of the highest channel numbers seen + // as either in- or outputs + if (source >= filter->min_input_channels) + filter->min_input_channels = source + 1; + if (dest >= filter->min_output_channels) + filter->min_output_channels = dest + 1; g_strfreev(sd); } // Allocate a map of "copy nothing to me" - filter->sources = g_malloc(filter->min_output_channels * sizeof(signed char)); + filter->sources = + g_malloc(filter->min_output_channels * sizeof(signed char)); + for (int i=0; i<filter->min_output_channels; ++i) filter->sources[i] = -1; - // Run through the spec again, and save the actual mapping output <- input + // Run through the spec again, and save the + // actual mapping output <- input for (int c=0; c<number_of_copies; ++c) { + + // String and int representations of the source/destination + gchar **sd; int source, dest; // Split the a>b string into source and destination - gchar **sd = g_strsplit(tokens[c], ">", 2); + sd = g_strsplit(tokens[c], ">", 2); if (g_strv_length(sd) != 2) { - g_error("Invalid copy operation around line %d in routes spec: %s", + g_error("Invalid copy around %d in routes spec: %s", param->line, tokens[c]); continue; } @@ -227,14 +240,19 @@ route_filter_open(struct filter *_filter, // Copy the input format for later reference filter->input_format = *audio_format; - filter->input_sample_size = audio_format_sample_size(&filter->input_format) * filter->input_format.channels; + filter->input_sample_size = + audio_format_sample_size(&filter->input_format) * + filter->input_format.channels; - // Decide on an output format which has enough channels, and is otherwise identical + // Decide on an output format which has enough channels, + // and is otherwise identical filter->output_format = *audio_format; filter->output_format.channels = filter->min_output_channels; // Precalculate this simple value, to speed up allocation later - filter->output_sample_size = audio_format_sample_size(&filter->output_format) * filter->output_format.channels; + filter->output_sample_size = + audio_format_sample_size(&filter->output_format) * + filter->output_format.channels; // This buffer grows as needed filter->output_buffer_size = filter->output_sample_size; @@ -261,19 +279,23 @@ route_filter_filter(struct filter *_filter, size_t number_of_samples = src_size / filter->input_sample_size; - size_t bytes_per_sample_per_channel = audio_format_sample_size(&filter->input_format); + size_t bytes_per_sample_per_channel = + audio_format_sample_size(&filter->input_format); // A moving pointer that always refers to channel 0 in the input, at the currently handled sample - const void *base_source = src; + const uint8_t *base_source = src; // A moving pointer that always refers to the currently filled channel of the currently handled sample, in the output - void *chan_destination; + uint8_t *chan_destination; // Grow our reusable buffer, if needed *dest_size_r = number_of_samples * filter->output_sample_size; if (*dest_size_r > filter->output_buffer_size) { filter->output_buffer_size = *dest_size_r; - filter->output_buffer = g_realloc(filter->output_buffer, filter->output_buffer_size); + + filter->output_buffer = + g_realloc(filter->output_buffer, + filter->output_buffer_size); } // A moving pointer that always refers to the currently filled channel of the currently handled sample, in the output @@ -284,13 +306,21 @@ route_filter_filter(struct filter *_filter, // Need to perform one copy per output channel for (unsigned int c=0; c<filter->min_output_channels; ++c) { - if (filter->sources[c] == -1 || filter->sources[c] >= filter->input_format.channels) { - // No source for this destination output, give it zeroes as input - memset(chan_destination, 0x00, bytes_per_sample_per_channel); + if (filter->sources[c] == -1 || + filter->sources[c] >= filter->input_format.channels) { + // No source for this destination output, + // give it zeroes as input + memset(chan_destination, + 0x00, + bytes_per_sample_per_channel); } else { - // Get the data from channel sources[c] and copy it to the output - const void *data = base_source + (filter->sources[c] * bytes_per_sample_per_channel); - g_memmove(chan_destination, data, bytes_per_sample_per_channel); + // Get the data from channel sources[c] + // and copy it to the output + const uint8_t *data = base_source + + (filter->sources[c] * bytes_per_sample_per_channel); + g_memmove(chan_destination, + data, + bytes_per_sample_per_channel); } // Move on to the next output channel chan_destination += bytes_per_sample_per_channel; -- 1.6.4.4
------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev
_______________________________________________ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team