From c2976b1f872a989365171c6229d44cba1df4277e Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Wed, 2 Nov 2011 21:54:15 +0100 Subject: [PATCH] oss: Use log2 function from core-util instead of own implementation --- src/modules/oss/oss-util.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/modules/oss/oss-util.c b/src/modules/oss/oss-util.c index 04899af..9412a87 100644 --- a/src/modules/oss/oss-util.c +++ b/src/modules/oss/oss-util.c @@ -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)); -- 2.7.4