alsa-lib/include
Timo Wischer ee64b4b83a pcm: extplug: Keep format and channels the same if requested
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>
2018-12-10 11:53:41 +01:00
..
sound timer: fix wrong comment to refer to 'SNDRV_TIMER_PSFLG_*' 2018-10-02 17:16:14 +02:00
alisp.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
alsa-symbols.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
aserver.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
asoundef.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
asoundlib-head.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
asoundlib-tail.h Create asoundlib.h dynamically according to configure options 2007-07-10 15:58:41 +02:00
bswap.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
conf.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
control.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
control_external.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
error.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
global.h Change snd_dlopen() function to return the error string 2017-11-27 21:48:20 +01:00
hwdep.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
input.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
list.h Replace list.h with its own version 2015-07-27 12:39:54 +02:00
local.h ucm: Set default include path 2018-11-29 09:40:10 +01:00
Makefile.am pcm: Remove home brew atomic operations 2016-07-11 15:25:30 +02:00
mixer.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
mixer_abst.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
output.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm.h a set of fixes to reduce gcc warnings 2018-03-27 15:16:41 +02:00
pcm_external.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_extplug.h pcm: extplug: Keep format and channels the same if requested 2018-12-10 11:53:41 +01:00
pcm_ioplug.h ioplug: Fix comment in struct snd_pcm_ioplug 2018-10-02 17:56:51 +02:00
pcm_old.h pcm: fix get_stop_threshold alsa-lib 0.9 alias 2016-12-15 22:47:02 +01:00
pcm_plugin.h pcm: Fix header guard in pcm_plugin.h 2018-07-06 17:07:13 +02:00
pcm_rate.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
rawmidi.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
search.h Corrections by Kevin Conder <kconder@interaccess.com> 2002-03-12 20:14:33 +00:00
seq.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
seq_event.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
seq_midi_event.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
seqmid.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
sys.h Ok, added warning to sys/asoundlib.h with redirection to alsa/asoundlib.h. 2001-09-11 12:18:56 +00:00
timer.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
topology.h ASoC: topology: Add definitions for mclk_direction values 2018-04-20 09:27:29 +02:00
type_compat.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
use-case.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00