[alsa-devel] [PATCH - snd_pcm_extplug_set_param_link() 1/1] pcm: extplug: Keep format and channels the same if requested
Takashi Iwai
tiwai at suse.de
Mon Dec 10 12:04:11 CET 2018
On Mon, 10 Dec 2018 11:33:16 +0100,
<twischer at de.adit-jv.com> wrote:
>
> From: Timo Wischer <twischer at de.adit-jv.com>
>
> Without this patch it is not possible to link the channel and format
> parameter if snd_pcm_extplug_set_param_*() or
> snd_pcm_extplug_set_slave_param_*() is called. Therefore the client and
> slave parameter can differ. So the extplug has to implement conversion.
> To avoid this the new snd_pcm_extplug_set_param_link() function can be
> called.
> As a reproduction sceanrio the following extplug source code can be used:
> static snd_pcm_sframes_t my_transfer(snd_pcm_extplug_t *e,
> const snd_pcm_channel_area_t *da, snd_pcm_uframes_t dof,
> const snd_pcm_channel_area_t *sa, snd_pcm_uframes_t sof,
> snd_pcm_uframes_t s) {
> return s;
> }
> static const snd_pcm_extplug_callback_t my_own_callback = {
> .transfer = my_transfer
> };
> SND_PCM_PLUGIN_DEFINE_FUNC(my_plug) {
> snd_config_iterator_t i, next;
> snd_config_t *slave = NULL;
> snd_pcm_extplug_t *myplug;
> snd_config_for_each(i, next, conf) {
> snd_config_t *n = snd_config_iterator_entry(i);
> const char *id;
> if (snd_config_get_id(n, &id) < 0)
> continue;
> if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0)
> continue;
> if (strcmp(id, "slave") == 0) {
> slave = n;
> continue;
> }
> return -EINVAL;
> }
> myplug = calloc(1, sizeof(*myplug));
> myplug->version = SND_PCM_EXTPLUG_VERSION;
> myplug->callback = &my_own_callback;
> snd_pcm_extplug_create(myplug, name, root, slave, stream, mode);
>
> snd_pcm_extplug_set_param_minmax(myplug,
> SND_PCM_EXTPLUG_HW_CHANNELS, 1, 16);
> // snd_pcm_extplug_set_param_link(myplug, SND_PCM_EXTPLUG_HW_CHANNELS, 1);
>
> *pcmp = myplug->pcm;
> return 0;
> }
> SND_PCM_PLUGIN_SYMBOL(my_plug);
>
> To use this plugin the following ALSA configuration is required:
> pcm.myplug {
> type my_plug
> slave.pcm hw:Dummy
> }
>
> With this configuration without this patch
> snd_pcm_hw_params_get_channels_max() will always return 16 channels
> independent of the supported channels of the dummy device. Due to that for
> example the start up of JACK would fail:
> $ modprobe snd_dummy
> $ jackd -d alsa -P myplug
> ALSA: cannot set channel count to 16 for playback
> ALSA: cannot configure playback channel
>
> Signed-off-by: Timo Wischer <twischer at de.adit-jv.com>
This looks much nicer, now with a proper documentation and a good
example!
Applied now, thanks.
Takashi
More information about the Alsa-devel
mailing list