Hi David, On Wed, Apr 6, 2011 at 1:41 AM, David Henningsson <david.hennings...@canonical.com> wrote: > 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? > This is a mistake in this version, It is fixed now.
> 2) There is no matching against what card sent the event, is that irrelevant > for UCM? > The UCM data is store per sound, I'm looking into a way of passing the card name to the hook and compare it with the one passed in the userdata. > 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? > It depends on the driver to report here what was inserted or removed. >> + >> +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...? > hmm, here we will switch to "device_name" gotten from the current profile, in case of failure the device will be disabled. I will post the changes soon. Regards, Margarita > -- > David Henningsson, Canonical Ltd. > http://launchpad.net/~diwic > _______________________________________________ > pulseaudio-discuss mailing list > pulseaudio-discuss@mail.0pointer.de > https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss > _______________________________________________ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss