[pulseaudio-commits] r1342 - in /trunk/src/pulsecore: memblock.c memblock.h memchunk.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Aug 28 18:16:48 PDT 2006


Author: lennart
Date: Tue Aug 29 03:16:47 2006
New Revision: 1342

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1342&root=pulseaudio&view=rev
Log:
modify memory block reference counting to use the new reference counting API

Modified:
    trunk/src/pulsecore/memblock.c
    trunk/src/pulsecore/memblock.h
    trunk/src/pulsecore/memchunk.c

Modified: trunk/src/pulsecore/memblock.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/memblock.c?rev=1342&root=pulseaudio&r1=1341&r2=1342&view=diff
==============================================================================
--- trunk/src/pulsecore/memblock.c (original)
+++ trunk/src/pulsecore/memblock.c Tue Aug 29 03:16:47 2006
@@ -170,7 +170,7 @@
     b = pa_xmalloc(sizeof(pa_memblock) + length);
     b->type = PA_MEMBLOCK_APPENDED;
     b->read_only = 0;
-    b->ref = 1;
+    PA_REFCNT_INIT(b);
     b->length = length;
     b->data = (uint8_t*) b + sizeof(pa_memblock);
     b->pool = p;
@@ -253,7 +253,7 @@
 
     b->length = length;
     b->read_only = 0;
-    b->ref = 1;
+    PA_REFCNT_INIT(b);
     b->pool = p;
 
     stat_add(b);
@@ -270,7 +270,7 @@
     b = pa_xnew(pa_memblock, 1);
     b->type = PA_MEMBLOCK_FIXED;
     b->read_only = read_only;
-    b->ref = 1;
+    PA_REFCNT_INIT(b);
     b->length = length;
     b->data = d;
     b->pool = p;
@@ -290,7 +290,7 @@
     b = pa_xnew(pa_memblock, 1);
     b->type = PA_MEMBLOCK_USER;
     b->read_only = read_only;
-    b->ref = 1;
+    PA_REFCNT_INIT(b);
     b->length = length;
     b->data = d;
     b->per_type.user.free_cb = free_cb;
@@ -302,17 +302,17 @@
 
 pa_memblock* pa_memblock_ref(pa_memblock*b) {
     assert(b);
-    assert(b->ref >= 1);
-    
-    b->ref++;
+    assert(PA_REFCNT_VALUE(b) > 0);
+
+    PA_REFCNT_INC(b);
     return b;
 }
 
 void pa_memblock_unref(pa_memblock*b) {
     assert(b);
-    assert(b->ref >= 1);
-
-    if ((--(b->ref)) > 0)
+    assert(PA_REFCNT_VALUE(b) > 0);
+
+    if (PA_REFCNT_DEC(b) > 0)
         return;
     
     stat_remove(b);
@@ -403,10 +403,10 @@
 
 void pa_memblock_unref_fixed(pa_memblock *b) {
     assert(b);
-    assert(b->ref >= 1);
+    assert(PA_REFCNT_VALUE(b) > 0);
     assert(b->type == PA_MEMBLOCK_FIXED);
 
-    if (b->ref > 1)
+    if (PA_REFCNT_VALUE(b) > 1)
         memblock_make_local(b);
 
     pa_memblock_unref(b);
@@ -615,7 +615,7 @@
     b = pa_xnew(pa_memblock, 1);
     b->type = PA_MEMBLOCK_IMPORTED;
     b->read_only = 1;
-    b->ref = 1;
+    PA_REFCNT_INIT(b);
     b->length = size;
     b->data = (uint8_t*) seg->memory.ptr + offset;
     b->pool = i->pool;

Modified: trunk/src/pulsecore/memblock.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/memblock.h?rev=1342&root=pulseaudio&r1=1341&r2=1342&view=diff
==============================================================================
--- trunk/src/pulsecore/memblock.h (original)
+++ trunk/src/pulsecore/memblock.h Tue Aug 29 03:16:47 2006
@@ -26,6 +26,7 @@
 #include <inttypes.h>
 
 #include <pulsecore/llist.h>
+#include <pulsecore/refcnt.h>
 
 /* A pa_memblock is a reference counted memory block. PulseAudio
  * passed references to pa_memblocks around instead of copying
@@ -56,7 +57,7 @@
 struct pa_memblock {
     pa_memblock_type_t type;
     int read_only; /* boolean */
-    unsigned ref;  /* the reference counter */
+    PA_REFCNT_DECLARE; /* the reference counter */
     size_t length;
     void *data;
     pa_mempool *pool;

Modified: trunk/src/pulsecore/memchunk.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/memchunk.c?rev=1342&root=pulseaudio&r1=1341&r2=1342&view=diff
==============================================================================
--- trunk/src/pulsecore/memchunk.c (original)
+++ trunk/src/pulsecore/memchunk.c Tue Aug 29 03:16:47 2006
@@ -38,9 +38,11 @@
     
     assert(c);
     assert(c->memblock);
-    assert(c->memblock->ref >= 1);
+    assert(PA_REFCNT_VALUE(c->memblock) > 0);
 
-    if (c->memblock->ref == 1 && !c->memblock->read_only && c->memblock->length >= c->index+min)
+    if (PA_REFCNT_VALUE(c->memblock) == 1 &&
+        !c->memblock->read_only &&
+        c->memblock->length >= c->index+min)
         return;
 
     l = c->length;




More information about the pulseaudio-commits mailing list