alsa: Catch role matched streams to enable/disable modifier

In UCM basic functions, we only assign intended roles from modifier
to sink/source, but we don't have a chance to set the ucm modifiers.
Here we amend the functions so that when roled stream starts or
stops, we have the following results:
1. stream will be routed to sink/source specified in modifier by
   module-intended-roles
2. After that, modifier will be enabled or disabled.
3. when multiple streams with matched roles of modifier start, only
   the first one will enable the modifier, and when they end, the
   last one will disable the modifier.

Signed-off-by: Feng Wei <wei.feng@freescale.com>
Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk>
This commit is contained in:
Feng Wei 2012-07-17 18:17:21 +08:00 committed by Arun Raghavan
parent 801f286dfd
commit 3a92bda554
5 changed files with 148 additions and 34 deletions

View file

@ -904,8 +904,6 @@ static int build_pollfd(struct userdata *u) {
/* Called from IO context */
static int suspend(struct userdata *u) {
const char *mod_name;
pa_assert(u);
pa_assert(u->pcm_handle);
@ -916,13 +914,6 @@ static int suspend(struct userdata *u) {
snd_pcm_close(u->pcm_handle);
u->pcm_handle = NULL;
if ((mod_name = pa_proplist_gets(u->sink->proplist, PA_ALSA_PROP_UCM_MODIFIER))) {
pa_log_info("Disable ucm modifier %s", mod_name);
if (snd_use_case_set(u->ucm_context->ucm->ucm_mgr, "_dismod", mod_name) < 0)
pa_log("Failed to disable ucm modifier %s", mod_name);
}
if (u->alsa_rtpoll_item) {
pa_rtpoll_item_free(u->alsa_rtpoll_item);
u->alsa_rtpoll_item = NULL;
@ -1045,20 +1036,12 @@ static int unsuspend(struct userdata *u) {
pa_bool_t b, d;
snd_pcm_uframes_t period_size, buffer_size;
char *device_name = NULL;
const char *mod_name;
pa_assert(u);
pa_assert(!u->pcm_handle);
pa_log_info("Trying resume...");
if ((mod_name = pa_proplist_gets(u->sink->proplist, PA_ALSA_PROP_UCM_MODIFIER))) {
pa_log_info("Enable ucm modifier %s", mod_name);
if (snd_use_case_set(u->ucm_context->ucm->ucm_mgr, "_enamod", mod_name) < 0)
pa_log("Failed to enable ucm modifier %s", mod_name);
}
if ((is_iec958(u) || is_hdmi(u)) && pa_sink_is_passthrough(u->sink)) {
/* Need to open device in NONAUDIO mode */
int len = strlen(u->device_name) + 8;