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.
This commit is contained in:
Max Kellermann
2009-11-10 17:11:34 +01:00
parent 68c2cfbb40
commit c412d6251e
50 changed files with 512 additions and 215 deletions
+27 -2
View File
@@ -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);