Re: [PATCH v15 39/50] ASoC: Introduce SND kcontrols to select sound card and PCM device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 13 Feb 2024 01:54:11 +0100,
Wesley Cheng wrote:
> 
> +static int soc_usb_get_offload_dev(struct snd_kcontrol *kcontrol,
> +				   struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
> +	struct snd_soc_usb *ctx = snd_soc_usb_find_priv_data(component->dev);
> +	int ret = 0;
> +
> +	mutex_lock(&ctx_mutex);
> +	if (ctx && ctx->get_offload_dev)
> +		ret = ctx->get_offload_dev(kcontrol, ucontrol);
> +	mutex_unlock(&ctx_mutex);

It might be safer to initialize the values with -1 in case when the
callback isn't available?

>  /**
>   * snd_soc_usb_get_components_tag() - Retrieve SOC USB component tag
>   * @playback: direction of audio stream
> @@ -157,6 +218,12 @@ EXPORT_SYMBOL_GPL(snd_soc_usb_free_port);
>   */
>  int snd_soc_usb_add_port(struct snd_soc_usb *usb)
>  {
> +	int ret;
> +
> +	ret = snd_soc_usb_control_init(usb->component);
> +	if (ret < 0)
> +		return ret;
> +
>  	mutex_lock(&ctx_mutex);
>  	list_add_tail(&usb->list, &usb_ctx_list);
>  	mutex_unlock(&ctx_mutex);

We may need to remove the control element upon the driver removal,
too?  In theory, you can unload the offload stuff while snd-usb-audio
is still active.


thanks,

Takashi



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux