summaryrefslogtreecommitdiffstats
path: root/polyp
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-09-16 00:03:19 +0000
committerLennart Poettering <lennart@poettering.net>2005-09-16 00:03:19 +0000
commit668f3cdcbc02ebb5074a31016f1766bfe4992240 (patch)
tree0598141cb185927c1927d8969327760de2a0ab06 /polyp
parent652e000f9e3b75fb705abf30c0dc447283a64191 (diff)
handle float values in sound files sensibly
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@354 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp')
-rw-r--r--polyp/sound-file.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/polyp/sound-file.c b/polyp/sound-file.c
index 80233da5..f16d326a 100644
--- a/polyp/sound-file.c
+++ b/polyp/sound-file.c
@@ -52,19 +52,18 @@ int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_m
goto finish;
}
- switch (sfinfo.format & 0xFF) {
- case SF_FORMAT_PCM_16:
- case SF_FORMAT_PCM_U8:
- case SF_FORMAT_ULAW:
- case SF_FORMAT_ALAW:
- ss->format = PA_SAMPLE_S16NE;
- readf_function = (sf_count_t (*)(SNDFILE *sndfile, void *ptr, sf_count_t frames)) sf_readf_short;
- break;
+ switch (sfinfo.format & SF_FORMAT_SUBMASK) {
case SF_FORMAT_FLOAT:
- default:
+ case SF_FORMAT_DOUBLE:
+ /* Only float and double need a special case. */
ss->format = PA_SAMPLE_FLOAT32NE;
readf_function = (sf_count_t (*)(SNDFILE *sndfile, void *ptr, sf_count_t frames)) sf_readf_float;
break;
+ default:
+ /* Everything else is cleanly converted to signed 16 bit. */
+ ss->format = PA_SAMPLE_S16NE;
+ readf_function = (sf_count_t (*)(SNDFILE *sndfile, void *ptr, sf_count_t frames)) sf_readf_short;
+ break;
}
ss->rate = sfinfo.samplerate;