[pulseaudio-commits] r1500 - in /branches/lennart/src/pulsecore: memblockq.c memblockq.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Jun 25 15:53:11 PDT 2007


Author: lennart
Date: Tue Jun 26 00:53:09 2007
New Revision: 1500

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1500&root=3Dpulseaudio&vi=
ew=3Drev
Log:
remove pa_memblockq_is_writable() (because it is stupid and not used anywhe=
re anyway, and replace all assert()s with pa_assert()s

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

Modified: branches/lennart/src/pulsecore/memblockq.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
memblockq.c?rev=3D1500&root=3Dpulseaudio&r1=3D1499&r2=3D1500&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/memblockq.c (original)
+++ branches/lennart/src/pulsecore/memblockq.c Tue Jun 26 00:53:09 2007
@@ -28,7 +28,6 @@
 #include <sys/time.h>
 #include <time.h>
 #include <stdio.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 =

@@ -36,6 +35,7 @@
 =

 #include <pulsecore/log.h>
 #include <pulsecore/mcalign.h>
+#include <pulsecore/macro.h>
 =

 #include "memblockq.h"
 =

@@ -66,8 +66,8 @@
 =

     pa_memblockq* bq;
 =

-    assert(base > 0);
-    assert(maxlength >=3D base);
+    pa_assert(base > 0);
+    pa_assert(maxlength >=3D base);
 =

     bq =3D pa_xnew(pa_memblockq, 1);
     bq->blocks =3D bq->blocks_tail =3D NULL;
@@ -80,7 +80,7 @@
         (unsigned long)maxlength, (unsigned long)tlength, (unsigned long)b=
ase, (unsigned long)prebuf, (unsigned long)minreq);
 =

     bq->maxlength =3D ((maxlength+base-1)/base)*base;
-    assert(bq->maxlength >=3D base);
+    pa_assert(bq->maxlength >=3D base);
 =

     bq->tlength =3D ((tlength+base-1)/base)*base;
     if (!bq->tlength || bq->tlength >=3D bq->maxlength)
