Merge pull request #33 from djpohly/jack-fixes
Fixes for JACK driver port detection
This commit is contained in:
@@ -113,15 +113,20 @@ RString RageSoundDriver_JACK::ConnectPorts()
|
|||||||
vector<RString> portNames;
|
vector<RString> portNames;
|
||||||
split(PREFSMAN->m_iSoundDevice.Get(), ",", portNames, true);
|
split(PREFSMAN->m_iSoundDevice.Get(), ",", portNames, true);
|
||||||
|
|
||||||
const char *port_out_l, *port_out_r;
|
const char *port_out_l = NULL, *port_out_r = NULL;
|
||||||
|
const char **ports = NULL;
|
||||||
if( portNames.size() == 0 )
|
if( portNames.size() == 0 )
|
||||||
{
|
{
|
||||||
// The user has NOT specified any ports to connect to. Search
|
// The user has NOT specified any ports to connect to. Search
|
||||||
// for all physical sinks and use the first two.
|
// for all physical sinks and use the first two.
|
||||||
const char **ports;
|
|
||||||
ports = jack_get_ports( client, NULL, NULL, JackPortIsInput | JackPortIsPhysical );
|
ports = jack_get_ports( client, NULL, NULL, JackPortIsInput | JackPortIsPhysical );
|
||||||
|
if( ports == NULL )
|
||||||
|
return "Couldn't get JACK ports";
|
||||||
if( ports[0] == NULL )
|
if( ports[0] == NULL )
|
||||||
|
{
|
||||||
|
jack_free( ports );
|
||||||
return "No physical sinks!";
|
return "No physical sinks!";
|
||||||
|
}
|
||||||
port_out_l = ports[0];
|
port_out_l = ports[0];
|
||||||
|
|
||||||
if( ports[1] == NULL )
|
if( ports[1] == NULL )
|
||||||
@@ -143,7 +148,8 @@ RString RageSoundDriver_JACK::ConnectPorts()
|
|||||||
{
|
{
|
||||||
jack_port_t *out = jack_port_by_name( client, *portName );
|
jack_port_t *out = jack_port_by_name( client, *portName );
|
||||||
// Make sure the port is a sink.
|
// Make sure the port is a sink.
|
||||||
if( ! jack_port_flags( out ) & JackPortIsInput ) continue;
|
if( ! ( jack_port_flags( out ) & JackPortIsInput ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( out != NULL )
|
if( out != NULL )
|
||||||
{
|
{
|
||||||
@@ -166,11 +172,13 @@ RString RageSoundDriver_JACK::ConnectPorts()
|
|||||||
|
|
||||||
RString ret = RString();
|
RString ret = RString();
|
||||||
|
|
||||||
if ( jack_connect( client, jack_port_name(port_l), port_out_l ) != 0 )
|
if( jack_connect( client, jack_port_name(port_l), port_out_l ) != 0 )
|
||||||
ret = "Couldn't connect left JACK port";
|
ret = "Couldn't connect left JACK port";
|
||||||
|
else if( jack_connect( client, jack_port_name(port_r), port_out_r ) != 0 )
|
||||||
|
ret = "Couldn't connect right JACK port";
|
||||||
|
|
||||||
if( jack_connect( client, jack_port_name(port_r), port_out_r ) != 0 )
|
if( ports != NULL )
|
||||||
if( ret == "") ret = "Couldn't connect right JACK port";
|
jack_free( ports );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user