diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-01-23 22:40:32 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-01-23 22:40:32 +0100 |
commit | db27c6347ebe3316bb5f80518c6cc86eea67779b (patch) | |
tree | d6dd7ffc5f2baa6a8ad50d2787e877bc63b60f4e /src/modules/alsa/module-alsa-card.c | |
parent | 640d317df93f205d5830b9f7b106233ddb6d2f9e (diff) |
make module-alsa-card move streams between the old and new sink/source, allowing 'hot' switching between profiles
Diffstat (limited to 'src/modules/alsa/module-alsa-card.c')
-rw-r--r-- | src/modules/alsa/module-alsa-card.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index 9a00edd9..d8a37fe6 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -26,6 +26,7 @@ #include <pulse/xmalloc.h> #include <pulsecore/core-util.h> #include <pulsecore/modargs.h> +#include <pulsecore/queue.h> #include "alsa-util.h" #include "alsa-sink.h" @@ -159,23 +160,49 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { od = PA_CARD_PROFILE_DATA(c->active_profile); if (od->sink_profile != nd->sink_profile) { + pa_queue *inputs = NULL; + if (u->sink) { + if (nd->sink_profile) + inputs = pa_sink_move_all_start(u->sink); + pa_alsa_sink_free(u->sink); u->sink = NULL; } - if (nd->sink_profile) + if (nd->sink_profile) { u->sink = pa_alsa_sink_new(c->module, u->modargs, __FILE__, c, nd->sink_profile); + + if (inputs) { + if (u->sink) + pa_sink_move_all_finish(u->sink, inputs); + else + pa_sink_move_all_fail(inputs); + } + } } if (od->source_profile != nd->source_profile) { + pa_queue *outputs = NULL; + if (u->source) { + if (nd->source_profile) + outputs = pa_source_move_all_start(u->source); + pa_alsa_source_free(u->source); u->source = NULL; } - if (nd->source_profile) + if (nd->source_profile) { u->source = pa_alsa_source_new(c->module, u->modargs, __FILE__, c, nd->source_profile); + + if (outputs) { + if (u->source) + pa_source_move_all_finish(u->source, outputs); + else + pa_source_move_all_fail(outputs); + } + } } return 0; |