@@ -110,7 +110,7 @@
 }
 =

 void pa_memblockq_free(pa_memblockq* bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     pa_memblockq_flush(bq);
 =

@@ -124,10 +124,10 @@
 }
 =

 static void drop_block(pa_memblockq *bq, struct memblock_list *q) {
-    assert(bq);
-    assert(q);
-
-    assert(bq->n_blocks >=3D 1);
+    pa_assert(bq);
+    pa_assert(q);
+
+    pa_assert(bq->n_blocks >=3D 1);
 =

     if (q->prev)
         q->prev->next =3D q->next;
@@ -148,7 +148,7 @@
 static int can_push(pa_memblockq *bq, size_t l) {
     int64_t end;
 =

-    assert(bq);
+    pa_assert(bq);
 =

     if (bq->read_index > bq->write_index) {
         size_t d =3D  bq->read_index - bq->write_index;
@@ -174,11 +174,11 @@
     struct memblock_list *q, *n;
     pa_memchunk chunk;
 =

-    assert(bq);
-    assert(uchunk);
-    assert(uchunk->memblock);
-    assert(uchunk->length > 0);
-    assert(uchunk->index + uchunk->length <=3D pa_memblock_get_length(uchu=
nk->memblock));
+    pa_assert(bq);
+    pa_assert(uchunk);
+    pa_assert(uchunk->memblock);
+    pa_assert(uchunk->length > 0);
+    pa_assert(uchunk->index + uchunk->length <=3D pa_memblock_get_length(u=
chunk->memblock));
 =

     if (uchunk->length % bq->base)
         return -1;
@@ -244,7 +244,7 @@
 =

                 /* Calculate offset */
                 d =3D bq->write_index + chunk.length - q->index;
-                assert(d > 0);
+                pa_assert(d > 0);
 =

                 /* Drop it from the new entry */
                 p->index =3D q->index + d;
@@ -274,7 +274,7 @@
         } else {
             size_t d;
 =

-            assert(bq->write_index + (int64_t)chunk.length > q->index &&
+            pa_assert(bq->write_index + (int64_t)chunk.length > q->index &&
                    bq->write_index + (int64_t)chunk.length < q->index + (i=
nt64_t)q->chunk.length &&
                    bq->write_index < q->index);
 =

@@ -291,8 +291,8 @@
     }
 =

     if (q) {
-        assert(bq->write_index >=3D  q->index + (int64_t)q->chunk.length);
-        assert(!q->next || (bq->write_index + (int64_t)chunk.length <=3D q=
->next->index));
+        pa_assert(bq->write_index >=3D  q->index + (int64_t)q->chunk.lengt=
h);
+        pa_assert(!q->next || (bq->write_index + (int64_t)chunk.length <=
=3D q->next->index));
 =

         /* Try to merge memory blocks */
 =

@@ -305,7 +305,7 @@
             return 0;
         }
     } else
-        assert(!bq->blocks || (bq->write_index + (int64_t)chunk.length <=
=3D bq->blocks->index));
+        pa_assert(!bq->blocks || (bq->write_index + (int64_t)chunk.length =
<=3D bq->blocks->index));
 =

 =

     n =3D pa_xnew(struct memblock_list, 1);
@@ -332,8 +332,8 @@
 }
 =

 int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk) {
-    assert(bq);
-    assert(chunk);
+    pa_assert(bq);
+    pa_assert(chunk);
 =

     if (bq->state =3D=3D PREBUF) {
 =

@@ -382,7 +382,7 @@
     }
 =

     /* Ok, let's pass real data to the caller */
-    assert(bq->blocks->index =3D=3D bq->read_index);
+    pa_assert(bq->blocks->index =3D=3D bq->read_index);
 =

     *chunk =3D bq->blocks->chunk;
     pa_memblock_ref(chunk->memblock);
@@ -391,10 +391,9 @@
 }
 =

 void pa_memblockq_drop(pa_memblockq *bq, const pa_memchunk *chunk, size_t =
length) {
-    assert(bq);
-    assert(length % bq->base =3D=3D 0);
-
-    assert(!chunk || length <=3D chunk->length);
+    pa_assert(bq);
+    pa_assert(length % bq->base =3D=3D 0);
+    pa_assert(!chunk || length <=3D chunk->length);
 =

     if (chunk) {
 =

@@ -410,7 +409,7 @@
 =

             /* The first item in the queue is not yet relevant */
 =

-            assert(!bq->blocks || bq->blocks->index > bq->read_index);
+            pa_assert(!bq->blocks || bq->blocks->index > bq->read_index);
             l =3D bq->blocks ? bq->blocks->index - bq->read_index : 0;
 =

             if (bq->silence) {
@@ -431,7 +430,7 @@
         if (bq->blocks) {
             size_t d;
 =

-            assert(bq->blocks->index >=3D bq->read_index);
+            pa_assert(bq->blocks->index >=3D bq->read_index);
 =

             d =3D (size_t) (bq->blocks->index - bq->read_index);
 =

@@ -446,7 +445,7 @@
                 bq->read_index +=3D d;
             }
 =

-            assert(bq->blocks->index =3D=3D bq->read_index);
+            pa_assert(bq->blocks->index =3D=3D bq->read_index);
 =

             if (bq->blocks->chunk.length <=3D length) {
                 /* We need to drop the full block */
@@ -475,7 +474,7 @@
 }
 =

 int pa_memblockq_is_readable(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     if (bq->prebuf > 0) {
         size_t l =3D pa_memblockq_get_length(bq);
@@ -490,17 +489,8 @@
     return 1;
 }
 =

-int pa_memblockq_is_writable(pa_memblockq *bq, size_t length) {
-    assert(bq);
-
-    if (length % bq->base)
-        return 0;
-
-    return pa_memblockq_get_length(bq) + length <=3D bq->tlength;
-}
-
 size_t pa_memblockq_get_length(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     if (bq->write_index <=3D bq->read_index)
         return 0;
@@ -510,7 +500,7 @@
 =

 size_t pa_memblockq_missing(pa_memblockq *bq) {
     size_t l;
-    assert(bq);
+    pa_assert(bq);
 =

     if ((l =3D pa_memblockq_get_length(bq)) >=3D bq->tlength)
         return 0;
@@ -520,13 +510,13 @@
 }
 =

 size_t pa_memblockq_get_minreq(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     return bq->minreq;
 }
 =

 void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t se=
ek) {
-    assert(bq);
+    pa_assert(bq);
 =

     switch (seek) {
         case PA_SEEK_RELATIVE:
@@ -543,16 +533,16 @@
             return;
     }
 =

-    assert(0);
+    pa_assert_not_reached();
 }
 =

 void pa_memblockq_flush(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     while (bq->blocks)
         drop_block(bq, bq->blocks);
 =

-    assert(bq->n_blocks =3D=3D 0);
+    pa_assert(bq->n_blocks =3D=3D 0);
 =

     bq->write_index =3D bq->read_index;
 =

@@ -560,26 +550,26 @@
 }
 =

 size_t pa_memblockq_get_tlength(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     return bq->tlength;
 }
 =

 int64_t pa_memblockq_get_read_index(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
     return bq->read_index;
 }
 =

 int64_t pa_memblockq_get_write_index(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
     return bq->write_index;
 }
 =

 int pa_memblockq_push_align(pa_memblockq* bq, const pa_memchunk *chunk) {
     pa_memchunk rchunk;
 =

-    assert(bq);
-    assert(chunk && bq->base);
+    pa_assert(bq);
+    pa_assert(chunk && bq->base);
 =

     if (bq->base =3D=3D 1)
         return pa_memblockq_push(bq, chunk);
@@ -606,7 +596,7 @@
 =

 void pa_memblockq_shorten(pa_memblockq *bq, size_t length) {
     size_t l;
-    assert(bq);
+    pa_assert(bq);
 =

     l =3D pa_memblockq_get_length(bq);
 =

@@ -615,27 +605,27 @@
 }
 =

 void pa_memblockq_prebuf_disable(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     if (bq->state =3D=3D PREBUF)
         bq->state =3D RUNNING;
 }
 =

 void pa_memblockq_prebuf_force(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     if (bq->state =3D=3D RUNNING && bq->prebuf > 0)
         bq->state =3D PREBUF;
 }
 =

 size_t pa_memblockq_get_maxlength(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     return bq->maxlength;
 }
 =

 size_t pa_memblockq_get_prebuf(pa_memblockq *bq) {
-    assert(bq);
+    pa_assert(bq);
 =

     return bq->prebuf;
 }

Modified: branches/lennart/src/pulsecore/memblockq.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
memblockq.h?rev=3D1500&root=3Dpulseaudio&r1=3D1499&r2=3D1500&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/memblockq.h (original)
+++ branches/lennart/src/pulsecore/memblockq.h Tue Jun 26 00:53:09 2007
@@ -94,9 +94,6 @@
 /* Test if the pa_memblockq is currently readable, that is, more data than=
 base */
 int pa_memblockq_is_readable(pa_memblockq *bq);
 =

-/* Test if the pa_memblockq is currently writable for the specified amount=
 of bytes */
-int pa_memblockq_is_writable(pa_memblockq *bq, size_t length);
-
 /* Return the length of the queue in bytes */
 size_t pa_memblockq_get_length(pa_memblockq *bq);
 =





More information about the pulseaudio-commits mailing list