]> git.alsa-project.org Git - alsa-lib.git/commitdiff
- added asym plugin.
authorTakashi Iwai <tiwai@suse.de>
Thu, 8 Jan 2004 14:05:55 +0000 (14:05 +0000)
committerTakashi Iwai <tiwai@suse.de>
Thu, 8 Jan 2004 14:05:55 +0000 (14:05 +0000)
doc/doxygen.cfg
src/pcm/Makefile.am
src/pcm/pcm.c
src/pcm/pcm_asym.c [new file with mode: 0644]
src/pcm/pcm_symbols.c

index 779997f597471ca8927ebfd2807b6301dc684d7b..b67609c49ce5955daef34874376b3cde22493353 100644 (file)
@@ -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 \
index c66b8560d2488508d680627f87f8a566cf8a0aea..64c35076c62c0578b94eafcdfe93cc7949d49776 100644 (file)
@@ -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
index 63af75225d375f4154771166d0e889f0638ead8d..0a433f5a4459bef3bbcea10af0756739d291a7e0 100644 (file)
@@ -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 (file)
index 0000000..5a2a4d6
--- /dev/null
@@ -0,0 +1,118 @@
+/**
+ * \file pcm/pcm_asym.c
+ * \ingroup PCM_Plugins
+ * \brief PCM Asymmetrical 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.
+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
+
+<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
index 0a08744ac74509354a3e3751b3d00c6f3c1fee16..ea8464ce02c3add5250e18bd430bad10b2253c44 100644 (file)
@@ -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)