[alsa-devel] [alsa-plugins] [PATCH 1/2] Allow number of channels

Corfu, ValentinX valentinx.corfu at intel.com
Tue Jan 21 17:41:15 CET 2014


0001-Modify-jack-client-name.patch is spitted in: 0001-Allow-number-of-channels.patch and 0002-Allow-to-specify-a-client-name-as-parameters-in-the-.patch

>From d247e4d675dd68c6f683a8c09ff792172396e870 Mon Sep 17 00:00:00 2001
From: Valentin Corfu <valentinx.corfu at intel.com>
Date: Tue, 21 Jan 2014 10:10:52 -0500
Subject: [PATCH 1/2] Allow number of channels

The modification allows to specify the number of channels as parameters in the configuration file
The given number of channels are then created but not connected.

Signed-off-by: Valentin Corfu <valentinx.corfu at intel.com>

diff --git a/jack/pcm_jack.c b/jack/pcm_jack.c
index c51fe84..4306a13 100644
--- a/jack/pcm_jack.c
+++ b/jack/pcm_jack.c
@@ -415,6 +415,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
     snd_config_t *playback_conf = NULL;
     snd_config_t *capture_conf = NULL;
     int err;
+    long num_channels = 0;
+    long chan;

     snd_config_for_each(i, next, conf) {
         snd_config_t *n = snd_config_iterator_entry(i);
@@ -423,6 +425,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
             continue;
         if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0 || strcmp(id, "hint") == 0)
             continue;
+        if (strcmp(id, "nchan") == 0) {
+            snd_config_get_integer(n, &num_channels);
+            continue;
+        }
         if (strcmp(id, "playback_ports") == 0) {
             if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
                 SNDERR("Invalid type for %s", id);
@@ -443,7 +449,72 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
         return -EINVAL;
     }

-    err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode);
+    if ( (num_channels != 0) && (playback_conf == NULL) && (capture_conf == NULL) ) {
+        err = snd_config_make_compound(&playback_conf, "playback_ports", 0);
+        if (err) {
+            SNDERR("Error during snd_config_make_compound(p): %s\n", strerror(err));
+            return err;
+        }
+        err = snd_config_make_compound(&capture_conf, "capture_ports", 0);
+        if (err) {
+            SNDERR("Error during snd_config_make_compound(c): %s\n", strerror(err));
+            return err;
+        }
+        char value[4];
+        for (chan=0; chan<num_channels; ++chan) {
+            snprintf(value, sizeof(value), "%d", chan);
+            snd_config_t *newLeafPlayback;
+            snd_config_t *newLeafCapture;
+        err = snd_config_imake_integer(&newLeafPlayback, value, chan);
+            if (err) {
+                SNDERR("Error during snd_config_imake_string(p): %s\n", strerror(err));
+                return err;
+            }
+        err = snd_config_add(playback_conf, newLeafPlayback);
+            if (err) {
+                SNDERR("Error during snd_config_add(p): %s\n", strerror(err));
+                return err;
+            }
+        err = snd_config_imake_integer(&newLeafCapture, value, chan);
+            if (err) {
+                SNDERR("Error during snd_config_imake_string(c): %s\n", strerror(err));
+                return err;
+            }
+        err = snd_config_add(capture_conf, newLeafCapture);
+            if (err) {
+                SNDERR("Error during snd_config_add(c): %s\n", strerror(err));
+                return err;
+            }
+        }
+        err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode);
+        if (err) {
+            SNDERR("Error during snd_pcm_jack_open: %s\n", strerror(err));
+            return err;
+        }
+
+        err = snd_config_delete_compound_members(playback_conf);
+        if (err) {
+            SNDERR("Error during snd_config_delete_compound_members(p): %s\n", strerror(err));
+            return err;
+        }
+        err = snd_config_delete_compound_members(capture_conf);
+        if (err) {
+            SNDERR("Error during snd_config_delete_compound_members(c): %s\n", strerror(err));
+            return err;
+        }
+        err = snd_config_delete(playback_conf);
+        if (err) {
+            SNDERR("Error during snd_config_delete(p): %s\n", strerror(err));
+            return err;
+        }
+        err = snd_config_delete(capture_conf);
+        if (err) {
+            SNDERR("Error during snd_config_delete(c): %s\n", strerror(err));
+            return err;
+        }
+    } else {
+        err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode);
+    }

     return err;
 }
--
1.8.1.4


--------------------------------------------------------------
Intel Shannon Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
Business address: Dromore House, East Park, Shannon, Co. Clare

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Allow-number-of-channels.patch
Type: text/x-patch
Size: 3633 bytes
Desc: 0001-Allow-number-of-channels.patch
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20140121/d22a09e3/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Modify-jack-client-name.patch
Type: text/x-patch
Size: 5812 bytes
Desc: 0001-Modify-jack-client-name.patch
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20140121/d22a09e3/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Allow-to-specify-a-client-name-as-parameters-in-the-.patch
Type: text/x-patch
Size: 4507 bytes
Desc: 0002-Allow-to-specify-a-client-name-as-parameters-in-the-.patch
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20140121/d22a09e3/attachment-0005.bin>


More information about the Alsa-devel mailing list