[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.11-35-g04ffac5

Lennart Poettering gitmailer-noreply at 0pointer.de
Sun Aug 3 09:56:16 PDT 2008


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  98fbd24d62bfe1fbbf8aaf7adb367e44da66fcd8 (commit)

- Log -----------------------------------------------------------------
04ffac5... add extension system for native protocol
9bfd67f... store load_once flag for module
114f290... add a new error code PA_ERR_NOEXTENSION
23bde22... start idle timer even when no module is ever loaded
f417bb4... some pa_bool_t'ization
-----------------------------------------------------------------------

Summary of changes:
 PROTOCOL                        |    8 ++++-
 configure.ac                    |    2 +-
 src/pulse/def.h                 |    1 +
 src/pulse/error.c               |    5 ++-
 src/pulsecore/core.c            |    2 +
 src/pulsecore/module.c          |    5 ++-
 src/pulsecore/module.h          |    8 +++--
 src/pulsecore/native-common.h   |    6 ++-
 src/pulsecore/protocol-native.c |   69 +++++++++++++++++++++++++++++++-------
 src/pulsecore/protocol-native.h |    8 +++--
 src/pulsecore/random.c          |   13 ++++---
 11 files changed, 97 insertions(+), 30 deletions(-)

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

commit f417bb42cf68920c5679a39296fca1c48864d7cb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 3 17:00:52 2008 +0200

    some pa_bool_t'ization

diff --git a/src/pulsecore/random.c b/src/pulsecore/random.c
index da38106..518c281 100644
--- a/src/pulsecore/random.c
+++ b/src/pulsecore/random.c
@@ -37,7 +37,7 @@
 
 #include "random.h"
 
-static int has_whined = 0;
+static pa_bool_t has_whined = TRUE;
 
 static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
 
@@ -89,9 +89,11 @@ void pa_random_seed(void) {
     unsigned int seed;
 
     if (random_proper(&seed, sizeof(unsigned int)) < 0) {
-        if (!has_whined)
+
+        if (!has_whined) {
             pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
-        has_whined = 1;
+            has_whined = TRUE;
+        }
 
         seed = (unsigned int) time(NULL);
     }
@@ -109,9 +111,10 @@ void pa_random(void *ret_data, size_t length) {
     if (random_proper(ret_data, length) >= 0)
         return;
 
-    if (!has_whined)
+    if (!has_whined) {
         pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG.");
-    has_whined = 1;
+        has_whined = TRUE;
+    }
 
     for (p = ret_data, l = length; l > 0; p++, l--)
         *p = (uint8_t) rand();

commit 23bde22b1002b8900bb712fe30ffc30ec2deff93
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 3 18:53:43 2008 +0200

    start idle timer even when no module is ever loaded

diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index 1907fca..aa8de8d 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -149,6 +149,8 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
     pa_check_signal_is_blocked(SIGPIPE);
 #endif
 
+    pa_core_check_quit(c);
+
     return c;
 }
 

commit 114f290be73889a92e8f0a248a3fde1fd09c2dc9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 3 18:54:55 2008 +0200

    add a new error code PA_ERR_NOEXTENSION

diff --git a/src/pulse/def.h b/src/pulse/def.h
index 9507197..aa07d1c 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -352,6 +352,7 @@ enum {
     PA_ERR_TOOLARGE,               /**< Data too large */
     PA_ERR_NOTSUPPORTED,           /**< Operation not supported \since 0.9.5 */
     PA_ERR_UNKNOWN,                /**< The error code was unknown to the client */
+    PA_ERR_NOEXTENSION,            /**< Extension does not exist. \since 0.9.12 */
     PA_ERR_MAX                     /**< Not really an error but the first invalid error code */
 };
 
diff --git a/src/pulse/error.c b/src/pulse/error.c
index 29690c8..50bbf70 100644
--- a/src/pulse/error.c
+++ b/src/pulse/error.c
@@ -57,7 +57,10 @@ const char*pa_strerror(int error) {
         [PA_ERR_BADSTATE] = "Bad state",
         [PA_ERR_NODATA] = "No data",
         [PA_ERR_VERSION] = "Incompatible protocol version",
-        [PA_ERR_TOOLARGE] = "Too large"
+        [PA_ERR_TOOLARGE] = "Too large",
+        [PA_ERR_NOTSUPPORTED] = "Not supported",
+        [PA_ERR_UNKNOWN] = "Unknown error code",
+        [PA_ERR_NOEXTENSION] = "No such extension"
     };
 
     if (error < 0 || error >= PA_ERR_MAX)

commit 9bfd67f70f31b5b84dea5e16e7b43ab939d94f6b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 3 18:55:42 2008 +0200

    store load_once flag for module

diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index e003dd7..edd0b0a 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -76,6 +76,7 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
     m = pa_xnew(pa_module, 1);
     m->name = pa_xstrdup(name);
     m->argument = pa_xstrdup(argument);
+    m->load_once = FALSE;
 
     if (!(m->dl = lt_dlopenext(name))) {
         pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
@@ -84,7 +85,9 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
 
     if ((load_once = (pa_bool_t (*)(void)) pa_load_sym(m->dl, name, PA_SYMBOL_LOAD_ONCE))) {
 
-        if (load_once() && c->modules) {
+        m->load_once = load_once();
+
+        if (m->load_once && c->modules) {
             pa_module *i;
             uint32_t idx;
             /* OK, the module only wants to be loaded once, let's make sure it is */
diff --git a/src/pulsecore/module.h b/src/pulsecore/module.h
index ec582f2..bb3a3f5 100644
--- a/src/pulsecore/module.h
+++ b/src/pulsecore/module.h
@@ -43,10 +43,12 @@ struct pa_module {
     void *userdata;
 
     int n_used;
-    pa_bool_t auto_unload;
-    time_t last_used_time;
 
-    pa_bool_t unload_requested;
+    pa_bool_t auto_unload:1;
+    pa_bool_t load_once:1;
+    pa_bool_t unload_requested:1;
+
+    time_t last_used_time;
 };
 
 pa_module* pa_module_load(pa_core *c, const char *name, const char*argument);

commit 04ffac57a67eee9640f248b6fab33ee8367b0eab
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 3 18:56:10 2008 +0200

    add extension system for native protocol

diff --git a/PROTOCOL b/PROTOCOL
index 4439c71..4885b3d 100644
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -79,7 +79,7 @@ New opcodes for notifications:
  PA_COMMAND_PLAYBACK_STREAM_MOVED
  PA_COMMAND_CAPTURE_STREAM_MOVED
 
-### v13, implemented  by >= 0.9.11
+### v13, implemented by >= 0.9.11
 
 New fields for PA_COMMAND_CREATE_PLAYBACK_STREAM, PA_COMMAND_CREATE_RECORD_STREAM request at the end:
 
@@ -134,3 +134,9 @@ PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR at the end:
 new message:
 
   PA_COMMAND_STARTED
+
+### v14, implemented by >= 0.9.12
+
+new message:
+
+  PA_COMMAND_EXTENSION
diff --git a/configure.ac b/configure.ac
index 2ea4d89..ac3090c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,7 +35,7 @@ AC_SUBST(PA_MAJORMINOR, "PA_MAJOR.PA_MINOR")
 AC_SUBST(PACKAGE_URL, [http://pulseaudio.org/])
 
 AC_SUBST(PA_API_VERSION, 12)
-AC_SUBST(PA_PROTOCOL_VERSION, 13)
+AC_SUBST(PA_PROTOCOL_VERSION, 14)
 
 # The stable ABI for client applications, for the version info x:y:z
 # always will hold y=z
diff --git a/src/pulsecore/native-common.h b/src/pulsecore/native-common.h
index 809d6c7..8138b7a 100644
--- a/src/pulsecore/native-common.h
+++ b/src/pulsecore/native-common.h
@@ -137,7 +137,7 @@ enum {
     PA_COMMAND_PLAYBACK_STREAM_MOVED,
     PA_COMMAND_RECORD_STREAM_MOVED,
 
-    /* Supported since protocol v13 (0.9.10) */
+    /* Supported since protocol v13 (0.9.11) */
     PA_COMMAND_UPDATE_RECORD_STREAM_PROPLIST,
     PA_COMMAND_UPDATE_PLAYBACK_STREAM_PROPLIST,
     PA_COMMAND_UPDATE_CLIENT_PROPLIST,
@@ -148,6 +148,9 @@ enum {
     /* SERVER->CLIENT */
     PA_COMMAND_STARTED,
 
+    /* Supported since protocol v14 (0.9.12) */
+    PA_COMMAND_EXTENSION,
+
     PA_COMMAND_MAX
 };
 
@@ -161,7 +164,6 @@ enum {
 
 #define PA_NATIVE_DEFAULT_UNIX_SOCKET "native"
 
-
 PA_C_DECL_END
 
 #endif
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 39a258f..ef56a6f 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -173,7 +173,7 @@ struct pa_native_protocol {
     pa_strlist *servers;
     pa_hook servers_changed;
 
-    /*     pa_hashmap *extensions; */
+    pa_hashmap *extensions;
 
 };
 
@@ -263,6 +263,7 @@ static void command_set_stream_buffer_attr(pa_pdispatch *pd, uint32_t command, u
 static void command_update_stream_sample_rate(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
 static void command_update_proplist(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
 static void command_remove_proplist(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
 
 static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
     [PA_COMMAND_ERROR] = NULL,
@@ -353,6 +354,8 @@ static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
     [PA_COMMAND_REMOVE_RECORD_STREAM_PROPLIST] = command_remove_proplist,
     [PA_COMMAND_REMOVE_PLAYBACK_STREAM_PROPLIST] = command_remove_proplist,
     [PA_COMMAND_REMOVE_CLIENT_PROPLIST] = command_remove_proplist,
+
+    [PA_COMMAND_EXTENSION] = command_extension
 };
 
 /* structure management */
@@ -3837,6 +3840,43 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa
     pa_pstream_send_simple_ack(c->pstream, tag);
 }
 
+static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    connection *c = CONNECTION(userdata);
+    uint32_t idx = PA_INVALID_INDEX;
+    const char *name = NULL;
+    pa_module *m;
+    pa_native_protocol_ext_cb_t cb;
+
+    connection_assert_ref(c);
+    pa_assert(t);
+
+    if (pa_tagstruct_getu32(t, &idx) < 0 ||
+        pa_tagstruct_gets(t, &name) < 0) {
+        protocol_error(c);
+        return;
+    }
+
+    CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
+    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || !name || !*name || pa_utf8_valid(name), tag, PA_ERR_INVALID);
+
+    if (idx != PA_INVALID_INDEX)
+        m = pa_idxset_get_by_index(c->protocol->core->modules, idx);
+    else {
+        for (m = pa_idxset_first(c->protocol->core->modules, &idx); m; m = pa_idxset_next(c->protocol->core->modules, &idx))
+            if (strcmp(name, m->name) == 0)
+                break;
+    }
+
+    CHECK_VALIDITY(c->pstream, m, tag, PA_ERR_NOEXTENSION);
+    CHECK_VALIDITY(c->pstream, m->load_once || idx != PA_INVALID_INDEX, tag, PA_ERR_INVALID);
+
+    cb = (pa_native_protocol_ext_cb_t) pa_hashmap_get(c->protocol->extensions, m);
+    CHECK_VALIDITY(c->pstream, m, tag, PA_ERR_NOEXTENSION);
+
+    cb(c->protocol, m, c->pstream, tag, t);
+}
+
+
 /*** pstream callbacks ***/
 
 static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, const pa_creds *creds, void *userdata) {
@@ -4152,21 +4192,24 @@ pa_strlist *pa_native_protocol_servers(pa_native_protocol *p) {
     return p->servers;
 }
 
-/* int pa_native_protocol_install_extension(pa_native_protocol *p, pa_module *m, pa_native_protocol_extension_cb_t cb) { */
-/*     pa_assert(p); */
-/*     pa_assert(PA_REFCNT_VALUE(p) >= 1); */
-/*     pa_assert(m); */
-/*     pa_assert(cb); */
-
+int pa_native_protocol_install_ext(pa_native_protocol *p, pa_module *m, pa_native_protocol_ext_cb_t cb) {
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) >= 1);
+    pa_assert(m);
+    pa_assert(cb);
+    pa_assert(!pa_hashmap_get(p->extensions, m));
 
-/* } */
+    pa_assert_se(pa_hashmap_put(p->extensions, m, (void*) cb) == 0);
+    return 0;
+}
 
-/* void pa_native_protocol_remove_extension(pa_native_protocol *p, pa_module *m) { */
-/*     pa_assert(p); */
-/*     pa_assert(PA_REFCNT_VALUE(p) >= 1); */
-/*     pa_assert(m); */
+void pa_native_protocol_remove_ext(pa_native_protocol *p, pa_module *m) {
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) >= 1);
+    pa_assert(m);
 
-/* } */
+    pa_assert_se(pa_hashmap_remove(p->extensions, m));
+}
 
 pa_native_options* pa_native_options_new(void) {
     pa_native_options *o;
diff --git a/src/pulsecore/protocol-native.h b/src/pulsecore/protocol-native.h
index 7f0ef25..b3db305 100644
--- a/src/pulsecore/protocol-native.h
+++ b/src/pulsecore/protocol-native.h
@@ -31,6 +31,8 @@
 #include <pulsecore/modargs.h>
 #include <pulsecore/strlist.h>
 #include <pulsecore/hook-list.h>
+#include <pulsecore/pstream.h>
+#include <pulsecore/tagstruct.h>
 
 typedef struct pa_native_protocol pa_native_protocol;
 
@@ -58,9 +60,9 @@ void pa_native_protocol_remove_server_string(pa_native_protocol *p, const char *
 pa_hook *pa_native_protocol_servers_changed(pa_native_protocol *p);
 pa_strlist *pa_native_protocol_servers(pa_native_protocol *p);
 
-/* typedef void (*pa_native_protocol_extension_cb_t)(pa_native_protocol *p, pa_module *m, pa_pstream *p, uint32_t tag, pa_tagstruct *t); */
-/* int pa_native_protocol_install_extension(pa_native_protocol *p, pa_module *m, pa_native_protocol_extension_cb_t cb); */
-/* void pa_native_protocol_remove_extension(pa_native_protocol *p, pa_module *m); */
+typedef void (*pa_native_protocol_ext_cb_t)(pa_native_protocol *p, pa_module *m, pa_pstream *ps, uint32_t tag, pa_tagstruct *t);
+int pa_native_protocol_install_ext(pa_native_protocol *p, pa_module *m, pa_native_protocol_ext_cb_t cb);
+void pa_native_protocol_remove_ext(pa_native_protocol *p, pa_module *m);
 
 pa_native_options* pa_native_options_new(void);
 pa_native_options* pa_native_options_ref(pa_native_options *o);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list