[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.16-test1-31-g7dabe05

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Jul 1 11:22:31 PDT 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  b174a511207d67896800ae82a5797dcda1ec2780 (commit)

- Log -----------------------------------------------------------------
7dabe05 memtrap: properly lock access to memtrap changer
28e4625 memblock: rearrange locking order
efdd3d0 reserve: update from upstream git repo
5d4769b alsa: fix a few comments
5bb1883 build-sys: add missing dependency to libcli
-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am               |    2 +-
 src/modules/alsa/alsa-sink.c  |    3 +--
 src/modules/reserve-monitor.c |   12 +++++++++++-
 src/modules/reserve-monitor.h |   10 ++++++++++
 src/modules/reserve.c         |    2 ++
 src/modules/reserve.h         |   10 ++++++++++
 src/pulsecore/memblock.c      |   38 +++++++++++++++++++++-----------------
 src/pulsecore/memtrap.c       |   20 ++++++++++++++++++++
 8 files changed, 76 insertions(+), 21 deletions(-)

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

commit 5bb1883e60a70210dedbf1590a2bb8665aba2878
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 1 20:19:42 2009 +0200

    build-sys: add missing dependency to libcli

diff --git a/src/Makefile.am b/src/Makefile.am
index 0d5bd85..7ebf1f8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1246,7 +1246,7 @@ module_simple_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINOR
 
 module_cli_la_SOURCES = modules/module-cli.c
 module_cli_la_LDFLAGS = $(MODULE_LDFLAGS)
-module_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libcli.la
+module_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libcli.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_cli_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)

