summaryrefslogtreecommitdiffstats
path: root/polyp/protocol-native.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-09-06 21:55:09 +0000
committerLennart Poettering <lennart@poettering.net>2004-09-06 21:55:09 +0000
commit0fa499db56dc9111ddd866080606cb8b0379280e (patch)
tree013d82760d80a0c32c7b709985dcb8820504d27d /polyp/protocol-native.c
parent3536be420cf9ec6f4f8fbe1dc60b2da0cefba86c (diff)
add support for setting/getting default sink/source via native protocol
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@182 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/protocol-native.c')
-rw-r--r--polyp/protocol-native.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/polyp/protocol-native.c b/polyp/protocol-native.c
index 1ec1b608..3d6114cf 100644
--- a/polyp/protocol-native.c
+++ b/polyp/protocol-native.c
@@ -138,6 +138,7 @@ static void command_subscribe(struct pa_pdispatch *pd, uint32_t command, uint32_
static void command_set_volume(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
static void command_cork_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
static void command_flush_or_trigger_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
+static void command_set_default_sink_or_source(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
static const struct pa_pdispatch_command command_table[PA_COMMAND_MAX] = {
[PA_COMMAND_ERROR] = { NULL },
@@ -182,6 +183,8 @@ static const struct pa_pdispatch_command command_table[PA_COMMAND_MAX] = {
[PA_COMMAND_CORK_PLAYBACK_STREAM] = { command_cork_playback_stream },
[PA_COMMAND_FLUSH_PLAYBACK_STREAM] = { command_flush_or_trigger_playback_stream },
[PA_COMMAND_TRIGGER_PLAYBACK_STREAM] = { command_flush_or_trigger_playback_stream },
+ [PA_COMMAND_SET_DEFAULT_SINK] = { command_set_default_sink_or_source },
+ [PA_COMMAND_SET_DEFAULT_SOURCE] = { command_set_default_sink_or_source },
};
/* structure management */
@@ -1221,6 +1224,8 @@ static void command_get_server_info(struct pa_pdispatch *pd, uint32_t command, u
pa_tagstruct_puts(reply, pa_get_user_name(txt, sizeof(txt)));
pa_tagstruct_puts(reply, pa_get_host_name(txt, sizeof(txt)));
pa_tagstruct_put_sample_spec(reply, &c->protocol->core->default_sample_spec);
+ pa_tagstruct_puts(reply, c->protocol->core->default_sink_name ? c->protocol->core->default_sink_name : "");
+ pa_tagstruct_puts(reply, c->protocol->core->default_source_name ? c->protocol->core->default_source_name : "");
pa_pstream_send_tagstruct(c->pstream, reply);
}
@@ -1373,6 +1378,28 @@ static void command_flush_or_trigger_playback_stream(struct pa_pdispatch *pd, ui
request_bytes(s);
}
+static void command_set_default_sink_or_source(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+ struct connection *c = userdata;
+ uint32_t index;
+ const char *s;
+ assert(c && t);
+
+ if (pa_tagstruct_getu32(t, &index) < 0 ||
+ pa_tagstruct_gets(t, &s) < 0 ||
+ !pa_tagstruct_eof(t)) {
+ protocol_error(c);
+ return;
+ }
+
+ if (!c->authorized) {
+ pa_pstream_send_error(c->pstream, tag, PA_ERROR_ACCESS);
+ return;
+ }
+
+ pa_namereg_set_default(c->protocol->core, s, command == PA_COMMAND_SET_DEFAULT_SOURCE ? PA_NAMEREG_SOURCE : PA_NAMEREG_SINK);
+ pa_pstream_send_simple_ack(c->pstream, tag);
+}
+
/*** pstream callbacks ***/
static void pstream_packet_callback(struct pa_pstream *p, struct pa_packet *packet, void *userdata) {