mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
add pa_sound_file_too_big_to_cache()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@355 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
668f3cdcbc
commit
48b2a87ed8
2 changed files with 38 additions and 1 deletions
|
|
@ -75,7 +75,7 @@ int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_m
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((l = pa_frame_size(ss)*sfinfo.frames) > MAX_FILE_SIZE) {
|
if ((l = pa_frame_size(ss)*sfinfo.frames) > MAX_FILE_SIZE) {
|
||||||
pa_log(__FILE__": File to large\n");
|
pa_log(__FILE__": File too large\n");
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,3 +102,38 @@ finish:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pa_sound_file_too_big_to_cache(const char *fname) {
|
||||||
|
SNDFILE*sf = NULL;
|
||||||
|
SF_INFO sfinfo;
|
||||||
|
struct pa_sample_spec ss;
|
||||||
|
|
||||||
|
if (!(sf = sf_open(fname, SFM_READ, &sfinfo))) {
|
||||||
|
pa_log(__FILE__": Failed to open file %s\n", fname);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sf_close(sf);
|
||||||
|
|
||||||
|
switch (sfinfo.format & SF_FORMAT_SUBMASK) {
|
||||||
|
case SF_FORMAT_FLOAT:
|
||||||
|
case SF_FORMAT_DOUBLE:
|
||||||
|
/* Only float and double need a special case. */
|
||||||
|
ss.format = PA_SAMPLE_FLOAT32NE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* Everything else is cleanly converted to signed 16 bit. */
|
||||||
|
ss.format = PA_SAMPLE_S16NE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ss.rate = sfinfo.samplerate;
|
||||||
|
ss.channels = sfinfo.channels;
|
||||||
|
|
||||||
|
if ((pa_frame_size(&ss) * sfinfo.frames) > MAX_FILE_SIZE) {
|
||||||
|
pa_log(__FILE__": File too large %s\n", fname);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,6 @@
|
||||||
|
|
||||||
int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_memchunk *chunk, struct pa_memblock_stat *s);
|
int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_memchunk *chunk, struct pa_memblock_stat *s);
|
||||||
|
|
||||||
|
int pa_sound_file_too_big_to_cache(const char *fname);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue