From c412d6251e9cd3abe735b7622af4003502e54f72 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Nov 2009 17:11:34 +0100 Subject: 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. --- src/audio_format.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/audio_format.c') diff --git a/src/audio_format.c b/src/audio_format.c index f88735c7..33cd90f5 100644 --- a/src/audio_format.c +++ b/src/audio_format.c @@ -28,6 +28,31 @@ #define REVERSE_ENDIAN_SUFFIX "_be" #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) @@ -35,8 +60,8 @@ audio_format_to_string(const struct audio_format *af, 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); -- cgit v1.2.3