From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: DMIX and capture stream Date: Wed, 07 Jan 2004 12:01:02 +0100 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <200401051741.i05HfCXl007120@dhin.linuxaudiosystems.com> <20040106223828.39d2c233.mista.tapas@gmx.net> Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: multipart/mixed; boundary="Multipart_Wed_Jan__7_12:01:02_2004-1" Return-path: In-Reply-To: <20040106223828.39d2c233.mista.tapas@gmx.net> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Florian Schmidt Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org --Multipart_Wed_Jan__7_12:01:02_2004-1 Content-Type: text/plain; charset=US-ASCII At Tue, 6 Jan 2004 22:38:28 +0100, Florian Schmidt wrote: > > On Tue, 6 Jan 2004 11:05:52 -0600 (CST) > David Lloyd wrote: > > > This patch works great - I'm now able to use TeamSpeak (which opens > > capture and playback through oss) at the same time as xmms. > > > > Cool.. this sounds good. Great news! Thanks, Takashi.. Is there a chance > of this getting into cvs? Is this actually a replacement for the > pcm.dspX definition? or is it still possible to define it the old way? as written in my previous mail, it was a quick hack. and there is a better approach. the attached patch will add a new plugin, asym, which defines different slave pcms for playback and capture streams. for example, pcm.duplex { type asym playback.pcm "dmix" capture.pcm "dsnoop" } then you can use the pcm "duplex" for dmix/dsnoop combination. % aplay -D duplex foo.wav % arecord -D duplex bar.wav (in reality, you likely need plug layer in addition to support other sample rates, though.) also, by defining pcm.dsp0 "duplex" you can use it via aoss, too. i'm not sure whether the name "asym" is the best choice. if you have better idea, please let me know before committing to cvs. Takashi --Multipart_Wed_Jan__7_12:01:02_2004-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="pcm-asym.dif" Content-Transfer-Encoding: 7bit Index: alsa-lib/src/pcm/Makefile.am =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-lib/src/pcm/Makefile.am,v retrieving revision 1.40 diff -u -r1.40 Makefile.am --- alsa-lib/src/pcm/Makefile.am 17 Sep 2003 17:03:14 -0000 1.40 +++ alsa-lib/src/pcm/Makefile.am 7 Jan 2004 10:53:54 -0000 @@ -11,7 +11,7 @@ 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 Index: alsa-lib/src/pcm/pcm.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-lib/src/pcm/pcm.c,v retrieving revision 1.141 diff -u -r1.141 pcm.c --- alsa-lib/src/pcm/pcm.c 2 Jan 2004 13:41:32 -0000 1.141 +++ alsa-lib/src/pcm/pcm.c 7 Jan 2004 10:54:29 -0000 @@ -1782,7 +1782,7 @@ 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, Index: alsa-lib/src/pcm/pcm_symbols.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-lib/src/pcm/pcm_symbols.c,v retrieving revision 1.9 diff -u -r1.9 pcm_symbols.c --- alsa-lib/src/pcm/pcm_symbols.c 20 Mar 2003 11:06:14 -0000 1.9 +++ alsa-lib/src/pcm/pcm_symbols.c 7 Jan 2004 10:54:07 -0000 @@ -43,6 +43,7 @@ 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 @@ &_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) --- /dev/null 2003-11-13 06:41:21.000000000 +0100 +++ alsa-lib/src/pcm/pcm_asym.c 2004-01-07 11:53:43.000000000 +0100 @@ -0,0 +1,115 @@ +/** + * \file pcm/pcm_asym.c + * \ingroup PCM_Plugins + * \brief PCM Asym 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. +Assymmetrical slave PCMs can be defined 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 + +\subsection pcm_plugins_asym_funcref Function reference + +
    +
  • _snd_pcm_asym_open() +
+ +*/ + +/** + * \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 --Multipart_Wed_Jan__7_12:01:02_2004-1-- ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click