From f47bb8c1db91b50be95c4d5dd301728e38c57274 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Nov 2009 19:00:41 +0100 Subject: audio_check: checker functions for audio_format attributes These functions are a wrapper for audio_valid_X(). On error, they return a GError object. --- src/audio_parser.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/audio_parser.c') diff --git a/src/audio_parser.c b/src/audio_parser.c index 5795c35dd..df87be325 100644 --- a/src/audio_parser.c +++ b/src/audio_parser.c @@ -25,6 +25,7 @@ #include "config.h" #include "audio_parser.h" #include "audio_format.h" +#include "audio_check.h" #include @@ -55,11 +56,8 @@ parse_sample_rate(const char *src, bool mask, uint32_t *sample_rate_r, g_set_error(error_r, audio_parser_quark(), 0, "Failed to parse the sample rate"); return false; - } else if (!audio_valid_sample_rate(value)) { - g_set_error(error_r, audio_parser_quark(), 0, - "Invalid sample rate: %lu", value); + } else if (!audio_check_sample_rate(value, error_r)) return false; - } *sample_rate_r = value; *endptr_r = endptr; @@ -84,11 +82,8 @@ parse_sample_format(const char *src, bool mask, uint8_t *bits_r, g_set_error(error_r, audio_parser_quark(), 0, "Failed to parse the sample format"); return false; - } else if (!audio_valid_sample_format(value)) { - g_set_error(error_r, audio_parser_quark(), 0, - "Invalid sample format: %lu", value); + } else if (!audio_check_sample_format(value, error_r)) return false; - } *bits_r = value; *endptr_r = endptr; @@ -113,11 +108,8 @@ parse_channel_count(const char *src, bool mask, uint8_t *channels_r, g_set_error(error_r, audio_parser_quark(), 0, "Failed to parse the channel count"); return false; - } else if (!audio_valid_channel_count(value)) { - g_set_error(error_r, audio_parser_quark(), 0, - "Invalid channel count: %lu", value); + } else if (!audio_check_channel_count(value, error_r)) return false; - } *channels_r = value; *endptr_r = endptr; -- cgit v1.2.3