mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-20 08:56:47 -05:00
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
This commit is contained in:
parent
f014d466cd
commit
450ad85b35
9 changed files with 292 additions and 22 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue