[CM] Re: snd jack playback mode bug

Kjetil Svalastog Matheussen k.s.matheussen at notam02.no
Sun Nov 7 09:58:50 PST 2004



On Sun, 7 Nov 2004, Kjetil Svalastog Matheussen wrote:

> 
> Oh yes, thank you. jack_get_ports returns NULL when there are no ports.
> I'll fix it ASAP.
> 
> Something like this is a quick fix:
> 
> 
> static int sndjack_getnuminchannels(void){
>   int lokke=0;
>   const char **ports=jack_get_ports(sndjack_client,"alsa_pcm:capture_*","",0);
> 
>   if(ports==NULL) return 0;
> 
>   while(ports[lokke]!=NULL){ ////// ****appears to crash here with lokke=0
>     lokke++;
>   }
>   if(lokke<2) return 2;
>   return lokke;
> }
> 

Oops. That was not enough. Below and attached is a working patch. Thanks
for your excellent bug-report Tim.

Please apply Bill.



--- audio.c~    2004-11-07 12:47:56.000000000 +0100
+++ audio.c     2004-11-07 18:51:49.000000000 +0100
@@ -9023,7 +9023,7 @@
 static int sndjack_getnumoutchannels(void){
   int lokke=0;
   const char **ports=jack_get_ports(sndjack_client,"alsa_pcm:playback_*","",0);
-  while(ports[lokke]!=NULL){
+  while(ports!=NULL && ports[lokke]!=NULL){
     lokke++;
   }
   if(lokke<2) return 2;
@@ -9033,7 +9033,7 @@
 static int sndjack_getnuminchannels(void){
   int lokke=0;
   const char **ports=jack_get_ports(sndjack_client,"alsa_pcm:capture_*","",0);
-  while(ports[lokke]!=NULL){
+  while(ports!=NULL && ports[lokke]!=NULL){
     lokke++;
   }
   if(lokke<2) return 2;
@@ -9137,8 +9137,7 @@
                     )
        )
       {
-       fprintf (stderr, "Error. Cannot connect jack output port %d: \"%s\".\n",ch,temp);
-       goto failed_connect;
+       printf ("Warning. Cannot connect jack output port %d: \"%s\".\n",ch,temp);
       }
   }

@@ -9153,8 +9152,7 @@
                     )
        )
       {
-       fprintf (stderr, "Error. Cannot connect jack input port %d: \"%s\".\n",ch,temp);
-       goto failed_connect;
+       printf ("Warning. Cannot connect jack input port %d: \"%s\".\n",ch,temp);
       }
   }



-- 
-------------- next part --------------
--- audio.c~	2004-11-07 12:47:56.000000000 +0100
+++ audio.c	2004-11-07 18:55:56.000000000 +0100
@@ -9023,7 +9023,7 @@
 static int sndjack_getnumoutchannels(void){
   int lokke=0;
   const char **ports=jack_get_ports(sndjack_client,"alsa_pcm:playback_*","",0);
-  while(ports[lokke]!=NULL){
+  while(ports!=NULL && ports[lokke]!=NULL){
     lokke++;
   }
   if(lokke<2) return 2;
@@ -9033,7 +9033,7 @@
 static int sndjack_getnuminchannels(void){
   int lokke=0;
   const char **ports=jack_get_ports(sndjack_client,"alsa_pcm:capture_*","",0);
-  while(ports[lokke]!=NULL){
+  while(ports!=NULL && ports[lokke]!=NULL){
     lokke++;
   }
   if(lokke<2) return 2;
@@ -9137,8 +9137,7 @@
 		     )
 	)
       {
-	fprintf (stderr, "Error. Cannot connect jack output port %d: \"%s\".\n",ch,temp);
-	goto failed_connect;
+	printf ("Warning. Cannot connect jack output port %d: \"%s\".\n",ch,temp);
       }
   }
 
@@ -9153,8 +9152,7 @@
 		     )
 	)
       {
-	fprintf (stderr, "Error. Cannot connect jack input port %d: \"%s\".\n",ch,temp);
-	goto failed_connect;
+	printf ("Warning. Cannot connect jack input port %d: \"%s\".\n",ch,temp);
       }
   }
 


More information about the Cmdist mailing list