[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-214-gb6804ee

Lennart Poettering gitmailer-noreply at 0pointer.de
Sat Jan 10 03:16:39 PST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  98049fbf81fae18707281642f6ae5b23632bd068 (commit)

- Log -----------------------------------------------------------------
b6804ee... Make sure we don't drop any data on the client side
8a3dc57... make module-sine-source actually work
4e8ada5... show maximum usable slot size
c850aa0... Add new pa_reduce() and pa_gcd() functions
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-sine-source.c |   25 ++++++++++++++++++-------
 src/pulsecore/core-util.c        |   24 ++++++++++++++++++++++++
 src/pulsecore/core-util.h        |    3 +++
 src/pulsecore/memblock.c         |    5 +++--
 src/utils/pacat.c                |   17 ++++++++---------
 5 files changed, 56 insertions(+), 18 deletions(-)

-----------------------------------------------------------------------

commit c850aa0c5b5e856618f11021a3e2a338c625de67
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 10 02:53:57 2009 +0100

    Add new pa_reduce() and pa_gcd() functions

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index dde34d7..6f31566 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2487,3 +2487,27 @@ pa_bool_t pa_in_valgrind(void) {
     return b > 1;
 }
 #endif
+
+unsigned pa_gcd(unsigned a, unsigned b) {
+
+    while (b > 0) {
+        unsigned t = b;
+        b = a % b;
+        a = t;
+    }
+
+    return a;
+}
+
+void pa_reduce(unsigned *num, unsigned *den) {
+
+    unsigned gcd = pa_gcd(*num, *den);
+
+    if (gcd <= 0)
+        return;
+
+    *num /= gcd;
+    *den /= gcd;
+
+    pa_assert(pa_gcd(*num, *den) == 1);
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index fd6ee89..d9fad11 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -206,4 +206,7 @@ static inline pa_bool_t pa_in_valgrind(void) {
 }
 #endif
 
+unsigned pa_gcd(unsigned a, unsigned b);
+void pa_reduce(unsigned *num, unsigned *den);
+
 #endif

commit 4e8ada521affb62d8d95a21270371e40853599fb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 10 02:55:57 2009 +0100

    show maximum usable slot size

diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index d9e1bf1..1d7f455 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -711,11 +711,12 @@ pa_mempool* pa_mempool_new(pa_bool_t shared, size_t size) {
         return NULL;
     }
 
-    pa_log_debug("Using %s memory pool with %u slots of size %s each, total size is %s",
+    pa_log_debug("Using %s memory pool with %u slots of size %s each, total size is %s, maximum usable slot size is %lu",
                  p->memory.shared ? "shared" : "private",
                  p->n_blocks,
                  pa_bytes_snprint(t1, sizeof(t1), (unsigned) p->block_size),
-                 pa_bytes_snprint(t2, sizeof(t2), (unsigned) (p->n_blocks * p->block_size)));
+                 pa_bytes_snprint(t2, sizeof(t2), (unsigned) (p->n_blocks * p->block_size)),
+                 (unsigned long) pa_mempool_block_size_max(p));
 
     memset(&p->stat, 0, sizeof(p->stat));
     pa_atomic_store(&p->n_init, 0);

commit 8a3dc57df2c90f9f27325998033db996b8fa5cfb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 10 03:33:10 2009 +0100

    make module-sine-source actually work

diff --git a/src/modules/module-sine-source.c b/src/modules/module-sine-source.c
index dcc3416..358514a 100644
--- a/src/modules/module-sine-source.c
+++ b/src/modules/module-sine-source.c
@@ -129,7 +129,7 @@ static void source_update_requested_latency_cb(pa_source *s) {
     if (u->block_usec == (pa_usec_t) -1)
         u->block_usec = s->thread_info.max_latency;
 
-    pa_log("new block msec = %lu", (unsigned long) (u->block_usec / PA_USEC_PER_MSEC));
+    pa_log_debug("new block msec = %lu", (unsigned long) (u->block_usec / PA_USEC_PER_MSEC));
 }
 
 static void process_render(struct userdata *u, pa_usec_t now) {
@@ -147,7 +147,6 @@ static void process_render(struct userdata *u, pa_usec_t now) {
 
         pa_log_debug("posting %lu", (unsigned long) chunk.length);
         pa_source_post(u->source, &chunk);
-        pa_memchunk_dump_to_file(&chunk, "sine");
 
         u->peek_index += chunk.length;
         while (u->peek_index >= u->memchunk.length)
@@ -208,7 +207,7 @@ static void calc_sine(float *f, size_t l, double freq) {
     l /= sizeof(float);
 
     for (i = 0; i < l; i++)
-        f[i] = (float) sin((double) i/(double)l*M_PI*2*freq)/2;
+        *(f++) = (float) 0.5f * sin((double) i*M_PI*2*freq / (double) l);
 }
 
 int pa__init(pa_module*m) {
@@ -218,6 +217,8 @@ int pa__init(pa_module*m) {
     uint32_t frequency;
     pa_sample_spec ss;
     void *p;
+    unsigned n, d;
+    size_t l;
 
     pa_assert(m);
 
@@ -249,12 +250,22 @@ int pa__init(pa_module*m) {
 
     u->peek_index = 0;
     pa_memchunk_reset(&u->memchunk);
-    u->memchunk.memblock = pa_memblock_new(m->core->mempool, (size_t) -1);
-    u->memchunk.length = pa_frame_align(pa_memblock_get_length(u->memchunk.memblock), &ss);
+
+    n = ss.rate;
+    d = frequency;
+    pa_reduce(&n, &d);
+
+    l = pa_mempool_block_size_max(m->core->mempool) / pa_frame_size(&ss);
+
+    l /= n;
+    if (l <= 0) l = 1;
+    l *= n;
+
+    u->memchunk.length = l * pa_frame_size(&ss);
+    u->memchunk.memblock = pa_memblock_new(m->core->mempool, u->memchunk.length);
 
     p = pa_memblock_acquire(u->memchunk.memblock);
-    calc_sine(p, u->memchunk.length,
-              (double) frequency * (double) pa_bytes_to_usec(u->memchunk.length, &ss) / (double) PA_USEC_PER_SEC);
+    calc_sine(p, u->memchunk.length, pa_bytes_to_usec(u->memchunk.length, &ss) * frequency / PA_USEC_PER_SEC);
     pa_memblock_release(u->memchunk.memblock);
 
     pa_source_new_data_init(&data);

commit b6804eefea4697d594210502b19f8370771e2a22
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 10 03:33:27 2009 +0100

    Make sure we don't drop any data on the client side

diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index ea736e2..b1e0d1f 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -139,17 +139,16 @@ static void stream_read_callback(pa_stream *s, size_t length, void *userdata) {
     assert(length > 0);
 
     if (buffer) {
-        fprintf(stderr, _("Buffer overrun, dropping incoming data\n"));
-        if (pa_stream_drop(s) < 0) {
-            fprintf(stderr, _("pa_stream_drop() failed: %s\n"), pa_strerror(pa_context_errno(context)));
-            quit(1);
-        }
-        return;
+        buffer = pa_xrealloc(buffer, buffer_length + length);
+        memcpy((uint8_t*) buffer + buffer_length, data, length);
+        buffer_length += length;
+    } else {
+        buffer = pa_xmalloc(length);
+        memcpy(buffer, data, length);
+        buffer_length = length;
+        buffer_index = 0;
     }
 
-    buffer = pa_xmalloc(buffer_length = length);
-    memcpy(buffer, data, length);
-    buffer_index = 0;
     pa_stream_drop(s);
 }
 

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list