mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
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@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
||
|---|---|---|
| .. | ||
| sound | ||
| alisp.h | ||
| alsa-symbols.h | ||
| aserver.h | ||
| asoundef.h | ||
| asoundlib-head.h | ||
| asoundlib-tail.h | ||
| bswap.h | ||
| conf.h | ||
| control.h | ||
| control_external.h | ||
| error.h | ||
| global.h | ||
| hwdep.h | ||
| input.h | ||
| list.h | ||
| local.h | ||
| Makefile.am | ||
| mixer.h | ||
| mixer_abst.h | ||
| output.h | ||
| pcm.h | ||
| pcm_external.h | ||
| pcm_extplug.h | ||
| pcm_ioplug.h | ||
| pcm_old.h | ||
| pcm_plugin.h | ||
| pcm_rate.h | ||
| rawmidi.h | ||
| search.h | ||
| seq.h | ||
| seq_event.h | ||
| seq_midi_event.h | ||
| seqmid.h | ||
| sys.h | ||
| timer.h | ||
| topology.h | ||
| type_compat.h | ||
| use-case.h | ||