]> Repos - portaudio/commitdiff
Jack: Add a port-type filter expression to calls to jack_get_ports() so that only...
authorgineera <gineera@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 15 Nov 2013 12:27:07 +0000 (12:27 +0000)
committergineera <gineera@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 15 Nov 2013 12:27:07 +0000 (12:27 +0000)
src/hostapi/jack/pa_jack.c

index 524f0ae9178c5b0d7771642c6db5b155dafae4db..a800f8e1dd9155879caf592f09494e91318b20ad 100644 (file)
@@ -232,6 +232,10 @@ typedef struct PaJackStream
 }
 PaJackStream;
 
+/* In calls to jack_get_ports() this filter expression is used instead of ""
+ * to prevent any other types (eg Midi ports etc) being listed */
+#define JACK_PORT_TYPE_FILTER "audio"
+
 #define TRUE 1
 #define FALSE 0
 
@@ -492,7 +496,7 @@ static PaError BuildDeviceList( PaJackHostApiRepresentation *jackApi )
      * according to the client_name:port_name convention (which is
      * enforced by jackd)
      * A: If jack_get_ports returns NULL, there's nothing for us to do */
-    UNLESS( (jack_ports = jack_get_ports( jackApi->jack_client, "", "", 0 )) && jack_ports[0], paNoError );
+    UNLESS( (jack_ports = jack_get_ports( jackApi->jack_client, "", JACK_PORT_TYPE_FILTER, 0 )) && jack_ports[0], paNoError );
     /* Find number of ports */
     while( jack_ports[numPorts] )
         ++numPorts;
@@ -583,7 +587,7 @@ static PaError BuildDeviceList( PaJackHostApiRepresentation *jackApi )
 
         /* ... what are your output ports (that we could input from)? */
         clientPorts = jack_get_ports( jackApi->jack_client, regex_pattern,
-                                     NULL, JackPortIsOutput);
+                                     JACK_PORT_TYPE_FILTER, JackPortIsOutput);
         curDevInfo->maxInputChannels = 0;
         curDevInfo->defaultLowInputLatency = 0.;
         curDevInfo->defaultHighInputLatency = 0.;
@@ -604,7 +608,7 @@ static PaError BuildDeviceList( PaJackHostApiRepresentation *jackApi )
 
         /* ... what are your input ports (that we could output to)? */
         clientPorts = jack_get_ports( jackApi->jack_client, regex_pattern,
-                                     NULL, JackPortIsInput);
+                                     JACK_PORT_TYPE_FILTER, JackPortIsInput);
         curDevInfo->maxOutputChannels = 0;
         curDevInfo->defaultLowOutputLatency = 0.;
         curDevInfo->defaultHighOutputLatency = 0.;
@@ -1235,7 +1239,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
         /* Get output ports of our capture device */
         snprintf( regex_pattern, regexSz, "%s:.*", hostApi->deviceInfos[ inputParameters->device ]->name );
         UNLESS( jack_ports = jack_get_ports( jackHostApi->jack_client, regex_pattern,
-                                     NULL, JackPortIsOutput ), paUnanticipatedHostError );
+                                     JACK_PORT_TYPE_FILTER, JackPortIsOutput ), paUnanticipatedHostError );
         for( i = 0; i < inputChannelCount && jack_ports[i]; i++ )
         {
             if( (stream->remote_output_ports[i] = jack_port_by_name(
@@ -1259,7 +1263,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
         /* Get input ports of our playback device */
         snprintf( regex_pattern, regexSz, "%s:.*", hostApi->deviceInfos[ outputParameters->device ]->name );
         UNLESS( jack_ports = jack_get_ports( jackHostApi->jack_client, regex_pattern,
-                                     NULL, JackPortIsInput ), paUnanticipatedHostError );
+                                     JACK_PORT_TYPE_FILTER, JackPortIsInput ), paUnanticipatedHostError );
         for( i = 0; i < outputChannelCount && jack_ports[i]; i++ )
         {
             if( (stream->remote_input_ports[i] = jack_port_by_name(