From 73eabece3365c1bb47bf6b009682219c4492fda5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 11 Dec 2004 00:10:41 +0000 Subject: * add first part of zeroconf publisher * bump version to 0.7.1. * improve logging subsystem (introducing log levels) * remove verbose flag on cli * add new API pa_sample_format_to_string() * replace strtol() by usages of pa_atou() and pa_atoi() git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@317 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/sample.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'polyp/sample.c') diff --git a/polyp/sample.c b/polyp/sample.c index 978a3d6a..b0723f70 100644 --- a/polyp/sample.c +++ b/polyp/sample.c @@ -84,7 +84,7 @@ 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_spec_snprint(char *s, size_t l, const struct pa_sample_spec *spec) { +const char *pa_sample_format_to_string(enum pa_sample_format f) { static const char* const table[]= { [PA_SAMPLE_U8] = "U8", [PA_SAMPLE_ALAW] = "ALAW", @@ -95,12 +95,21 @@ void pa_sample_spec_snprint(char *s, size_t l, const struct pa_sample_spec *spec [PA_SAMPLE_FLOAT32BE] = "FLOAT32BE", }; + if (f >= PA_SAMPLE_MAX) + return NULL; + + return table[f]; +} + +void pa_sample_spec_snprint(char *s, size_t l, const struct pa_sample_spec *spec) { + assert(s && l && spec); + if (!pa_sample_spec_valid(spec)) { snprintf(s, l, "Invalid"); return; } - snprintf(s, l, "%s %uch %uHz", table[spec->format], spec->channels, spec->rate); + snprintf(s, l, "%s %uch %uHz", pa_sample_format_to_string(spec->format), spec->channels, spec->rate); } pa_volume_t pa_volume_multiply(pa_volume_t a, pa_volume_t b) { -- cgit