oss: Use log2 function from core-util instead of own implementation

This commit is contained in:
Maarten Bosmans 2011-11-02 21:54:15 +01:00 committed by Arun Raghavan
parent 93f46b92c7
commit c2976b1f87

View file

@ -231,23 +231,14 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
return 0;
}
static int simple_log2(int v) {
int k = 0;
for (;;) {
v >>= 1;
if (!v) break;
k++;
}
return k;
}
int pa_oss_set_fragments(int fd, int nfrags, int frag_size) {
int arg;
arg = ((int) nfrags << 16) | simple_log2(frag_size);
pa_log_debug("Asking for %i fragments of size %i (requested %i)", nfrags, 1 << simple_log2(frag_size), frag_size);
pa_assert(frag_size >= 0);
arg = ((int) nfrags << 16) | pa_ulog2(frag_size);
pa_log_debug("Asking for %i fragments of size %i (requested %i)", nfrags, 1 << pa_ulog2(frag_size), frag_size);
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) {
pa_log("SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno));