summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PROTOCOL8
-rw-r--r--configure.ac2
-rw-r--r--src/pulsecore/native-common.h6
-rw-r--r--src/pulsecore/protocol-native.c69
-rw-r--r--src/pulsecore/protocol-native.h8
5 files changed, 73 insertions, 20 deletions
diff --git a/PROTOCOL b/PROTOCOL
index 4439c713..4885b3d1 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 2ea4d893..ac3090c3 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 809d6c75..8138b7a4 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 39a258f9..ef56a6f4 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 7f0ef258..b3db305c 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);