diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-19 23:12:41 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-19 23:12:41 +0000 |
commit | b118982674effa44aa1687e8bd0d2bc0eb6254b2 (patch) | |
tree | b2a63ba549b374f94a1dec9c1e4e07e05f0b8058 /polyp/sample.c | |
parent | 70a30530e03ed4c43639575a479d77e38fea56ea (diff) |
remove obnoxious assert from module-combine
tagstruct: add support for NULL strings
improve pactl
correct pa_bytes_snprint()
pa_sample_spec_snprint(): don't fail on invalid sample spec
rename PA_SAMPLE_SNPRINT_MAX_LENGTH to PA_SAMPLE_SPEC_SNPRINT_MAX
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@222 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/sample.c')
-rw-r--r-- | polyp/sample.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/polyp/sample.c b/polyp/sample.c index 397e57a2..143e1e41 100644 --- a/polyp/sample.c +++ b/polyp/sample.c @@ -94,7 +94,11 @@ void pa_sample_spec_snprint(char *s, size_t l, const struct pa_sample_spec *spec [PA_SAMPLE_FLOAT32BE] = "FLOAT32BE", }; - assert(pa_sample_spec_valid(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); } @@ -120,13 +124,13 @@ double pa_volume_to_dB(pa_volume_t v) { return 20*log10((double) v/PA_VOLUME_NORM); } -void pa_bytes_snprint(char *s, size_t l, off_t v) { - if (v >= (off_t) 1024*1024*1024) - snprintf(s, l, "%0.1f GB", (double) v/1024/1024/1024); - else if (v >= (off_t) 1024*1024) - snprintf(s, l, "%0.1f MB", (double) v/1024/1024); - else if (v >= (off_t) 1024) - snprintf(s, l, "%0.1f KB", (double) v/1024); +void pa_bytes_snprint(char *s, size_t l, unsigned v) { + if (v >= ((unsigned) 1024)*1024*1024) + snprintf(s, l, "%0.1f GB", ((double) v)/1024/1024/1024); + else if (v >= ((unsigned) 1024)*1024) + snprintf(s, l, "%0.1f MB", ((double) v)/1024/1024); + else if (v >= (unsigned) 1024) + snprintf(s, l, "%0.1f KB", ((double) v)/1024); else snprintf(s, l, "%u B", (unsigned) v); } |