alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-plugins] [PATCH 2/2] Allow number of channels
@ 2014-02-26 14:03 Corfu, ValentinX
  0 siblings, 0 replies; 3+ messages in thread
From: Corfu, ValentinX @ 2014-02-26 14:03 UTC (permalink / raw)
  To: patch; +Cc: alsa-devel, Trandafir, IonutX

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


Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Allow-number-of-channels.patch --]
[-- Type: text/x-patch; name="0002-Allow-number-of-channels.patch", Size: 2769 bytes --]

From f0e45ca372fde0bb7b2fab2132cbea2ccdef34dd Mon Sep 17 00:00:00 2001
From: Valentin Corfu <valentinx.corfu@intel.com>
Date: Tue, 11 Feb 2014 05:08:24 -0500
Subject: [PATCH 2/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@intel.com>

diff --git a/jack/pcm_jack.c b/jack/pcm_jack.c
index 983878f..6c9d675 100644
--- a/jack/pcm_jack.c
+++ b/jack/pcm_jack.c
@@ -325,7 +325,7 @@ static int make_nonblock(int fd)
 static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
 			     snd_config_t *playback_conf,
 			     snd_config_t *capture_conf,
-			     snd_pcm_stream_t stream, int mode)
+			     snd_pcm_stream_t stream, int mode, unsigned int num_channels)
 {
 	snd_pcm_jack_t *jack;
 	int err;
@@ -341,11 +341,21 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
 	jack->fd = -1;
 	jack->io.poll_fd = -1;
 
-	err = parse_ports(jack, stream == SND_PCM_STREAM_PLAYBACK ?
-			  playback_conf : capture_conf);
-	if (err) {
-		snd_pcm_jack_free(jack);
-		return err;
+    if (num_channels > 0) {
+        jack->num_ports = num_channels;
+        jack->port_names = calloc(num_channels, sizeof(char*));
+        if (jack->port_names == NULL){
+            snd_pcm_jack_free(jack);
+            return -ENOMEM;
+        }
+    }
+    else {
+        err = parse_ports(jack, stream == SND_PCM_STREAM_PLAYBACK ?
+                  playback_conf : capture_conf);
+        if (err) {
+            snd_pcm_jack_free(jack);
+            return err;
+        }
 	}
 
 	jack->channels = jack->num_ports;
@@ -422,6 +432,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
 	snd_config_t *playback_conf = NULL;
 	snd_config_t *capture_conf = NULL;
 	int err;
+	unsigned int num_channels = 0;
 	
 	snd_config_for_each(i, next, conf) {
 		snd_config_t *n = snd_config_iterator_entry(i);
@@ -434,6 +445,14 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
             snd_config_get_string(n, &name);
             continue;
         }
+        if (strcmp(id, "nchan") == 0) {
+			if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+				SNDERR("Invalid type for %s", id);
+				return -EINVAL;
+			}
+			num_channels = n;
+            continue;
+        }
 		if (strcmp(id, "playback_ports") == 0) {
 			if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
 				SNDERR("Invalid type for %s", id);
@@ -454,7 +473,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
 		return -EINVAL;
 	}
 
-	err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode);
+	err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode, num_channels);
 
 	return err;
 }
-- 
1.8.1.4


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [alsa-plugins] [PATCH 2/2] Allow number of channels
  2014-01-31 14:05 Corfu, ValentinX
@ 2014-02-06 10:30 ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2014-02-06 10:30 UTC (permalink / raw)
  To: Corfu, ValentinX; +Cc: alsa-devel, Trandafir, IonutX

At Fri, 31 Jan 2014 14:05:48 +0000,
Corfu, ValentinX wrote:
> 
> >From 92cf8488d3d2e271fdb4b1fb41fbc006cc59677b Mon Sep 17 00:00:00 2001
> From: Valentin Corfu <valentinx.corfu@intel.com>
> Date: Fri, 31 Jan 2014 08:08:51 -0500
> Subject: [PATCH 2/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.

This patch isn't applicable, too, by the same reason.
Please fix your mailer, or use an attachment.

About the changes:

> Signed-off-by: Valentin Corfu <valentinx.corfu@intel.com>
> 
> diff --git a/jack/pcm_jack.c b/jack/pcm_jack.c
> index 475c619..feef4a0 100644
> --- a/jack/pcm_jack.c
> +++ b/jack/pcm_jack.c
> @@ -325,7 +325,7 @@ static int make_nonblock(int fd)
>  static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
>                   snd_config_t *playback_conf,
>                   snd_config_t *capture_conf,
> -                 snd_pcm_stream_t stream, int mode)
> +                 snd_pcm_stream_t stream, int mode, long num_channels)

Not necessary to be long.  We don't want over 2 billion channels :)

