All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Florian Schmidt <mista.tapas@gmx.net>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: DMIX and capture stream
Date: Wed, 07 Jan 2004 12:01:02 +0100	[thread overview]
Message-ID: <s5hvfno10r5.wl@alsa2.suse.de> (raw)
In-Reply-To: <20040106223828.39d2c233.mista.tapas@gmx.net>

[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]

At Tue, 6 Jan 2004 22:38:28 +0100,
Florian Schmidt wrote:
> 
> On Tue, 6 Jan 2004 11:05:52 -0600 (CST)
> David Lloyd <dmlloyd@tds.net> 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

[-- Attachment #2: pcm-asym.dif --]
[-- Type: application/octet-stream, Size: 5528 bytes --]

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 <tiwai@suse.de>
+ * \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
+
+<UL>
+  <LI>_snd_pcm_asym_open()
+</UL>
+
+*/
+
+/**
+ * \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

  reply	other threads:[~2004-01-07 11:01 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-02 20:29 DMIX and capture stream David Lloyd
2004-01-04  5:07 ` Paul Davis
2004-01-04 12:12   ` Joern Nettingsmeier
2004-01-04 13:52   ` Florian Schmidt
2004-01-05  0:02     ` David Lloyd
2004-01-05  0:15       ` Florian Schmidt
2004-01-05  6:00       ` Patrick Shirkey
2004-01-05 10:18         ` HDSP as normal user Patrick Shirkey
2004-01-05 14:02           ` Paul Davis
2004-01-05 14:22           ` Takashi Iwai
2004-01-05 14:48             ` Patrick Shirkey
2004-01-05 16:13         ` DMIX and capture stream David Lloyd
2004-01-05 16:21           ` Jaroslav Kysela
2004-01-05 16:29   ` David Lloyd
2004-01-05 16:28     ` Jaroslav Kysela
2004-01-05 16:43       ` Takashi Iwai
2004-01-05 17:27       ` David Lloyd
2004-01-05 17:28       ` Florian Schmidt
2004-01-05 16:42     ` Takashi Iwai
2004-01-05 17:20       ` David Lloyd
2004-01-05 17:41         ` Paul Davis
2004-01-05 17:45           ` David Lloyd
2004-01-05 18:59             ` Paul Davis
2004-01-05 18:12           ` Takashi Iwai
2004-01-06 17:05             ` David Lloyd
2004-01-06 21:38               ` Florian Schmidt
2004-01-07 11:01                 ` Takashi Iwai [this message]
2004-01-07 12:05                   ` Florian Schmidt
2004-01-07 13:06                     ` Florian Schmidt
2004-01-07 13:49                       ` Takashi Iwai
2004-01-07 12:45                   ` Abramo Bagnara
2004-01-07 13:45                     ` Takashi Iwai
2004-01-07 14:39                       ` Abramo Bagnara
2004-01-07 15:02                         ` Takashi Iwai
2004-01-07 15:15                           ` Abramo Bagnara
2004-01-07 15:30                             ` Takashi Iwai
2004-01-07 15:47                               ` Abramo Bagnara
2004-01-07 16:12                                 ` Takashi Iwai
2004-01-07 16:58                                   ` Abramo Bagnara
2004-01-07 17:22                                     ` Takashi Iwai
2004-01-08  8:33                           ` Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hvfno10r5.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=mista.tapas@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.