diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-27 21:05:55 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-27 21:05:55 +0000 |
commit | 450ad85b35bd600ed020f7ec119d51e7e7bc01a4 (patch) | |
tree | 4e0079eaf12964a6b312f58e92dd1aac47af40b7 /polyp/sound-file.c | |
parent | f014d466cd5f65b03a7a1608aa3d4cd83425a56e (diff) |
try to use file sample type for cache entries and play-file playback
allow paplay to use STDIN
add new module: module-match
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@244 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/sound-file.c')
-rw-r--r-- | polyp/sound-file.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/polyp/sound-file.c b/polyp/sound-file.c index d1f7e0f7..c63aa628 100644 --- a/polyp/sound-file.c +++ b/polyp/sound-file.c @@ -39,19 +39,34 @@ int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_m SF_INFO sfinfo; int ret = -1; size_t l; + sf_count_t (*readf_function)(SNDFILE *sndfile, void *ptr, sf_count_t frames); assert(fname && ss && chunk); - memset(&sfinfo, 0, sizeof(sfinfo)); - chunk->memblock = NULL; chunk->index = chunk->length = 0; - + + memset(&sfinfo, 0, sizeof(sfinfo)); + if (!(sf = sf_open(fname, SFM_READ, &sfinfo))) { pa_log(__FILE__": Failed to open file %s\n", fname); goto finish; } - ss->format = PA_SAMPLE_FLOAT32; + 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; + case SF_FORMAT_FLOAT: + default: + ss->format = PA_SAMPLE_FLOAT32NE; + readf_function = (sf_count_t (*)(SNDFILE *sndfile, void *ptr, sf_count_t frames)) sf_readf_float; + break; + } + ss->rate = sfinfo.samplerate; ss->channels = sfinfo.channels; @@ -70,7 +85,7 @@ int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_m chunk->index = 0; chunk->length = l; - if (sf_readf_float(sf, chunk->memblock->data, sfinfo.frames) != sfinfo.frames) { + if (readf_function(sf, chunk->memblock->data, sfinfo.frames) != sfinfo.frames) { pa_log(__FILE__": Premature file end\n"); goto finish; } |