From: Maarten Bosmans Date: Wed, 2 Nov 2011 20:54:15 +0000 (+0100) Subject: oss: Use log2 function from core-util instead of own implementation X-Git-Tag: 1.0_branch~229 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2976b1f872a989365171c6229d44cba1df4277e;p=profile%2Fivi%2Fpulseaudio.git oss: Use log2 function from core-util instead of own implementation --- 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));