summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-14 00:22:27 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-14 00:22:27 +0100
commitf3101133d7c1dec9f4e79c9f3508c692c6b6b682 (patch)
treedf7a5856ecae8fc09c228f06b4405fa1323dd2b2 /src
parentab9736421013d6eb7ccac1a6cce57a33fcf2c599 (diff)
parent09641cc707b0cf45368fa9e61ca8607483b4989f (diff)
Merge commit 'elmarco/master'
Diffstat (limited to 'src')
-rw-r--r--src/pulse/def.h2
-rw-r--r--src/pulse/proplist.c2
-rw-r--r--src/pulsecore/cli-command.c122
-rw-r--r--src/pulsecore/core-util.h1
-rw-r--r--src/pulsecore/sink-input.c15
-rw-r--r--src/pulsecore/sink-input.h1
-rw-r--r--src/pulsecore/sink.c1
-rw-r--r--src/pulsecore/source-output.c15
-rw-r--r--src/pulsecore/source-output.h10
9 files changed, 163 insertions, 6 deletions
diff --git a/src/pulse/def.h b/src/pulse/def.h
index ace56574..7a715b66 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -428,7 +428,7 @@ typedef enum pa_subscription_event_type {
PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
/**< An object was removed */
- PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U,
+ PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U
/**< A mask to extract the event operation from an event value */
} pa_subscription_event_type_t;
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index eec9d310..60a92d44 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -359,7 +359,7 @@ pa_proplist *pa_proplist_from_string(const char *str) {
}
blob = pa_xmalloc((size_t)(e-v)/2);
- if (pa_parsehex(v, blob, (e-v)/2) != ((e-v)/2)) {
+ if (pa_parsehex(v, blob, (e-v)/2) != (size_t)((e-v)/2)) {
pa_log("Invalid \"hex:\" value data");
pa_xfree(blob);
break;
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index 3cb2a14e..07d55d07 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -122,6 +122,9 @@ static int pa_cli_command_log_meta(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
static int pa_cli_command_log_time(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
static int pa_cli_command_log_backtrace(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
static int pa_cli_command_update_sink_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_update_source_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_update_sink_input_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_update_source_output_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
/* A method table for all available commands */
@@ -148,6 +151,9 @@ static const struct command commands[] = {
{ "set-sink-input-mute", pa_cli_command_sink_input_mute, "Set the mute switch of a sink input (args: index, bool)", 3},
{ "set-source-mute", pa_cli_command_source_mute, "Set the mute switch of a source (args: index|name, bool)", 3},
{ "update-sink-proplist", pa_cli_command_update_sink_proplist, "Update the properties of a sink (args: index|name, properties)", 3},
+ { "update-source-proplist", pa_cli_command_update_source_proplist, "Update the properties of a source (args: index|name, properties)", 3},
+ { "update-sink-input-proplist", pa_cli_command_update_sink_input_proplist, "Update the properties of a sink input (args: index, properties)", 3},
+ { "update-source-output-proplist", pa_cli_command_update_source_output_proplist, "Update the properties of a source_output (args: index, properties)", 3},
{ "set-default-sink", pa_cli_command_sink_default, "Set the default sink (args: index|name)", 2},
{ "set-default-source", pa_cli_command_source_default, "Set the default source (args: index|name)", 2},
{ "kill-client", pa_cli_command_kill_client, "Kill a client (args: index)", 2},
@@ -681,6 +687,122 @@ static int pa_cli_command_update_sink_proplist(pa_core *c, pa_tokenizer *t, pa_s
pa_sink_update_proplist(sink, PA_UPDATE_REPLACE, p);
+ pa_proplist_free(p);
+
+ return 0;
+}
+
+static int pa_cli_command_update_source_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+ const char *n, *s;
+ pa_source *source;
+ pa_proplist *p;
+
+ pa_core_assert_ref(c);
+ pa_assert(t);
+ pa_assert(buf);
+ pa_assert(fail);
+
+ if (!(n = pa_tokenizer_get(t, 1))) {
+ pa_strbuf_puts(buf, "You need to specify a source either by its name or its index.\n");
+ return -1;
+ }
+
+ if (!(s = pa_tokenizer_get(t, 2))) {
+ pa_strbuf_puts(buf, "You need to specify a \"key=value\" argument.\n");
+ return -1;
+ }
+
+ if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE, 1))) {
+ pa_strbuf_puts(buf, "No source found by this name or index.\n");
+ return -1;
+ }
+
+ p = pa_proplist_from_string(s);
+
+ pa_source_update_proplist(source, PA_UPDATE_REPLACE, p);
+
+ pa_proplist_free(p);
+
+ return 0;
+}
+
+static int pa_cli_command_update_sink_input_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+ const char *n, *s;
+ pa_sink_input *si;
+ uint32_t idx;
+ pa_proplist *p;
+
+ pa_core_assert_ref(c);
+ pa_assert(t);
+ pa_assert(buf);
+ pa_assert(fail);
+
+ if (!(n = pa_tokenizer_get(t, 1))) {
+ pa_strbuf_puts(buf, "You need to specify a sink input either by index.\n");
+ return -1;
+ }
+
+ if ((idx = parse_index(n)) == PA_IDXSET_INVALID) {
+ pa_strbuf_puts(buf, "Failed to parse index.\n");
+ return -1;
+ }
+
+ if (!(s = pa_tokenizer_get(t, 2))) {
+ pa_strbuf_puts(buf, "You need to specify a \"key=value\" argument.\n");
+ return -1;
+ }
+
+ if (!(si = pa_idxset_get_by_index(c->sink_inputs, (uint32_t) idx))) {
+ pa_strbuf_puts(buf, "No sink input found with this index.\n");
+ return -1;
+ }
+
+ p = pa_proplist_from_string(s);
+
+ pa_sink_input_update_proplist(si, PA_UPDATE_REPLACE, p);
+
+ pa_proplist_free(p);
+
+ return 0;
+}
+
+static int pa_cli_command_update_source_output_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+ const char *n, *s;
+ pa_source_output *so;
+ uint32_t idx;
+ pa_proplist *p;
+
+ pa_core_assert_ref(c);
+ pa_assert(t);
+ pa_assert(buf);
+ pa_assert(fail);
+
+ if (!(n = pa_tokenizer_get(t, 1))) {
+ pa_strbuf_puts(buf, "You need to specify a source output by its index.\n");
+ return -1;
+ }
+
+ if ((idx = parse_index(n)) == PA_IDXSET_INVALID) {
+ pa_strbuf_puts(buf, "Failed to parse index.\n");
+ return -1;
+ }
+
+ if (!(s = pa_tokenizer_get(t, 2))) {
+ pa_strbuf_puts(buf, "You need to specify a \"key=value\" argument.\n");
+ return -1;
+ }
+
+ if (!(so = pa_idxset_get_by_index(c->source_outputs, (uint32_t) idx))) {
+ pa_strbuf_puts(buf, "No source output found with this index.\n");
+ return -1;
+ }
+
+ p = pa_proplist_from_string(s);
+
+ pa_source_output_update_proplist(so, PA_UPDATE_REPLACE, p);
+
+ pa_proplist_free(p);
+
return 0;
}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index d9fad11e..167d0735 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -27,6 +27,7 @@
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
+#include <string.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index d25cd797..33490cc6 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -859,6 +859,21 @@ pa_bool_t pa_sink_input_get_mute(pa_sink_input *i) {
return i->muted;
}
+/* Called from main thread */
+pa_bool_t pa_sink_input_update_proplist(pa_sink_input *i, pa_update_mode_t mode, pa_proplist *p) {
+
+ pa_sink_input_assert_ref(i);
+
+ pa_proplist_update(i->proplist, mode, p);
+
+ if (PA_SINK_IS_LINKED(i->state)) {
+ pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED], i);
+ pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
+ }
+
+ return TRUE;
+}
+
/* Called from main context */
void pa_sink_input_cork(pa_sink_input *i, pa_bool_t b) {
pa_sink_input_assert_ref(i);
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index 27125988..8cfe32bc 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -294,6 +294,7 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume);
const pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i);
void pa_sink_input_set_mute(pa_sink_input *i, pa_bool_t mute);
pa_bool_t pa_sink_input_get_mute(pa_sink_input *i);
+pa_bool_t pa_sink_input_update_proplist(pa_sink_input *i, pa_update_mode_t mode, pa_proplist *p);
pa_resample_method_t pa_sink_input_get_resample_method(pa_sink_input *i);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d5082d53..48c8f794 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -953,6 +953,7 @@ pa_bool_t pa_sink_get_mute(pa_sink *s, pa_bool_t force_refresh) {
return s->muted;
}
+/* Called from main thread */
pa_bool_t pa_sink_update_proplist(pa_sink *s, pa_update_mode_t mode, pa_proplist *p) {
pa_sink_assert_ref(s);
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index c92c5ab7..e3d0d8b2 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -592,6 +592,21 @@ void pa_source_output_set_name(pa_source_output *o, const char *name) {
}
}
+/* Called from main thread */
+pa_bool_t pa_source_output_update_proplist(pa_source_output *o, pa_update_mode_t mode, pa_proplist *p) {
+
+ pa_source_output_assert_ref(o);
+
+ pa_proplist_update(o->proplist, mode, p);
+
+ if (PA_SINK_IS_LINKED(o->state)) {
+ pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED], o);
+ pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE, o->index);
+ }
+
+ return TRUE;
+}
+
/* Called from main context */
pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o) {
pa_source_output_assert_ref(o);
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index f011f9bd..2fdebae0 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -209,11 +209,11 @@ pa_source_output* pa_source_output_new(
void pa_source_output_put(pa_source_output *o);
void pa_source_output_unlink(pa_source_output*o);
-void pa_source_output_set_name(pa_source_output *i, const char *name);
+void pa_source_output_set_name(pa_source_output *o, const char *name);
-pa_usec_t pa_source_output_set_requested_latency(pa_source_output *i, pa_usec_t usec);
+pa_usec_t pa_source_output_set_requested_latency(pa_source_output *o, pa_usec_t usec);
-void pa_source_output_cork(pa_source_output *i, pa_bool_t b);
+void pa_source_output_cork(pa_source_output *o, pa_bool_t b);
int pa_source_output_set_rate(pa_source_output *o, uint32_t rate);
@@ -222,7 +222,9 @@ int pa_source_output_set_rate(pa_source_output *o, uint32_t rate);
/* External code may request disconnection with this funcion */
void pa_source_output_kill(pa_source_output*o);
-pa_usec_t pa_source_output_get_latency(pa_source_output *i, pa_usec_t *source_latency);
+pa_usec_t pa_source_output_get_latency(pa_source_output *o, pa_usec_t *source_latency);
+
+pa_bool_t pa_source_output_update_proplist(pa_source_output *o, pa_update_mode_t mode, pa_proplist *p);
pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o);