summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-08-02 21:18:36 +0200
committerMax Kellermann <max@musicpd.org>2018-08-02 21:18:36 +0200
commitb39bc85e60191bbcac2991d6a7ab461a194d04c6 (patch)
treed735207e0b1507ac9d8c5361d6f47fa0ec33c18f /src
parent603ce87ac27ac766601d8d9398d466101bee2bb0 (diff)
AudioFormat: add mask support to ToString()
Diffstat (limited to 'src')
-rw-r--r--src/AudioFormat.cxx19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/AudioFormat.cxx b/src/AudioFormat.cxx
index c4c654357..4a7c16874 100644
--- a/src/AudioFormat.cxx
+++ b/src/AudioFormat.cxx
@@ -53,12 +53,23 @@ ToString(const AudioFormat af) noexcept
sample rate */
p += sprintf(p, "dsd%u:", af.sample_rate * 8 / 44100);
} else {
- p += sprintf(p, "%u:%s:",
- af.sample_rate,
- sample_format_to_string(af.format));
+ const char *sample_format = af.format != SampleFormat::UNDEFINED
+ ? sample_format_to_string(af.format)
+ : "*";
+
+ if (af.sample_rate > 0)
+ p += sprintf(p, "%u:%s:", af.sample_rate,
+ sample_format);
+ else
+ p += sprintf(p, "*:%s:", sample_format);
}
- p += sprintf(p, "%u", af.channels);
+ if (af.channels > 0)
+ p += sprintf(p, "%u", af.channels);
+ else {
+ *p++ = '*';
+ *p = 0;
+ }
return buffer;
}