Merge commit 'elmarco/master'

This commit is contained in:
Lennart Poettering 2009-01-14 00:22:27 +01:00
commit f3101133d7
9 changed files with 163 additions and 6 deletions

View file

@ -428,7 +428,7 @@ typedef enum pa_subscription_event_type {
PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U, PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
/**< An object was removed */ /**< 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 */ /**< A mask to extract the event operation from an event value */
} pa_subscription_event_type_t; } pa_subscription_event_type_t;

View file

@ -359,7 +359,7 @@ pa_proplist *pa_proplist_from_string(const char *str) {
} }
blob = pa_xmalloc((size_t)(e-v)/2); 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_log("Invalid \"hex:\" value data");
pa_xfree(blob); pa_xfree(blob);
break; break;

View file

@ -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_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_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_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 */ /* 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-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}, { "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-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-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}, { "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}, { "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_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; return 0;
} }

View file

@ -27,6 +27,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#ifdef HAVE_SYS_RESOURCE_H #ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h> #include <sys/resource.h>

View file

@ -859,6 +859,21 @@ pa_bool_t pa_sink_input_get_mute(pa_sink_input *i) {
return i->muted; 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 */ /* Called from main context */
void pa_sink_input_cork(pa_sink_input *i, pa_bool_t b) { void pa_sink_input_cork(pa_sink_input *i, pa_bool_t b) {
pa_sink_input_assert_ref(i); pa_sink_input_assert_ref(i);

View file

@ -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); 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); 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_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); pa_resample_method_t pa_sink_input_get_resample_method(pa_sink_input *i);

View file

@ -953,6 +953,7 @@ pa_bool_t pa_sink_get_mute(pa_sink *s, pa_bool_t force_refresh) {
return s->muted; 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_bool_t pa_sink_update_proplist(pa_sink *s, pa_update_mode_t mode, pa_proplist *p) {
pa_sink_assert_ref(s); pa_sink_assert_ref(s);

View file

@ -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 */ /* Called from main context */
pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o) { pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o) {
pa_source_output_assert_ref(o); pa_source_output_assert_ref(o);

View file

@ -209,11 +209,11 @@ pa_source_output* pa_source_output_new(
void pa_source_output_put(pa_source_output *o); void pa_source_output_put(pa_source_output *o);
void pa_source_output_unlink(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); 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 */ /* External code may request disconnection with this funcion */
void pa_source_output_kill(pa_source_output*o); 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); pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o);