[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.19-290-gf42022a

Colin Guthrie gitmailer-noreply at 0pointer.de
Thu Dec 3 14:00: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  118466638aa651eac0d20513d348ddcc446bb5e6 (commit)

- Log -----------------------------------------------------------------
f42022a stream-restore: At startup, create dbus entries only for valid database entries.
00debf4 stream-restore: Add a missing pa_xnew0() call in handle_add_entry().
a6b7ac6 stream-restore: Fix a few assertion misuses with the D-Bus code.
e785f72 dbus: Add a missing break statement in handle_message_cb().
7b1b68c dbus: Handle the cases when a non-existing interface is detected in an incoming message.
4c793cf libpulse: Store pa_stream pointers to hashmaps instead of dynarrays.
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-stream-restore.c |   18 ++++++++++++------
 src/pulse/context.c                 |   12 ++++++------
 src/pulse/internal.h                |    3 +--
 src/pulse/stream.c                  |   20 ++++++++++----------
 src/pulsecore/protocol-dbus.c       |    9 +++++++++
 src/pulsecore/protocol-dbus.h       |    1 +
 6 files changed, 39 insertions(+), 24 deletions(-)

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

commit 4c793cfc76360676b3881d7943b49adf892594d2
Author: Tanu Kaskinen <ext-tanu.kaskinen at nokia.com>
Date:   Thu Dec 3 13:22:05 2009 +0200

    libpulse: Store pa_stream pointers to hashmaps instead of dynarrays.
    
    Since the stream identifiers (channels) are monotonically growing integer, it
    isn't a good idea to use them as index to a dynamic array, because the array
    will grow all the time. This is not a problem with client connections that
    don't create many streams, but, for example, long-running clients that use
    libcanberra for playing event sounds, this means that the client connection
    effectively leaks memory.

diff --git a/src/pulse/context.c b/src/pulse/context.c
index e33143d..0018492 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -63,7 +63,7 @@
 #include <pulsecore/native-common.h>
 #include <pulsecore/pdispatch.h>
 #include <pulsecore/pstream.h>
-#include <pulsecore/dynarray.h>
+#include <pulsecore/hashmap.h>
 #include <pulsecore/socket-client.h>
 #include <pulsecore/pstream-util.h>
 #include <pulsecore/core-rtclock.h>
@@ -160,8 +160,8 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *
     c->client = NULL;
     c->pstream = NULL;
     c->pdispatch = NULL;
-    c->playback_streams = pa_dynarray_new();
-    c->record_streams = pa_dynarray_new();
+    c->playback_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
+    c->record_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
     c->client_index = PA_INVALID_INDEX;
     c->use_rtclock = pa_mainloop_is_our_api(mainloop);
 
@@ -266,9 +266,9 @@ static void context_free(pa_context *c) {
 #endif
 
     if (c->record_streams)
-        pa_dynarray_free(c->record_streams, NULL, NULL);
+        pa_hashmap_free(c->record_streams, NULL, NULL);
     if (c->playback_streams)
-        pa_dynarray_free(c->playback_streams, NULL, NULL);
+        pa_hashmap_free(c->playback_streams, NULL, NULL);
 
     if (c->mempool)
         pa_mempool_free(c->mempool);
@@ -375,7 +375,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
 
     pa_context_ref(c);
 
-    if ((s = pa_dynarray_get(c->record_streams, channel))) {
+    if ((s = pa_hashmap_get(c->record_streams, PA_UINT32_TO_PTR(channel)))) {
 
         if (chunk->memblock) {
             pa_memblockq_seek(s->record_memblockq, offset, seek, TRUE);
diff --git a/src/pulse/internal.h b/src/pulse/internal.h
index b371bfc..9545d50 100644
--- a/src/pulse/internal.h
+++ b/src/pulse/internal.h
@@ -34,7 +34,6 @@
 #include <pulsecore/socket-client.h>
 #include <pulsecore/pstream.h>
 #include <pulsecore/pdispatch.h>
-#include <pulsecore/dynarray.h>
 #include <pulsecore/llist.h>
 #include <pulsecore/native-common.h>
 #include <pulsecore/strlist.h>
@@ -66,7 +65,7 @@ struct pa_context {
     pa_pstream *pstream;
     pa_pdispatch *pdispatch;
 
-    pa_dynarray *record_streams, *playback_streams;
+    pa_hashmap *record_streams, *playback_streams;
     PA_LLIST_HEAD(pa_stream, streams);
     PA_LLIST_HEAD(pa_operation, operations);
 
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 4dea567..4081256 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -199,7 +199,7 @@ static void stream_unlink(pa_stream *s) {
         pa_pdispatch_unregister_reply(s->context->pdispatch, s);
 
     if (s->channel_valid) {
-        pa_dynarray_put((s->direction == PA_STREAM_PLAYBACK) ? s->context->playback_streams : s->context->record_streams, s->channel, NULL);
+        pa_hashmap_remove((s->direction == PA_STREAM_PLAYBACK) ? s->context->playback_streams : s->context->record_streams, PA_UINT32_TO_PTR(s->channel));
         s->channel = 0;
         s->channel_valid = FALSE;
     }
@@ -354,7 +354,7 @@ void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, uint32_t tag,
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(command == PA_COMMAND_PLAYBACK_STREAM_KILLED ? c->playback_streams : c->record_streams, channel)))
+    if (!(s = pa_hashmap_get(command == PA_COMMAND_PLAYBACK_STREAM_KILLED ? c->playback_streams : c->record_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -474,7 +474,7 @@ void pa_command_stream_moved(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(command == PA_COMMAND_PLAYBACK_STREAM_MOVED ? c->playback_streams : c->record_streams, channel)))
+    if (!(s = pa_hashmap_get(command == PA_COMMAND_PLAYBACK_STREAM_MOVED ? c->playback_streams : c->record_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -557,7 +557,7 @@ void pa_command_stream_buffer_attr(pa_pdispatch *pd, uint32_t command, uint32_t
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(command == PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED ? c->playback_streams : c->record_streams, channel)))
+    if (!(s = pa_hashmap_get(command == PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED ? c->playback_streams : c->record_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -609,7 +609,7 @@ void pa_command_stream_suspended(pa_pdispatch *pd, uint32_t command, uint32_t ta
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(command == PA_COMMAND_PLAYBACK_STREAM_SUSPENDED ? c->playback_streams : c->record_streams, channel)))
+    if (!(s = pa_hashmap_get(command == PA_COMMAND_PLAYBACK_STREAM_SUSPENDED ? c->playback_streams : c->record_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -651,7 +651,7 @@ void pa_command_stream_started(pa_pdispatch *pd, uint32_t command, uint32_t tag,
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(c->playback_streams, channel)))
+    if (!(s = pa_hashmap_get(c->playback_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -697,7 +697,7 @@ void pa_command_stream_event(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(command == PA_COMMAND_PLAYBACK_STREAM_EVENT ? c->playback_streams : c->record_streams, channel)))
+    if (!(s = pa_hashmap_get(command == PA_COMMAND_PLAYBACK_STREAM_EVENT ? c->playback_streams : c->record_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -733,7 +733,7 @@ void pa_command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tag
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(c->playback_streams, channel)))
+    if (!(s = pa_hashmap_get(c->playback_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -767,7 +767,7 @@ void pa_command_overflow_or_underflow(pa_pdispatch *pd, uint32_t command, uint32
         goto finish;
     }
 
-    if (!(s = pa_dynarray_get(c->playback_streams, channel)))
+    if (!(s = pa_hashmap_get(c->playback_streams, PA_UINT32_TO_PTR(channel))))
         goto finish;
 
     if (s->state != PA_STREAM_READY)
@@ -997,7 +997,7 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag,
     }
 
     s->channel_valid = TRUE;
-    pa_dynarray_put((s->direction == PA_STREAM_RECORD) ? s->context->record_streams : s->context->playback_streams, s->channel, s);
+    pa_hashmap_put((s->direction == PA_STREAM_RECORD) ? s->context->record_streams : s->context->playback_streams, PA_UINT32_TO_PTR(s->channel), s);
 
     create_stream_complete(s);
 

commit 7b1b68ce2cfbc735065f1af45811f33a8a6bf6ea
Author: Tanu Kaskinen <ext-tanu.kaskinen at nokia.com>
Date:   Thu Dec 3 15:28:36 2009 +0200

    dbus: Handle the cases when a non-existing interface is detected in an incoming message.

diff --git a/src/pulsecore/protocol-dbus.c b/src/pulsecore/protocol-dbus.c
index e427bb1..95518a1 100644
--- a/src/pulsecore/protocol-dbus.c
+++ b/src/pulsecore/protocol-dbus.c
@@ -552,10 +552,18 @@ static DBusHandlerResult handle_message_cb(DBusConnection *connection, DBusMessa
             pa_dbus_send_error(connection, message, DBUS_ERROR_UNKNOWN_METHOD, "No such method: %s", call_info.method);
             break;
 
+        case NO_SUCH_INTERFACE:
+            pa_dbus_send_error(connection, message, PA_DBUS_ERROR_NO_SUCH_INTERFACE, "No such interface: %s", call_info.interface);
+            break;
+
         case NO_SUCH_PROPERTY:
             pa_dbus_send_error(connection, message, PA_DBUS_ERROR_NO_SUCH_PROPERTY, "No such property: %s", call_info.property);
             break;
 
+        case NO_SUCH_PROPERTY_INTERFACE:
+            pa_dbus_send_error(connection, message, PA_DBUS_ERROR_NO_SUCH_INTERFACE, "No such property interface: %s", call_info.property_interface);
+            break;
+
         case INVALID_METHOD_SIG:
             pa_dbus_send_error(connection, message, DBUS_ERROR_INVALID_ARGS,
                                "Invalid signature for method %s: '%s'. Expected '%s'.",
diff --git a/src/pulsecore/protocol-dbus.h b/src/pulsecore/protocol-dbus.h
index 6d100f7..8999933 100644
--- a/src/pulsecore/protocol-dbus.h
+++ b/src/pulsecore/protocol-dbus.h
@@ -35,6 +35,7 @@
 #define PA_DBUS_CORE_INTERFACE "org.PulseAudio.Core1"
 #define PA_DBUS_CORE_OBJECT_PATH "/org/pulseaudio/core1"
 
+#define PA_DBUS_ERROR_NO_SUCH_INTERFACE PA_DBUS_CORE_INTERFACE ".NoSuchInterfaceError"
 #define PA_DBUS_ERROR_NO_SUCH_PROPERTY PA_DBUS_CORE_INTERFACE ".NoSuchPropertyError"
 #define PA_DBUS_ERROR_NOT_FOUND PA_DBUS_CORE_INTERFACE ".NotFoundError"
 

commit e785f728a54b5dc4ad25373b262d35babe8221f6
Author: Tanu Kaskinen <ext-tanu.kaskinen at nokia.com>
Date:   Thu Dec 3 15:30:01 2009 +0200

    dbus: Add a missing break statement in handle_message_cb().

diff --git a/src/pulsecore/protocol-dbus.c b/src/pulsecore/protocol-dbus.c
index 95518a1..582bc65 100644
--- a/src/pulsecore/protocol-dbus.c
+++ b/src/pulsecore/protocol-dbus.c
@@ -574,6 +574,7 @@ static DBusHandlerResult handle_message_cb(DBusConnection *connection, DBusMessa
             pa_dbus_send_error(connection, message, DBUS_ERROR_INVALID_ARGS,
                                "Invalid signature for property %s: '%s'. Expected '%s'.",
                                call_info.property, call_info.property_sig, call_info.expected_property_sig);
+            break;
 
         default:
             pa_assert_not_reached();

commit a6b7ac68268e55ec8b4ee7fa9e930b86e17fae85
Author: Tanu Kaskinen <ext-tanu.kaskinen at nokia.com>
Date:   Thu Dec 3 15:31:11 2009 +0200

    stream-restore: Fix a few assertion misuses with the D-Bus code.

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 02c312e..ce92362 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -647,7 +647,7 @@ static void handle_add_entry(DBusConnection *conn, DBusMessage *msg, void *userd
 
     } else {
         dbus_entry = dbus_entry_new(u, name);
-        pa_assert(pa_hashmap_put(u->dbus_entries, dbus_entry->entry_name, dbus_entry) >= 0);
+        pa_assert_se(pa_hashmap_put(u->dbus_entries, dbus_entry->entry_name, dbus_entry) == 0);
 
         e->muted_valid = TRUE;
         e->volume_valid = !!map.channels;
@@ -1245,10 +1245,10 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
 #ifdef HAVE_DBUS
     if (created_new_entry) {
         de = dbus_entry_new(u, name);
-        pa_hashmap_put(u->dbus_entries, de->entry_name, de);
+        pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de) == 0);
         send_new_entry_signal(de);
     } else {
-        pa_assert((de = pa_hashmap_get(u->dbus_entries, name)));
+        pa_assert_se(de = pa_hashmap_get(u->dbus_entries, name));
 
         if (device_updated)
             send_device_updated_signal(de, &entry);
@@ -1859,7 +1859,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
 
                     } else {
                         de = dbus_entry_new(u, name);
-                        pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de));
+                        pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de) == 0);
                         send_new_entry_signal(de);
                     }
 #endif
@@ -2050,7 +2050,7 @@ int pa__init(pa_module*m) {
         pa_datum_free(&key);
 
         de = dbus_entry_new(u, name);
-        pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de) >= 0);
+        pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de) == 0);
 
         pa_xfree(name);
 

commit 00debf42437402dadbe5f0a5ff284582c4399aec
Author: Tanu Kaskinen <ext-tanu.kaskinen at nokia.com>
Date:   Thu Dec 3 15:32:23 2009 +0200

    stream-restore: Add a missing pa_xnew0() call in handle_add_entry().

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index ce92362..a1273fe 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -649,6 +649,7 @@ static void handle_add_entry(DBusConnection *conn, DBusMessage *msg, void *userd
         dbus_entry = dbus_entry_new(u, name);
         pa_assert_se(pa_hashmap_put(u->dbus_entries, dbus_entry->entry_name, dbus_entry) == 0);
 
+        e = pa_xnew0(struct entry, 1);
         e->muted_valid = TRUE;
         e->volume_valid = !!map.channels;
         e->device_valid = !!device[0];

commit f42022a7d3157a3f3346b49c749d2262abea34c4
Author: Tanu Kaskinen <ext-tanu.kaskinen at nokia.com>
Date:   Thu Dec 3 15:34:26 2009 +0200

    stream-restore: At startup, create dbus entries only for valid database entries.

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index a1273fe..becdb54 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -2044,14 +2044,19 @@ int pa__init(pa_module*m) {
         pa_datum next_key;
         char *name;
         struct dbus_entry *de;
+        struct entry *e;
 
         done = !pa_database_next(u->database, &key, &next_key, NULL);
 
         name = pa_xstrndup(key.data, key.size);
         pa_datum_free(&key);
 
-        de = dbus_entry_new(u, name);
-        pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de) == 0);
+        /* Use read_entry() for checking that the entry is valid. */
+        if ((e = read_entry(u, name))) {
+            de = dbus_entry_new(u, name);
+            pa_assert_se(pa_hashmap_put(u->dbus_entries, de->entry_name, de) == 0);
+            pa_xfree(e);
+        }
 
         pa_xfree(name);
 

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list