[pulseaudio-discuss] [PATCH 5/6] ucm: Add support for "JackControl"

Arun Raghavan arun at accosted.net
Tue Mar 10 05:09:31 PDT 2015


On Thu, 2015-02-12 at 15:11 +0200, Tanu Kaskinen wrote:
> JackControl is used to indicate the kcontrol name for jack detection.
> ---
>  src/modules/alsa/alsa-ucm.c | 25 ++++++++++++++++++++-----
>  src/modules/alsa/alsa-ucm.h |  3 +++
>  2 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
> index aa2d601..ef6adcd 100644
> --- a/src/modules/alsa/alsa-ucm.c
> +++ b/src/modules/alsa/alsa-ucm.c
> @@ -90,6 +90,7 @@ static struct ucm_items item[] = {
>      {"CaptureRate", PA_ALSA_PROP_UCM_CAPTURE_RATE},
>      {"CaptureChannels", PA_ALSA_PROP_UCM_CAPTURE_CHANNELS},
>      {"TQ", PA_ALSA_PROP_UCM_QOS},
> +    {"JackControl", PA_ALSA_PROP_UCM_JACK_CONTROL},
>      {NULL, NULL},
>  };
>  
> @@ -1262,9 +1263,18 @@ static int ucm_create_mapping(
>      return ret;
>  }
>  
> -static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, const char *dev_name, const char *pre_tag) {
> +static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *device, const char *pre_tag) {
>      pa_alsa_jack *j;
> -    char *name = pa_sprintf_malloc("%s%s", pre_tag, dev_name);
> +    const char *device_name;
> +    char *name;
> +    const char *jack_control;
> +
> +    pa_assert(ucm);
> +    pa_assert(device);
> +    pa_assert(pre_tag);
> +
> +    device_name = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_NAME);
> +    name = pa_sprintf_malloc("%s%s", pre_tag, device_name);
>  
>      PA_LLIST_FOREACH(j, ucm->jacks)
>          if (pa_streq(j->name, name))
> @@ -1274,7 +1284,12 @@ static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, const char *dev_name,
>      j->state_unplugged = PA_AVAILABLE_NO;
>      j->state_plugged = PA_AVAILABLE_YES;
>      j->name = pa_xstrdup(name);
> -    j->alsa_name = pa_sprintf_malloc("%s Jack", dev_name);
> +
> +    jack_control = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_JACK_CONTROL);
> +    if (jack_control)
> +        j->alsa_name = pa_xstrdup(jack_control);
> +    else
> +        j->alsa_name = pa_sprintf_malloc("%s Jack", device_name);
>  
>      PA_LLIST_PREPEND(pa_alsa_jack, ucm->jacks, j);
>  
> @@ -1343,9 +1358,9 @@ static int ucm_create_profile(
>          ucm_create_mapping(ucm, ps, p, dev, verb_name, name, sink, source);
>  
>          if (sink)
> -            dev->output_jack = ucm_get_jack(ucm, name, PA_UCM_PRE_TAG_OUTPUT);
> +            dev->output_jack = ucm_get_jack(ucm, dev, PA_UCM_PRE_TAG_OUTPUT);
>          if (source)
> -            dev->input_jack = ucm_get_jack(ucm, name, PA_UCM_PRE_TAG_INPUT);
> +            dev->input_jack = ucm_get_jack(ucm, dev, PA_UCM_PRE_TAG_INPUT);
>      }
>  
>      /* Now find modifiers that have their own PlaybackPCM and create
> diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h
> index 20dc999..a8c8090 100644
> --- a/src/modules/alsa/alsa-ucm.h
> +++ b/src/modules/alsa/alsa-ucm.h
> @@ -84,6 +84,9 @@ typedef void snd_use_case_mgr_t;
>  /** For devices: The modifier (if any) that this device corresponds to */
>  #define PA_ALSA_PROP_UCM_MODIFIER "alsa.ucm.modifier"
>  
> +/* Corresponds to the "JackControl" UCM value. */
> +#define PA_ALSA_PROP_UCM_JACK_CONTROL               "alsa.ucm.jack_control"
> +
>  typedef struct pa_alsa_ucm_verb pa_alsa_ucm_verb;
>  typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
>  typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;

Looks good to me, ack.

-- Arun



More information about the pulseaudio-discuss mailing list