a JACK-specific flag to disable automatic connection of ports
authorJP Cimalando <jp-dev@inbox.ru>
Tue, 26 Jul 2016 07:58:47 +0000 (09:58 +0200)
committerJP Cimalando <jp-dev@inbox.ru>
Tue, 26 Jul 2016 07:58:47 +0000 (09:58 +0200)
RtAudio.cpp
RtAudio.h

index 882fa0e2830202407c2f17814c8a4e372947993d..d41c408f4c632bc85bfea778d6f996c4b46a6139 100644 (file)
@@ -1943,7 +1943,7 @@ struct JackHandle {
 static void jackSilentError( const char * ) {};\r
 \r
 RtApiJack :: RtApiJack()\r
 static void jackSilentError( const char * ) {};\r
 \r
 RtApiJack :: RtApiJack()\r
-{\r
+    :shouldAutoconnect_(true) {\r
   // Nothing to do here.\r
 #if !defined(__RTAUDIO_DEBUG__)\r
   // Turn off Jack's internal error reporting.\r
   // Nothing to do here.\r
 #if !defined(__RTAUDIO_DEBUG__)\r
   // Turn off Jack's internal error reporting.\r
@@ -2354,6 +2354,8 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
   // here.\r
   if ( stream_.doConvertBuffer[mode] ) setConvertInfo( mode, 0 );\r
 \r
   // here.\r
   if ( stream_.doConvertBuffer[mode] ) setConvertInfo( mode, 0 );\r
 \r
+  if ( options && options->flags & RTAUDIO_JACK_DONT_CONNECT ) shouldAutoconnect_ = false;\r
+\r
   return SUCCESS;\r
 \r
  error:\r
   return SUCCESS;\r
 \r
  error:\r
@@ -2443,7 +2445,7 @@ void RtApiJack :: startStream( void )
   const char **ports;\r
 \r
   // Get the list of available ports.\r
   const char **ports;\r
 \r
   // Get the list of available ports.\r
-  if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {\r
+  if ( shouldAutoconnect_ && (stream_.mode == OUTPUT || stream_.mode == DUPLEX) ) {\r
     result = 1;\r
     ports = jack_get_ports( handle->client, handle->deviceName[0].c_str(), NULL, JackPortIsInput);\r
     if ( ports == NULL) {\r
     result = 1;\r
     ports = jack_get_ports( handle->client, handle->deviceName[0].c_str(), NULL, JackPortIsInput);\r
     if ( ports == NULL) {\r
@@ -2467,7 +2469,7 @@ void RtApiJack :: startStream( void )
     free(ports);\r
   }\r
 \r
     free(ports);\r
   }\r
 \r
-  if ( stream_.mode == INPUT || stream_.mode == DUPLEX ) {\r
+  if ( shouldAutoconnect_ && (stream_.mode == INPUT || stream_.mode == DUPLEX) ) {\r
     result = 1;\r
     ports = jack_get_ports( handle->client, handle->deviceName[1].c_str(), NULL, JackPortIsOutput );\r
     if ( ports == NULL) {\r
     result = 1;\r
     ports = jack_get_ports( handle->client, handle->deviceName[1].c_str(), NULL, JackPortIsOutput );\r
     if ( ports == NULL) {\r
index 11345cc6d8a72f2ea35f6d5abf44c02e266d150a..dea39f0745c4c326c7c3341890c1a7ffad0f46ee 100644 (file)
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -86,6 +86,7 @@ static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/mi
     - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency.
     - \e RTAUDIO_HOG_DEVICE:       Attempt grab device for exclusive use.
     - \e RTAUDIO_ALSA_USE_DEFAULT: Use the "default" PCM device (ALSA only).
     - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency.
     - \e RTAUDIO_HOG_DEVICE:       Attempt grab device for exclusive use.
     - \e RTAUDIO_ALSA_USE_DEFAULT: Use the "default" PCM device (ALSA only).
+    - \e RTAUDIO_JACK_DONT_CONNECT: Do not automatically connect ports (JACK only).
 
     By default, RtAudio streams pass and receive audio data from the
     client in an interleaved format.  By passing the
 
     By default, RtAudio streams pass and receive audio data from the
     client in an interleaved format.  By passing the
@@ -117,6 +118,9 @@ static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/mi
     If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to
     open the "default" PCM device when using the ALSA API. Note that this
     will override any specified input or output device id.
     If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to
     open the "default" PCM device when using the ALSA API. Note that this
     will override any specified input or output device id.
+
+    If the RTAUDIO_JACK_DONT_CONNECT flag is set, RtAudio will not attempt
+    to automatically connect the ports of the client to the audio device.
 */
 typedef unsigned int RtAudioStreamFlags;
 static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1;    // Use non-interleaved buffers (default = interleaved).
 */
 typedef unsigned int RtAudioStreamFlags;
 static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1;    // Use non-interleaved buffers (default = interleaved).
@@ -124,6 +128,7 @@ static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2;  // Attempt to s
 static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4;        // Attempt grab device and prevent use by others.
 static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread.
 static const RtAudioStreamFlags RTAUDIO_ALSA_USE_DEFAULT = 0x10; // Use the "default" PCM device (ALSA only).
 static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4;        // Attempt grab device and prevent use by others.
 static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread.
 static const RtAudioStreamFlags RTAUDIO_ALSA_USE_DEFAULT = 0x10; // Use the "default" PCM device (ALSA only).
+static const RtAudioStreamFlags RTAUDIO_JACK_DONT_CONNECT = 0x20; // Do not automatically connect ports (JACK only).
 
 /*! \typedef typedef unsigned long RtAudioStreamStatus;
     \brief RtAudio stream status (over- or underflow) flags.
 
 /*! \typedef typedef unsigned long RtAudioStreamStatus;
     \brief RtAudio stream status (over- or underflow) flags.
@@ -912,6 +917,8 @@ public:
                         unsigned int firstChannel, unsigned int sampleRate,
                         RtAudioFormat format, unsigned int *bufferSize,
                         RtAudio::StreamOptions *options );
                         unsigned int firstChannel, unsigned int sampleRate,
                         RtAudioFormat format, unsigned int *bufferSize,
                         RtAudio::StreamOptions *options );
+
+  bool shouldAutoconnect_;
 };
 
 #endif
 };
 
 #endif