From b833982c700275972c0befcf80e793bf91f472bc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2004 14:05:55 +0000 Subject: [PATCH] - added asym plugin. --- doc/doxygen.cfg | 1 + src/pcm/Makefile.am | 2 +- src/pcm/pcm.c | 2 +- src/pcm/pcm_asym.c | 118 ++++++++++++++++++++++++++++++++++++++++++ src/pcm/pcm_symbols.c | 4 +- 5 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/pcm/pcm_asym.c diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg index 779997f5..b67609c4 100644 --- a/doc/doxygen.cfg +++ b/doc/doxygen.cfg @@ -59,6 +59,7 @@ INPUT = index.doxygen \ ../src/pcm/pcm_direct.c \ ../src/pcm/pcm_meter.c \ ../src/pcm/pcm_ladspa.c \ + ../src/pcm/pcm_asym.c \ ../src/pcm/pcm_misc.c \ ../src/rawmidi \ ../src/timer \ diff --git a/src/pcm/Makefile.am b/src/pcm/Makefile.am index c66b8560..64c35076 100644 --- a/src/pcm/Makefile.am +++ b/src/pcm/Makefile.am @@ -11,7 +11,7 @@ libpcm_la_SOURCES = atomic.c mask.c interval.c \ pcm_shm.c pcm_file.c pcm_null.c pcm_share.c \ pcm_meter.c pcm_hooks.c pcm_lfloat.c pcm_ladspa.c \ pcm_direct.c pcm_dmix.c pcm_dsnoop.c pcm_dshare.c \ - pcm_symbols.c + pcm_asym.c pcm_symbols.c noinst_HEADERS = pcm_local.h pcm_plugin.h mask.h mask_inline.h \ interval.h interval_inline.h plugin_ops.h ladspa.h \ pcm_direct.h pcm_dmix_i386.h pcm_dmix_x86_64.h diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 63af7522..0a433f5a 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -1782,7 +1782,7 @@ snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler) static char *build_in_pcms[] = { "adpcm", "alaw", "copy", "dmix", "file", "hooks", "hw", "ladspa", "lfloat", "linear", "meter", "mulaw", "multi", "null", "plug", "rate", "route", "share", - "shm", "dsnoop", "dshare", NULL + "shm", "dsnoop", "dshare", "asym", NULL }; static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, diff --git a/src/pcm/pcm_asym.c b/src/pcm/pcm_asym.c new file mode 100644 index 00000000..5a2a4d64 --- /dev/null +++ b/src/pcm/pcm_asym.c @@ -0,0 +1,118 @@ +/** + * \file pcm/pcm_asym.c + * \ingroup PCM_Plugins + * \brief PCM Asymmetrical Plugin Interface + * \author Takashi Iwai + * \date 2003 + */ + +#include "pcm_local.h" + +#ifndef PIC +/* entry for static linking */ +const char *_snd_module_pcm_asym = ""; +#endif + +/*! \page pcm_plugins + +\section pcm_plugins_asym Plugin: asym + +This plugin is a combination of playback and capture PCM streams. +Slave PCMs can be defined asymmetrically for both directions. + +\code +pcm.name { + type asym # Asym PCM + playback STR # Playback slave name + # or + playback { # Playback slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } + capture STR # Capture slave name + # or + capture { # Capture slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } +} +\endcode + +For example, you can combine a dmix plugin and a dsnoop plugin as +as a single PCM for playback and capture directions, respectively. +\code +pcm.duplex { + type asym + playback.pcm "dmix" + capture.pcm "dsnoop" +} +\endcode + +By defining only a single direction, the resultant PCM becomes +half-duplex. + +\subsection pcm_plugins_asym_funcref Function reference + + + +*/ + +/** + * \brief Creates a new asym stream PCM + * \param pcmp Returns created PCM handle + * \param name Name of PCM + * \param root Root configuration node + * \param conf Configuration node with copy PCM description + * \param stream Stream type + * \param mode Stream mode + * \retval zero on success otherwise a negative error code + * \warning Using of this function might be dangerous in the sense + * of compatibility reasons. The prototype might be freely + * changed in future. + */ +int _snd_pcm_asym_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED, + snd_config_t *root, snd_config_t *conf, + snd_pcm_stream_t stream, int mode) +{ + snd_config_iterator_t i, next; + int err; + snd_config_t *slave = NULL, *sconf; + 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 (snd_pcm_conf_generic_id(id)) + continue; + if (strcmp(id, "playback") == 0) { + if (stream == SND_PCM_STREAM_PLAYBACK) + slave = n; + continue; + } + if (strcmp(id, "capture") == 0) { + if (stream == SND_PCM_STREAM_CAPTURE) + slave = n; + continue; + } + SNDERR("Unknown field %s", id); + return -EINVAL; + } + if (! slave) { + SNDERR("%s slave is not defined", + stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture"); + return -EINVAL; + } + err = snd_pcm_slave_conf(root, slave, &sconf, 0); + if (err < 0) + return err; + err = snd_pcm_open_slave(pcmp, root, sconf, stream, mode); + snd_config_delete(sconf); + return err; +} +#ifndef DOC_HIDDEN +SND_DLSYM_BUILD_VERSION(_snd_pcm_asym_open, SND_PCM_DLSYM_VERSION); +#endif diff --git a/src/pcm/pcm_symbols.c b/src/pcm/pcm_symbols.c index 0a08744a..ea8464ce 100644 --- a/src/pcm/pcm_symbols.c +++ b/src/pcm/pcm_symbols.c @@ -43,6 +43,7 @@ extern const char *_snd_module_pcm_ladspa; extern const char *_snd_module_pcm_dmix; extern const char *_snd_module_pcm_dsnoop; extern const char *_snd_module_pcm_dshare; +extern const char *_snd_module_pcm_asym; static const char **snd_pcm_open_objects[] = { &_snd_module_pcm_adpcm, @@ -65,7 +66,8 @@ static const char **snd_pcm_open_objects[] = { &_snd_module_pcm_ladspa, &_snd_module_pcm_dmix, &_snd_module_pcm_dsnoop, - &_snd_module_pcm_dshare + &_snd_module_pcm_dshare, + &_snd_module_pcm_asym }; void *snd_pcm_open_symbols(void) -- 2.47.1