commit 5d4769b7dd9467ee7c9475fad689918cbae216a4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 1 20:20:06 2009 +0200

    alsa: fix a few comments

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index c584362..0cde694 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -169,10 +169,10 @@ static int reserve_init(struct userdata *u, const char *dname) {
     if (pa_in_system_mode())
         return 0;
 
-    /* We are resuming, try to lock the device */
     if (!(rname = pa_alsa_get_reserve_name(dname)))
         return 0;
 
+    /* We are resuming, try to lock the device */
     u->reserve = pa_reserve_wrapper_get(u->core, rname);
     pa_xfree(rname);
 
@@ -222,7 +222,6 @@ static int reserve_monitor_init(struct userdata *u, const char *dname) {
     if (pa_in_system_mode())
         return 0;
 
-    /* We are resuming, try to lock the device */
     if (!(rname = pa_alsa_get_reserve_name(dname)))
         return 0;
 

commit efdd3d054ba8ace4560dfe9008ac931966b88249
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 1 20:20:36 2009 +0200

    reserve: update from upstream git repo

diff --git a/src/modules/reserve-monitor.c b/src/modules/reserve-monitor.c
index 64d2a7c..13ecde2 100644
--- a/src/modules/reserve-monitor.c
+++ b/src/modules/reserve-monitor.c
@@ -1,3 +1,5 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/
+
 /***
   Copyright 2009 Lennart Poettering
 
@@ -76,9 +78,17 @@ static DBusHandlerResult filter_handler(
 			goto invalid;
 
 		if (strcmp(name, m->service_name) == 0) {
-
 			m->busy = !!(new && *new);
 
+			/* If we ourselves own the device, then don't consider this 'busy' */
+			if (m->busy) {
+				const char *un;
+
+				if ((un = dbus_bus_get_unique_name(c)))
+					if (strcmp(new, un) == 0)
+						m->busy = FALSE;
+			}
+
 			if (m->change_cb) {
 				m->ref++;
 				m->change_cb(m);
diff --git a/src/modules/reserve-monitor.h b/src/modules/reserve-monitor.h
index 4f4a833..421a52e 100644
--- a/src/modules/reserve-monitor.h
+++ b/src/modules/reserve-monitor.h
@@ -1,3 +1,5 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/
+
 #ifndef fooreservemonitorhfoo
 #define fooreservemonitorhfoo
 
@@ -28,6 +30,10 @@
 #include <dbus/dbus.h>
 #include <inttypes.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct rm_monitor rm_monitor;
 
 /* Prototype for a function that is called whenever the reservation
@@ -59,4 +65,8 @@ void rm_set_userdata(rm_monitor *m, void *userdata);
  * userdata was set. */
 void* rm_get_userdata(rm_monitor *m);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/src/modules/reserve.c b/src/modules/reserve.c
index 09bc46c..5597f17 100644
--- a/src/modules/reserve.c
+++ b/src/modules/reserve.c
@@ -1,3 +1,5 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/
+
 /***
   Copyright 2009 Lennart Poettering
 
diff --git a/src/modules/reserve.h b/src/modules/reserve.h
index 3107129..9ae49cf 100644
--- a/src/modules/reserve.h
+++ b/src/modules/reserve.h
@@ -1,3 +1,5 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/
+
 #ifndef fooreservehfoo
 #define fooreservehfoo
 
@@ -28,6 +30,10 @@
 #include <dbus/dbus.h>
 #include <inttypes.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct rd_device rd_device;
 
 /* Prototype for a function that is called whenever someone else wants
@@ -66,4 +72,8 @@ void rd_set_userdata(rd_device *d, void *userdata);
  * userdata was set. */
 void* rd_get_userdata(rd_device *d);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

commit 28e4625a52dedbf9f3697b3b3bb5b6ea59f336c9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 1 20:20:55 2009 +0200

    memblock: rearrange locking order

diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index 9a57895..2c3f98a 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -257,7 +257,7 @@ static struct mempool_slot* mempool_allocate_slot(pa_mempool *p) {
             slot = (struct mempool_slot*) ((uint8_t*) p->memory.ptr + (p->block_size * (size_t) idx));
 
         if (!slot) {
-            pa_log_info("Pool full");
+            pa_log_debug("Pool full");
             pa_atomic_inc(&p->stat.n_pool_full);
             return NULL;
         }
@@ -509,13 +509,16 @@ static void memblock_free(pa_memblock *b) {
 
             /* FIXME! This should be implemented lock-free */
 
-            segment = b->per_type.imported.segment;
-            pa_assert(segment);
-            import = segment->import;
-            pa_assert(import);
+            pa_assert_se(segment = b->per_type.imported.segment);
+            pa_assert_se(import = segment->import);
 
             pa_mutex_lock(import->mutex);
-            pa_hashmap_remove(import->blocks, PA_UINT32_TO_PTR(b->per_type.imported.id));
+
+            pa_hashmap_remove(
+                    import->blocks,
+                    PA_UINT32_TO_PTR(b->per_type.imported.id));
+
+            pa_assert(segment->n_blocks >= 1);
             if (-- segment->n_blocks <= 0)
                 segment_detach(segment);
 
@@ -525,6 +528,7 @@ static void memblock_free(pa_memblock *b) {
 
             if (pa_flist_push(PA_STATIC_FLIST_GET(unused_memblocks), b) < 0)
                 pa_xfree(b);
+
             break;
         }
 
@@ -657,7 +661,8 @@ pa_memblock *pa_memblock_will_need(pa_memblock *b) {
 
 /* Self-locked. This function is not multiple-caller safe */
 static void memblock_replace_import(pa_memblock *b) {
-    pa_memimport_segment *seg;
+    pa_memimport_segment *segment;
+    pa_memimport *import;
 
     pa_assert(b);
     pa_assert(b->type == PA_MEMBLOCK_IMPORTED);
@@ -667,23 +672,22 @@ static void memblock_replace_import(pa_memblock *b) {
     pa_atomic_dec(&b->pool->stat.n_imported);
     pa_atomic_sub(&b->pool->stat.imported_size, (int) b->length);
 
-    seg = b->per_type.imported.segment;
-    pa_assert(seg);
-    pa_assert(seg->import);
+    pa_assert_se(segment = b->per_type.imported.segment);
+    pa_assert_se(import = segment->import);
 
-    pa_mutex_lock(seg->import->mutex);
+    pa_mutex_lock(import->mutex);
 
     pa_hashmap_remove(
-            seg->import->blocks,
+            import->blocks,
             PA_UINT32_TO_PTR(b->per_type.imported.id));
 
     memblock_make_local(b);
 
-    if (-- seg->n_blocks <= 0) {
-        pa_mutex_unlock(seg->import->mutex);
-        segment_detach(seg);
-    } else
-        pa_mutex_unlock(seg->import->mutex);
+    pa_assert(segment->n_blocks >= 1);
+    if (-- segment->n_blocks <= 0)
+        segment_detach(segment);
+
+    pa_mutex_unlock(import->mutex);
 }
 
 pa_mempool* pa_mempool_new(pa_bool_t shared, size_t size) {

commit 7dabe051cdd3980887a78a6cfe8e06666e2b21c9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 1 20:22:38 2009 +0200

    memtrap: properly lock access to memtrap changer

diff --git a/src/pulsecore/memtrap.c b/src/pulsecore/memtrap.c
index e06f60c..7d91745 100644
--- a/src/pulsecore/memtrap.c
+++ b/src/pulsecore/memtrap.c
@@ -37,6 +37,7 @@
 #include <pulsecore/aupdate.h>
 #include <pulsecore/atomic.h>
 #include <pulsecore/once.h>
+#include <pulsecore/mutex.h>
 
 #include "memtrap.h"
 
@@ -49,6 +50,7 @@ struct pa_memtrap {
 
 static pa_memtrap *memtraps[2] = { NULL, NULL };
 static pa_aupdate *aupdate;
+static pa_static_mutex mutex = PA_STATIC_MUTEX_INIT; /* only required to serialize access to the write side */
 
 static void allocate_aupdate(void) {
     PA_ONCE_BEGIN {
@@ -124,6 +126,7 @@ static void memtrap_unlink(pa_memtrap *m, unsigned j) {
 pa_memtrap* pa_memtrap_add(const void *start, size_t size) {
     pa_memtrap *m = NULL;
     unsigned j;
+    pa_mutex *mx;
 
     pa_assert(start);
     pa_assert(size > 0);
@@ -138,33 +141,45 @@ pa_memtrap* pa_memtrap_add(const void *start, size_t size) {
 
     allocate_aupdate();
 
+    mx = pa_static_mutex_get(&mutex, FALSE, TRUE);
+    pa_mutex_lock(mx);
+
     j = pa_aupdate_write_begin(aupdate);
     memtrap_link(m, j);
     j = pa_aupdate_write_swap(aupdate);
     memtrap_link(m, j);
     pa_aupdate_write_end(aupdate);
 
+    pa_mutex_unlock(mx);
+
     return m;
 }
 
 void pa_memtrap_remove(pa_memtrap *m) {
     unsigned j;
+    pa_mutex *mx;
 
     pa_assert(m);
 
     allocate_aupdate();
 
+    mx = pa_static_mutex_get(&mutex, FALSE, TRUE);
+    pa_mutex_lock(mx);
+
     j = pa_aupdate_write_begin(aupdate);
     memtrap_unlink(m, j);
     j = pa_aupdate_write_swap(aupdate);
     memtrap_unlink(m, j);
     pa_aupdate_write_end(aupdate);
 
+    pa_mutex_unlock(mx);
+
     pa_xfree(m);
 }
 
 pa_memtrap *pa_memtrap_update(pa_memtrap *m, const void *start, size_t size) {
     unsigned j;
+    pa_mutex *mx;
 
     pa_assert(m);
 
@@ -176,6 +191,9 @@ pa_memtrap *pa_memtrap_update(pa_memtrap *m, const void *start, size_t size) {
 
     allocate_aupdate();
 
+    mx = pa_static_mutex_get(&mutex, FALSE, TRUE);
+    pa_mutex_lock(mx);
+
     j = pa_aupdate_write_begin(aupdate);
 
     if (m->start == start && m->size == size)
@@ -194,6 +212,8 @@ pa_memtrap *pa_memtrap_update(pa_memtrap *m, const void *start, size_t size) {
 unlock:
     pa_aupdate_write_end(aupdate);
 
+    pa_mutex_unlock(mx);
+
     return m;
 }
 

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list