[pulseaudio-discuss] [PATCH 5/6] alsa: create ucm profiles

David Henningsson david.henningsson at canonical.com
Tue Apr 5 23:41:36 PDT 2011


On 2011-04-05 22:34, Margarita Olaya wrote:
> +static pa_hook_result_t jack_insert_new_hook_callback(pa_core *c,
> struct userdata *u) {
> +    struct pa_alsa_ucm_config *ucm =&u->ucm;
> +    struct profile_data *d;
> +    char *device_name;
> +
> +    pa_assert(u);
> +
> +    d = PA_CARD_PROFILE_DATA(u->card->active_profile);
> +
> +    pa_log_debug("Jack insert new hook callback");
> +
> +    device_name = strchr(d->profile->name, ':') + 2;
> +    if (!device_name) {
> +        pa_log("no device found for %s", d->profile->name);
> +        return PA_HOOK_CANCEL;
> +    }
> +
> +    if (strcmp(device_name, "Headset.0") == 0)
> +        return PA_HOOK_OK;
> +
> +    /* Set headset.0 device per default */
> +    if (snd_use_case_set(ucm->ucm_mgr, "_enadev", "Headset.0")<  0) {
> +        pa_log("failed to set device Headset.0");
> +        return PA_HOOK_CANCEL;
> +    }
> +
> +    return PA_HOOK_OK;
> +}

About this function:

1) pa_hook_cb_t defines three pointers as input, but this one only takes 
two. Is that really working on all platforms?

2) There is no matching against what card sent the event, is that 
irrelevant for UCM?

3) Is "Headset.0" a reserved identifier in UCM, or is this unfinished 
test code? What if there isn't a headset, just a separate external mic, 
or external speakers connected to line out?

> +
> +static pa_hook_result_t jack_remove_new_hook_callback(pa_core *c,
> struct userdata *u) {
> +    struct profile_data *d;
> +    struct pa_alsa_ucm_config *ucm =&u->ucm;
> +    char *device_name;
> +
> +    pa_assert(u);
> +
> +    d = PA_CARD_PROFILE_DATA(u->card->active_profile);
> +
> +    pa_log_debug("Jack removed new hook callback");
> +
> +    device_name = strchr(d->profile->name, ':') + 2;
> +    if(!device_name) {
> +        pa_log("no device found for %s", d->profile->name);
> +        return PA_HOOK_CANCEL;
> +    }
> +
> +    /* Set current profile device */
> +    if (snd_use_case_set(ucm->ucm_mgr, "_enadev", "Headset.0")<  0) {
> +        pa_log("failed to set device Headset.0");
> +        return PA_HOOK_CANCEL;
> +    }
> +
> +    return PA_HOOK_OK;
> +}

Ehm, seems like you set it to the Headset device both on plug and unplug...?

-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic



More information about the pulseaudio-discuss mailing list