From db27c6347ebe3316bb5f80518c6cc86eea67779b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Jan 2009 22:40:32 +0100 Subject: make module-alsa-card move streams between the old and new sink/source, allowing 'hot' switching between profiles --- src/modules/alsa/module-alsa-card.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/modules/alsa') 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 #include #include +#include #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; -- cgit