alsa-lib/src/pcm
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
..
scopes Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
interval.c pcm: snd_interval_refine_first/last: exclude value only if also excluded before 2018-07-03 12:47:32 +02:00
interval.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
interval_inline.h pcm: interval: Interpret (x x+1] correctly and return x+1 2018-10-24 12:07:33 +02:00
ladspa.h big ALSA LADSPA plugin rewrite for multiple channel LADSPA plugins 2005-12-13 14:08:58 +00:00
Makefile.am pcm: Remove home brew atomic operations 2016-07-11 15:25:30 +02:00
mask.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
mask.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
mask_inline.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm.c pcm: Skip avail_min check during draining 2018-03-29 09:23:46 +02:00
pcm_adpcm.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_alaw.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_asym.c Set PCM name properly in empty and asym plugins 2007-11-26 12:29:37 +01:00
pcm_copy.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_direct.c pcm: dmix: Add option to allow alignment of slave pointers 2018-11-13 15:18:40 +01:00
pcm_direct.h pcm: dmix: Add option to allow alignment of slave pointers 2018-11-13 15:18:40 +01:00
pcm_dmix.c pcm: dmix: Add option to allow alignment of slave pointers 2018-11-13 15:18:40 +01:00
pcm_dmix_generic.c Introduce bswap.h for portable definitions of byte swap macros. 2016-03-03 16:18:10 +01:00
pcm_dmix_i386.c pcm: dmix: Allow disabling x86 optimizations 2017-02-10 12:16:12 +01:00
pcm_dmix_i386.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_dmix_x86_64.c pcm: dmix: Allow disabling x86 optimizations 2017-02-10 12:16:12 +01:00
pcm_dmix_x86_64.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_dshare.c pcm: dshare: Fix segfault when not binding channel 0 2018-11-21 11:01:21 +01:00
pcm_dsnoop.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_empty.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_ext_parm.h pcm: extplug: Keep format and channels the same if requested 2018-12-10 11:53:41 +01:00
pcm_extplug.c pcm: extplug: Keep format and channels the same if requested 2018-12-10 11:53:41 +01:00
pcm_file.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_generic.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_generic.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_hooks.c core: Proper reference of internal snd_dlopen() 2018-01-04 15:29:57 +01:00
pcm_hw.c pcm: add missing flags initialization for the fallback control data 2018-05-23 10:33:40 +02:00
pcm_iec958.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_ioplug.c pcm: ioplug: Transfer all available data 2018-07-17 17:52:52 +02:00
pcm_ladspa.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_lfloat.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_linear.c pcm: linear, route: handle linear formats with 20-bit sample on 4 bytes 2017-12-18 15:41:08 +01:00
pcm_local.h pcm: ioplug: Provide hw_avail helper function for plugins 2018-03-13 22:12:02 +01:00
pcm_meter.c core: Proper reference of internal snd_dlopen() 2018-01-04 15:29:57 +01:00
pcm_misc.c pcm: add and describe SND_PCM_FORMAT_{S, U}20 2017-12-18 15:40:36 +01:00
pcm_mmap.c a set of fixes to reduce gcc warnings 2018-03-27 15:16:41 +02:00
pcm_mmap_emul.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_mulaw.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_multi.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_null.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_params.c pcm: Define refine mask bits explicitly (and fix missing DSD support) 2018-06-28 07:59:46 +02:00
pcm_plug.c pcm: plug: add SND_PCM_FORMAT_{S, U}20 to linear_preferred_formats 2017-12-18 15:41:29 +01:00
pcm_plugin.c a set of fixes to reduce gcc warnings 2018-03-27 15:16:41 +02:00
pcm_plugin.h Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_rate.c pcm: rate: Add error check for snd_pcm_avail_update() 2018-07-04 15:41:21 +02:00
pcm_rate_linear.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_route.c pcm: linear, route: handle linear formats with 20-bit sample on 4 bytes 2017-12-18 15:41:08 +01:00
pcm_share.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_shm.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_simple.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
pcm_softvol.c pcm: softvol: use position offset macro of TLV data 2018-05-15 18:03:13 +02:00
pcm_symbols.c Change FSF address (Franklin Street) 2017-11-14 14:29:26 +01:00
plugin_ops.h pcm: fix wrong comments for some cases of linear interpolation of PCM samples 2017-12-22 10:23:42 +01:00