From e61c2dddb7bc392ab4073d5691870615ada82922 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 3 Jul 2004 23:35:12 +0000 Subject: add pa_ prefix to all identifiers. fix downsampling/resampling add support for U8 samples git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@49 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/sample.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/sample.c') diff --git a/src/sample.c b/src/sample.c index 706880e4..20142a23 100644 --- a/src/sample.c +++ b/src/sample.c @@ -1,3 +1,4 @@ +#include #include #include "sample.h" @@ -44,7 +45,7 @@ int pa_sample_spec_valid(const struct pa_sample_spec *spec) { if (!spec->rate || !spec->channels) return 0; - if (spec->format <= 0 || spec->format >= PA_SAMPLE_MAX) + if (spec->format >= PA_SAMPLE_MAX) return 0; return 1; @@ -55,3 +56,17 @@ int pa_sample_spec_equal(const struct pa_sample_spec*a, const struct pa_sample_s return (a->format == b->format) && (a->rate == b->rate) && (a->channels == b->channels); } + +void pa_sample_snprint(char *s, size_t l, const struct pa_sample_spec *spec) { + static const char* const table[]= { + [PA_SAMPLE_U8] = "U8", + [PA_SAMPLE_ALAW] = "ALAW", + [PA_SAMPLE_ULAW] = "ULAW", + [PA_SAMPLE_S16LE] = "S16LE", + [PA_SAMPLE_S16BE] = "S16BE", + [PA_SAMPLE_FLOAT32] = "FLOAT32", + }; + + assert(pa_sample_spec_valid(spec)); + snprintf(s, l, "%s %uch %uHz", table[spec->format], spec->channels, spec->rate); +} -- cgit