]> code.delx.au - pulseaudio/commitdiff
oss: Use log2 function from core-util instead of own implementation
authorMaarten Bosmans <mkbosmans@gmail.com>
Wed, 2 Nov 2011 20:54:15 +0000 (21:54 +0100)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 14 Nov 2011 05:38:04 +0000 (11:08 +0530)
src/modules/oss/oss-util.c

index 04899afed883fffe685183a1ae4e759851e55a85..9412a87f60afac2917dc749ea2d6b9a88fd36ae8 100644 (file)
@@ -231,23 +231,14 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
     return 0;
 }
 
     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;
 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));
 
     if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) {
         pa_log("SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno));