Browse Source

Jack: allow unconnected streams to have more ports than device

tags/5.1.0
JP Cimalando 6 years ago
parent
commit
7aa565412b
1 changed files with 23 additions and 21 deletions
  1. +23
    -21
      RtAudio.cpp

+ 23
- 21
RtAudio.cpp View File

@@ -1973,7 +1973,7 @@ unsigned int RtApiJack :: getDeviceCount( void )
const char **ports;
std::string port, previousPort;
unsigned int nChannels = 0, nDevices = 0;
ports = jack_get_ports( client, NULL, NULL, 0 );
ports = jack_get_ports( client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0 );
if ( ports ) {
// Parse the port names up to the first colon (:).
size_t iColon = 0;
@@ -2012,7 +2012,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
const char **ports;
std::string port, previousPort;
unsigned int nPorts = 0, nDevices = 0;
ports = jack_get_ports( client, NULL, NULL, 0 );
ports = jack_get_ports( client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0 );
if ( ports ) {
// Parse the port names up to the first colon (:).
size_t iColon = 0;
@@ -2047,7 +2047,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
// Count the available ports containing the client name as device
// channels. Jack "input ports" equal RtAudio output channels.
unsigned int nChannels = 0;
ports = jack_get_ports( client, info.name.c_str(), NULL, JackPortIsInput );
ports = jack_get_ports( client, info.name.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput );
if ( ports ) {
while ( ports[ nChannels ] ) nChannels++;
free( ports );
@@ -2056,7 +2056,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )

// Jack "output ports" equal RtAudio input channels.
nChannels = 0;
ports = jack_get_ports( client, info.name.c_str(), NULL, JackPortIsOutput );
ports = jack_get_ports( client, info.name.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput );
if ( ports ) {
while ( ports[ nChannels ] ) nChannels++;
free( ports );
@@ -2168,7 +2168,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
const char **ports;
std::string port, previousPort, deviceName;
unsigned int nPorts = 0, nDevices = 0;
ports = jack_get_ports( client, NULL, NULL, 0 );
ports = jack_get_ports( client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0 );
if ( ports ) {
// Parse the port names up to the first colon (:).
size_t iColon = 0;
@@ -2192,22 +2192,24 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
return FAILURE;
}

// Count the available ports containing the client name as device
// channels. Jack "input ports" equal RtAudio output channels.
unsigned int nChannels = 0;
unsigned long flag = JackPortIsInput;
if ( mode == INPUT ) flag = JackPortIsOutput;
ports = jack_get_ports( client, deviceName.c_str(), NULL, flag );
if ( ports ) {
while ( ports[ nChannels ] ) nChannels++;
free( ports );
}

// Compare the jack ports for specified client to the requested number of channels.
if ( nChannels < (channels + firstChannel) ) {
errorStream_ << "RtApiJack::probeDeviceOpen: requested number of channels (" << channels << ") + offset (" << firstChannel << ") not found for specified device (" << device << ":" << deviceName << ").";
errorText_ = errorStream_.str();
return FAILURE;
if ( ! (options && (options->flags & RTAUDIO_JACK_DONT_CONNECT)) ) {
// Count the available ports containing the client name as device
// channels. Jack "input ports" equal RtAudio output channels.
unsigned int nChannels = 0;
ports = jack_get_ports( client, deviceName.c_str(), JACK_DEFAULT_AUDIO_TYPE, flag );
if ( ports ) {
while ( ports[ nChannels ] ) nChannels++;
free( ports );
}
// Compare the jack ports for specified client to the requested number of channels.
if ( nChannels < (channels + firstChannel) ) {
errorStream_ << "RtApiJack::probeDeviceOpen: requested number of channels (" << channels << ") + offset (" << firstChannel << ") not found for specified device (" << device << ":" << deviceName << ").";
errorText_ = errorStream_.str();
return FAILURE;
}
}

// Check the jack server sample rate.
@@ -2221,7 +2223,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
stream_.sampleRate = jackRate;

// Get the latency of the JACK port.
ports = jack_get_ports( client, deviceName.c_str(), NULL, flag );
ports = jack_get_ports( client, deviceName.c_str(), JACK_DEFAULT_AUDIO_TYPE, flag );
if ( ports[ firstChannel ] ) {
// Added by Ge Wang
jack_latency_callback_mode_t cbmode = (mode == INPUT ? JackCaptureLatency : JackPlaybackLatency);
@@ -2453,7 +2455,7 @@ void RtApiJack :: startStream( void )
// Get the list of available ports.
if ( shouldAutoconnect_ && (stream_.mode == OUTPUT || stream_.mode == DUPLEX) ) {
result = 1;
ports = jack_get_ports( handle->client, handle->deviceName[0].c_str(), NULL, JackPortIsInput);
ports = jack_get_ports( handle->client, handle->deviceName[0].c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput);
if ( ports == NULL) {
errorText_ = "RtApiJack::startStream(): error determining available JACK input ports!";
goto unlock;
@@ -2477,7 +2479,7 @@ void RtApiJack :: startStream( void )

if ( shouldAutoconnect_ && (stream_.mode == INPUT || stream_.mode == DUPLEX) ) {
result = 1;
ports = jack_get_ports( handle->client, handle->deviceName[1].c_str(), NULL, JackPortIsOutput );
ports = jack_get_ports( handle->client, handle->deviceName[1].c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput );
if ( ports == NULL) {
errorText_ = "RtApiJack::startStream(): error determining available JACK output ports!";
goto unlock;


Loading…
Cancel
Save