aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio_parser.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-21 23:01:04 +0200
committerMax Kellermann <max@duempel.org>2009-10-21 23:01:04 +0200
commit9526fdbe730edb4b095a1e12aade0e16f1da2292 (patch)
tree4544e77bf35e08a12d2b019e0bf3942754b85b96 /src/audio_parser.c
parenta5c4566fa1551953b84882a1fa53400c7bd6551c (diff)
downloadmpd-9526fdbe730edb4b095a1e12aade0e16f1da2292.tar.gz
mpd-9526fdbe730edb4b095a1e12aade0e16f1da2292.tar.xz
mpd-9526fdbe730edb4b095a1e12aade0e16f1da2292.zip
audio_format: wildcards allowed in audio_format configuration
An asterisk means that this attribute should not be enforced, and stays whatever it used to be. This way, some configuration values work like masks.
Diffstat (limited to 'src/audio_parser.c')
-rw-r--r--src/audio_parser.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/audio_parser.c b/src/audio_parser.c
index 0b3474ab3..7c0d45ddc 100644
--- a/src/audio_parser.c
+++ b/src/audio_parser.c
@@ -37,12 +37,18 @@ audio_parser_quark(void)
}
static bool
-parse_sample_rate(const char *src, uint32_t *sample_rate_r,
+parse_sample_rate(const char *src, bool mask, uint32_t *sample_rate_r,
const char **endptr_r, GError **error_r)
{
unsigned long value;
char *endptr;
+ if (mask && *src == '*') {
+ *sample_rate_r = 0;
+ *endptr_r = src + 1;
+ return true;
+ }
+
value = strtoul(src, &endptr, 10);
if (endptr == src) {
g_set_error(error_r, audio_parser_quark(), 0,
@@ -60,12 +66,18 @@ parse_sample_rate(const char *src, uint32_t *sample_rate_r,
}
static bool
-parse_sample_format(const char *src, uint8_t *bits_r,
+parse_sample_format(const char *src, bool mask, uint8_t *bits_r,
const char **endptr_r, GError **error_r)
{
unsigned long value;
char *endptr;
+ if (mask && *src == '*') {
+ *bits_r = 0;
+ *endptr_r = src + 1;
+ return true;
+ }
+
value = strtoul(src, &endptr, 10);
if (endptr == src) {
g_set_error(error_r, audio_parser_quark(), 0,
@@ -83,12 +95,18 @@ parse_sample_format(const char *src, uint8_t *bits_r,
}
static bool
-parse_channel_count(const char *src, uint8_t *channels_r,
+parse_channel_count(const char *src, bool mask, uint8_t *channels_r,
const char **endptr_r, GError **error_r)
{
unsigned long value;
char *endptr;
+ if (mask && *src == '*') {
+ *channels_r = 0;
+ *endptr_r = src + 1;
+ return true;
+ }
+
value = strtoul(src, &endptr, 10);
if (endptr == src) {
g_set_error(error_r, audio_parser_quark(), 0,
@@ -107,7 +125,7 @@ parse_channel_count(const char *src, uint8_t *channels_r,
bool
audio_format_parse(struct audio_format *dest, const char *src,
- GError **error_r)
+ bool mask, GError **error_r)
{
uint32_t rate;
uint8_t bits, channels;
@@ -116,7 +134,7 @@ audio_format_parse(struct audio_format *dest, const char *src,
/* parse sample rate */
- if (!parse_sample_rate(src, &rate, &src, error_r))
+ if (!parse_sample_rate(src, mask, &rate, &src, error_r))
return false;
if (*src++ != ':') {
@@ -127,7 +145,7 @@ audio_format_parse(struct audio_format *dest, const char *src,
/* parse sample format */
- if (!parse_sample_format(src, &bits, &src, error_r))
+ if (!parse_sample_format(src, mask, &bits, &src, error_r))
return false;
if (*src++ != ':') {
@@ -138,7 +156,7 @@ audio_format_parse(struct audio_format *dest, const char *src,
/* parse channel count */
- if (!parse_channel_count(src, &channels, &src, error_r))
+ if (!parse_channel_count(src, mask, &channels, &src, error_r))
return false;
if (*src != 0) {