From 00797b8b6ea7978f862facb7181fb04895caf23c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 5 Jun 2009 19:05:07 +0200 Subject: core: add a suspend cause flags field --- src/pulsecore/protocol-native.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index d4a9952a..e9e2d601 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -4098,7 +4098,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa pa_log_debug("%s all sinks", b ? "Suspending" : "Resuming"); - if (pa_sink_suspend_all(c->protocol->core, b) < 0) { + if (pa_sink_suspend_all(c->protocol->core, b, PA_SUSPEND_USER) < 0) { pa_pstream_send_error(c->pstream, tag, PA_ERR_INVALID); return; } @@ -4112,7 +4112,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa CHECK_VALIDITY(c->pstream, sink, tag, PA_ERR_NOENTITY); - if (pa_sink_suspend(sink, b) < 0) { + if (pa_sink_suspend(sink, b, PA_SUSPEND_USER) < 0) { pa_pstream_send_error(c->pstream, tag, PA_ERR_INVALID); return; } @@ -4125,7 +4125,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa pa_log_debug("%s all sources", b ? "Suspending" : "Resuming"); - if (pa_source_suspend_all(c->protocol->core, b) < 0) { + if (pa_source_suspend_all(c->protocol->core, b, PA_SUSPEND_USER) < 0) { pa_pstream_send_error(c->pstream, tag, PA_ERR_INVALID); return; } @@ -4140,7 +4140,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa CHECK_VALIDITY(c->pstream, source, tag, PA_ERR_NOENTITY); - if (pa_source_suspend(source, b) < 0) { + if (pa_source_suspend(source, b, PA_SUSPEND_USER) < 0) { pa_pstream_send_error(c->pstream, tag, PA_ERR_INVALID); return; } -- cgit From 31575f7766d6ff39665b64a3a04412eff1c39957 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 03:45:14 +0200 Subject: alsa: rework mixer logic Completely rework mixer logic. This now allows controlling a full set of elements from a single sink's volume slider/mute button. This also introduces sink and source "ports" that can be used to choose different input or output ports with the UI. (i.e. "mic"/"line-in" or "speaker"/"headphones". The mixer paths and device maps are now configered in external configuration files and can be tweaked as necessary. --- src/pulsecore/protocol-native.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index e9e2d601..b27346b2 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3328,9 +3328,9 @@ static void command_set_volume( CHECK_VALIDITY(c->pstream, si || sink || source, tag, PA_ERR_NOENTITY); if (sink) - pa_sink_set_volume(sink, &volume, TRUE, TRUE, TRUE); + pa_sink_set_volume(sink, &volume, TRUE, TRUE, TRUE, TRUE); else if (source) - pa_source_set_volume(source, &volume); + pa_source_set_volume(source, &volume, TRUE); else if (si) pa_sink_input_set_volume(si, &volume, TRUE, TRUE); @@ -3400,9 +3400,9 @@ static void command_set_mute( CHECK_VALIDITY(c->pstream, si || sink || source, tag, PA_ERR_NOENTITY); if (sink) - pa_sink_set_mute(sink, mute); + pa_sink_set_mute(sink, mute, TRUE); else if (source) - pa_source_set_mute(source, mute); + pa_source_set_mute(source, mute, TRUE); else if (si) pa_sink_input_set_mute(si, mute, TRUE); -- cgit From 6d7cf14dbfc6600cea7ae5110af1160b6a6d140e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 04:52:41 +0200 Subject: native: implement command to change sink/source port --- src/pulsecore/protocol-native.c | 67 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index b27346b2..92efc9ee 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -284,6 +284,7 @@ static void command_update_proplist(pa_pdispatch *pd, uint32_t command, uint32_t 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 void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); +static void command_set_sink_or_source_port(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, @@ -380,6 +381,9 @@ static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = { [PA_COMMAND_SET_CARD_PROFILE] = command_set_card_profile, + [PA_COMMAND_SET_SINK_PORT] = command_set_sink_or_source_port, + [PA_COMMAND_SET_SOURCE_PORT] = command_set_sink_or_source_port, + [PA_COMMAND_EXTENSION] = command_extension }; @@ -4195,6 +4199,7 @@ static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_ uint32_t idx = PA_INVALID_INDEX; const char *name = NULL, *profile = NULL; pa_card *card = NULL; + int ret; pa_native_connection_assert_ref(c); pa_assert(t); @@ -4220,11 +4225,69 @@ static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_ CHECK_VALIDITY(c->pstream, card, tag, PA_ERR_NOENTITY); - if (pa_card_set_profile(card, profile, TRUE) < 0) { - pa_pstream_send_error(c->pstream, tag, PA_ERR_INVALID); + if ((ret = pa_card_set_profile(card, profile, TRUE)) < 0) { + pa_pstream_send_error(c->pstream, tag, -ret); + return; + } + + pa_pstream_send_simple_ack(c->pstream, tag); +} + +static void command_set_sink_or_source_port(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { + pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); + uint32_t idx = PA_INVALID_INDEX; + const char *name = NULL, *port = NULL; + int ret; + + pa_native_connection_assert_ref(c); + pa_assert(t); + + if (pa_tagstruct_getu32(t, &idx) < 0 || + pa_tagstruct_gets(t, &name) < 0 || + pa_tagstruct_gets(t, &port) < 0 || + !pa_tagstruct_eof(t)) { + protocol_error(c); return; } + CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS); + CHECK_VALIDITY(c->pstream, !name || pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || name, tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !name, tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, !name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID); + + if (command == PA_COMMAND_SET_SINK_PORT) { + pa_sink *sink; + + if (idx != PA_INVALID_INDEX) + sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx); + else + sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK); + + CHECK_VALIDITY(c->pstream, sink, tag, PA_ERR_NOENTITY); + + if ((ret = pa_sink_set_port(sink, port, TRUE)) < 0) { + pa_pstream_send_error(c->pstream, tag, -ret); + return; + } + } else { + pa_source *source; + + pa_assert(command = PA_COMMAND_SET_SOURCE_PORT); + + if (idx != PA_INVALID_INDEX) + source = pa_idxset_get_by_index(c->protocol->core->sources, idx); + else + source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE); + + CHECK_VALIDITY(c->pstream, source, tag, PA_ERR_NOENTITY); + + if ((ret = pa_source_set_port(source, port, TRUE)) < 0) { + pa_pstream_send_error(c->pstream, tag, -ret); + return; + } + } + pa_pstream_send_simple_ack(c->pstream, tag); } -- cgit From 46b8ca21d1ef56df298cfa9412e73fdf17cbea49 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 23:17:37 +0200 Subject: native-protocol: allow enumerating ports --- src/pulsecore/protocol-native.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 92efc9ee..48f7b135 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -2845,6 +2845,23 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin pa_tagstruct_putu32(t, sink->n_volume_steps); pa_tagstruct_putu32(t, sink->card ? sink->card->index : PA_INVALID_INDEX); } + + if (c->version >= 16) { + pa_tagstruct_putu32(t, sink->ports ? pa_hashmap_size(sink->ports) : 0); + + if (sink->ports) { + void *state; + pa_device_port *p; + + PA_HASHMAP_FOREACH(p, sink->ports, state) { + pa_tagstruct_puts(t, p->name); + pa_tagstruct_puts(t, p->description); + pa_tagstruct_putu32(t, p->priority); + } + } + + pa_tagstruct_puts(t, sink->active_port ? sink->active_port->name : NULL); + } } static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_source *source) { @@ -2885,6 +2902,24 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s pa_tagstruct_putu32(t, source->n_volume_steps); pa_tagstruct_putu32(t, source->card ? source->card->index : PA_INVALID_INDEX); } + + if (c->version >= 16) { + + pa_tagstruct_putu32(t, source->ports ? pa_hashmap_size(source->ports) : 0); + + if (source->ports) { + void *state; + pa_device_port *p; + + PA_HASHMAP_FOREACH(p, source->ports, state) { + pa_tagstruct_puts(t, p->name); + pa_tagstruct_puts(t, p->description); + pa_tagstruct_putu32(t, p->priority); + } + } + + pa_tagstruct_puts(t, source->active_port ? source->active_port->name : NULL); + } } static void client_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_client *client) { -- cgit From 0955e3d45b6e992308e2d51fcbf28a9f9376f788 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 5 Apr 2009 02:13:43 +0300 Subject: Base mainloop on pa_rtclock_now() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the mainloop to monotonic based time events. Introduces 4 helper functions: pa_{context,core}_rttime_{new,restart}(), that fill correctly a timeval with the rtclock flag set if the mainloop supports it. Both mainloop-test and mainloop-test-glib works with rt and timeval based time events. PulseAudio and clients should be fully functional. This patch has received several iterations, and this one as been largely untested. Signed-off-by: Marc-André Lureau --- src/pulsecore/protocol-native.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 48f7b135..cda7ef57 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -61,7 +62,7 @@ #include "protocol-native.h" /* Kick a client if it doesn't authenticate within this time */ -#define AUTH_TIMEOUT 60 +#define AUTH_TIMEOUT (60 * PA_USEC_PER_SEC) /* Don't accept more connection than this */ #define MAX_CONNECTIONS 64 @@ -4479,11 +4480,10 @@ static void client_send_event_cb(pa_client *client, const char*event, pa_proplis /*** module entry points ***/ -static void auth_timeout(pa_mainloop_api*m, pa_time_event *e, const struct timeval *tv, void *userdata) { +static void auth_timeout(pa_mainloop_api*m, pa_time_event *e, const struct timeval *t, void *userdata) { pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); pa_assert(m); - pa_assert(tv); pa_native_connection_assert_ref(c); pa_assert(c->auth_timeout_event == e); @@ -4541,12 +4541,9 @@ void pa_native_protocol_connect(pa_native_protocol *p, pa_iochannel *io, pa_nati c->authorized = TRUE; } - if (!c->authorized) { - struct timeval tv; - pa_gettimeofday(&tv); - tv.tv_sec += AUTH_TIMEOUT; - c->auth_timeout_event = p->core->mainloop->time_new(p->core->mainloop, &tv, auth_timeout, c); - } else + if (!c->authorized) + c->auth_timeout_event = pa_core_rttime_new(p->core, pa_rtclock_now() + AUTH_TIMEOUT, auth_timeout, c); + else c->auth_timeout_event = NULL; c->is_local = pa_iochannel_socket_is_local(io); @@ -4565,7 +4562,7 @@ void pa_native_protocol_connect(pa_native_protocol *p, pa_iochannel *io, pa_nati pa_pstream_set_revoke_callback(c->pstream, pstream_revoke_callback, c); pa_pstream_set_release_callback(c->pstream, pstream_release_callback, c); - c->pdispatch = pa_pdispatch_new(p->core->mainloop, command_table, PA_COMMAND_MAX); + c->pdispatch = pa_pdispatch_new(p->core->mainloop, TRUE, command_table, PA_COMMAND_MAX); c->record_streams = pa_idxset_new(NULL, NULL); c->output_streams = pa_idxset_new(NULL, NULL); -- cgit