diff options
author | Max Kellermann <max@duempel.org> | 2009-02-11 18:00:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-11 18:00:48 +0100 |
commit | 3bc4224bfda5ebf9cd6969ea0f6647b1af3e9da6 (patch) | |
tree | 8c52ad4a6fc9a95033d40536a96291161130f556 /src/audio_parser.c | |
parent | 5090cf6484f5e7464aeba54d19500cc334a80fad (diff) | |
download | mpd-3bc4224bfda5ebf9cd6969ea0f6647b1af3e9da6.tar.gz mpd-3bc4224bfda5ebf9cd6969ea0f6647b1af3e9da6.tar.xz mpd-3bc4224bfda5ebf9cd6969ea0f6647b1af3e9da6.zip |
audio_format: added validation functions
In addition to audio_format_valid(), provide functions which validate
only one attribute of an audio_format. These functions are reused by
audio_format_parse().
Diffstat (limited to '')
-rw-r--r-- | src/audio_parser.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/audio_parser.c b/src/audio_parser.c index 807a279b3..ee43fd24e 100644 --- a/src/audio_parser.c +++ b/src/audio_parser.c @@ -54,7 +54,7 @@ audio_format_parse(struct audio_format *dest, const char *src, GError **error) g_set_error(error, audio_parser_quark(), 0, "Sample format missing"); return false; - } else if (value <= 0 || value > G_MAXINT32) { + } else if (!audio_valid_sample_rate(value)) { g_set_error(error, audio_parser_quark(), 0, "Invalid sample rate: %lu", value); return false; @@ -74,7 +74,7 @@ audio_format_parse(struct audio_format *dest, const char *src, GError **error) g_set_error(error, audio_parser_quark(), 0, "Channel count missing"); return false; - } else if (value != 16 && value != 24 && value != 8) { + } else if (!audio_valid_sample_format(value)) { g_set_error(error, audio_parser_quark(), 0, "Invalid sample format: %lu", value); return false; @@ -86,7 +86,7 @@ audio_format_parse(struct audio_format *dest, const char *src, GError **error) src = endptr + 1; value = strtoul(src, &endptr, 10); - if (*endptr != 0 || (value != 1 && value != 2)) { + if (*endptr != 0 || !audio_valid_channel_count(value)) { g_set_error(error, audio_parser_quark(), 0, "Invalid channel count: %s", src); return false; |