>  {
>      snd_pcm_jack_t *jack;
>      int err;
> @@ -341,11 +341,19 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
>      jack->fd = -1;
>      jack->io.poll_fd = -1;
> 
> -    err = parse_ports(jack, stream == SND_PCM_STREAM_PLAYBACK ?
> -              playback_conf : capture_conf);
> -    if (err) {
> -        snd_pcm_jack_free(jack);
> -        return err;
> +    if (num_channels > 0) {
> +        jack->num_ports = num_channels;
> +        jack->port_names = calloc(num_channels, sizeof(char*));
> +        if (jack->port_names == NULL)
> +            return -ENOMEM;

This leaks memory.  Call snd_pcm_jack_free() or free() before
returning.


> +    }
> +    else {
> +        err = parse_ports(jack, stream == SND_PCM_STREAM_PLAYBACK ?
> +                  playback_conf : capture_conf);
> +        if (err) {
> +            snd_pcm_jack_free(jack);
> +            return err;
> +        }
>      }
> 
>      jack->channels = jack->num_ports;
> @@ -422,6 +430,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
>      snd_config_t *playback_conf = NULL;
>      snd_config_t *capture_conf = NULL;
>      int err;
> +    long num_channels = 0;
> 
>      snd_config_for_each(i, next, conf) {
>          snd_config_t *n = snd_config_iterator_entry(i);
> @@ -434,6 +443,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
>              snd_config_get_string(n, &name);
>              continue;
>          }
> +        if (strcmp(id, "nchan") == 0) {
> +            snd_config_get_integer(n, &num_channels);

Better to have a sanity value check here.


thanks,

Takashi


> +            continue;
> +        }
>          if (strcmp(id, "playback_ports") == 0) {
>              if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
>                  SNDERR("Invalid type for %s", id);
> @@ -454,7 +467,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
>          return -EINVAL;
>      }
> 
> -    err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode);
> +    err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode, num_channels);
> 
>      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.
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [alsa-plugins] [PATCH 2/2] Allow number of channels
@ 2014-01-31 14:05 Corfu, ValentinX
  2014-02-06 10:30 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Corfu, ValentinX @ 2014-01-31 14:05 UTC (permalink / raw)
  To: patch; +Cc: alsa-devel, Trandafir, IonutX

>From 92cf8488d3d2e271fdb4b1fb41fbc006cc59677b Mon Sep 17 00:00:00 2001
From: Valentin Corfu <valentinx.corfu@intel.com>
Date: Fri, 31 Jan 2014 08:08:51 -0500
Subject: [PATCH 2/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@intel.com>

diff --git a/jack/pcm_jack.c b/jack/pcm_jack.c
index 475c619..feef4a0 100644
--- a/jack/pcm_jack.c
+++ b/jack/pcm_jack.c
@@ -325,7 +325,7 @@ static int make_nonblock(int fd)
 static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
                  snd_config_t *playback_conf,
                  snd_config_t *capture_conf,
-                 snd_pcm_stream_t stream, int mode)
+                 snd_pcm_stream_t stream, int mode, long num_channels)
 {
     snd_pcm_jack_t *jack;
     int err;
@@ -341,11 +341,19 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name,
     jack->fd = -1;
     jack->io.poll_fd = -1;

-    err = parse_ports(jack, stream == SND_PCM_STREAM_PLAYBACK ?
-              playback_conf : capture_conf);
-    if (err) {
-        snd_pcm_jack_free(jack);
-        return err;
+    if (num_channels > 0) {
+        jack->num_ports = num_channels;
+        jack->port_names = calloc(num_channels, sizeof(char*));
+        if (jack->port_names == NULL)
+            return -ENOMEM;
+    }
+    else {
+        err = parse_ports(jack, stream == SND_PCM_STREAM_PLAYBACK ?
+                  playback_conf : capture_conf);
+        if (err) {
+            snd_pcm_jack_free(jack);
+            return err;
+        }
     }

     jack->channels = jack->num_ports;
@@ -422,6 +430,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
     snd_config_t *playback_conf = NULL;
     snd_config_t *capture_conf = NULL;
     int err;
+    long num_channels = 0;

     snd_config_for_each(i, next, conf) {
         snd_config_t *n = snd_config_iterator_entry(i);
@@ -434,6 +443,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
             snd_config_get_string(n, &name);
             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);
@@ -454,7 +467,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack)
         return -EINVAL;
     }

-    err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode);
+    err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode, num_channels);

     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.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-26 14:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-26 14:03 [alsa-plugins] [PATCH 2/2] Allow number of channels Corfu, ValentinX
  -- strict thread matches above, loose matches on Subject: below --
2014-01-31 14:05 Corfu, ValentinX
2014-02-06 10:30 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).