[pulseaudio-commits] r1746 - in /branches/lennart/src/pulsecore: memblock.c memblock.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Sep 2 13:37:18 PDT 2007


Author: lennart
Date: Sun Sep  2 22:37:17 2007
New Revision: 1746

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1746&root=3Dpulseaudio&vi=
ew=3Drev
Log:
add new API pa_memblock_will_need() and make use of PA_PAGE_SIZE macro

Modified:
    branches/lennart/src/pulsecore/memblock.c
    branches/lennart/src/pulsecore/memblock.h

Modified: branches/lennart/src/pulsecore/memblock.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
memblock.c?rev=3D1746&root=3Dpulseaudio&r1=3D1745&r2=3D1746&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/memblock.c (original)
+++ branches/lennart/src/pulsecore/memblock.c Sun Sep  2 22:37:17 2007
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <signal.h>
+#include <errno.h>
 =

 #include <pulse/xmalloc.h>
 #include <pulse/def.h>
@@ -42,6 +43,7 @@
 #include <pulsecore/semaphore.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/flist.h>
+#include <pulsecore/core-util.h>
 =

 #include "memblock.h"
 =

@@ -596,6 +598,20 @@
     pa_memblock_unref(b);
 }
 =

+/* No lock necessary. */
+pa_memblock *pa_memblock_will_need(pa_memblock *b) {
+    void *p;
+    =

+    pa_assert(b);
+    pa_assert(PA_REFCNT_VALUE(b) > 0);
+
+    p =3D pa_memblock_acquire(b);
+    pa_will_need(p, b->length);
+    pa_memblock_release(b);
+
+    return b;
+}
+
 /* Self-locked. This function is not multiple-caller safe */
 static void memblock_replace_import(pa_memblock *b) {
     pa_memimport_segment *seg;
@@ -628,7 +644,6 @@
 }
 =

 pa_mempool* pa_mempool_new(int shared) {
-    size_t ps;
     pa_mempool *p;
 =

     p =3D pa_xnew(pa_mempool, 1);
@@ -636,18 +651,9 @@
     p->mutex =3D pa_mutex_new(1);
     p->semaphore =3D pa_semaphore_new(0);
 =

-#ifdef HAVE_SYSCONF
-    ps =3D (size_t) sysconf(_SC_PAGESIZE);
-#elif defined(PAGE_SIZE)
-    ps =3D (size_t) PAGE_SIZE;
-#else
-    ps =3D 4096; /* Let's hope it's like x86. */
-#endif
-
-    p->block_size =3D (PA_MEMPOOL_SLOT_SIZE/ps)*ps;
-
-    if (p->block_size < ps)
-        p->block_size =3D ps;
+    p->block_size =3D PA_PAGE_ALIGN(PA_MEMPOOL_SLOT_SIZE);
+    if (p->block_size < PA_PAGE_SIZE)
+        p->block_size =3D PA_PAGE_SIZE;
 =

     p->n_blocks =3D PA_MEMPOOL_SLOTS_MAX;
 =


Modified: branches/lennart/src/pulsecore/memblock.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
memblock.h?rev=3D1746&root=3Dpulseaudio&r1=3D1745&r2=3D1746&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/memblock.h (original)
+++ branches/lennart/src/pulsecore/memblock.h Sun Sep  2 22:37:17 2007
@@ -113,6 +113,8 @@
 size_t pa_memblock_get_length(pa_memblock *b);
 pa_mempool * pa_memblock_get_pool(pa_memblock *b);
 =

+pa_memblock *pa_memblock_will_need(pa_memblock *b);
+
 /* The memory block manager */
 pa_mempool* pa_mempool_new(int shared);
 void pa_mempool_free(pa_mempool *p);




More information about the pulseaudio-commits mailing list