aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio_format.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-10 17:11:34 +0100
committerMax Kellermann <max@duempel.org>2009-12-02 22:29:50 +0100
commitc412d6251e9cd3abe735b7622af4003502e54f72 (patch)
tree7344c13f62e4cc788c830c05d21bb7b5b47f5866 /src/audio_format.c
parent68c2cfbb4067b2292e1ff1d4e7716ff370903f84 (diff)
downloadmpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.gz
mpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.xz
mpd-c412d6251e9cd3abe735b7622af4003502e54f72.zip
audio_format: changed "bits" to "enum sample_format"
This patch prepares support for floating point samples (and probably other formats). It changes the meaning of the "bits" attribute from a bit count to a symbolic value.
Diffstat (limited to 'src/audio_format.c')
-rw-r--r--src/audio_format.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/audio_format.c b/src/audio_format.c
index f88735c73..33cd90f58 100644
--- a/src/audio_format.c
+++ b/src/audio_format.c
@@ -29,14 +29,39 @@
#endif
const char *
+sample_format_to_string(enum sample_format format)
+{
+ switch (format) {
+ case SAMPLE_FORMAT_UNDEFINED:
+ return "?";
+
+ case SAMPLE_FORMAT_S8:
+ return "8";
+
+ case SAMPLE_FORMAT_S16:
+ return "16";
+
+ case SAMPLE_FORMAT_S24_P32:
+ return "24";
+
+ case SAMPLE_FORMAT_S32:
+ return "32";
+ }
+
+ /* unreachable */
+ assert(false);
+ return "?";
+}
+
+const char *
audio_format_to_string(const struct audio_format *af,
struct audio_format_string *s)
{
assert(af != NULL);
assert(s != NULL);
- snprintf(s->buffer, sizeof(s->buffer), "%u:%u%s:%u",
- af->sample_rate, af->bits,
+ snprintf(s->buffer, sizeof(s->buffer), "%u:%s%s:%u",
+ af->sample_rate, sample_format_to_string(af->format),
af->reverse_endian ? REVERSE_ENDIAN_SUFFIX : "",
af->channels);