From db894326e722c5554cbaa583d5abc2e6e452dc89 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 21:28:57 -0500 Subject: [PATCH 1/2] fix port-choosing logic in JACK driver --- src/arch/Sound/RageSoundDriver_JACK.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/arch/Sound/RageSoundDriver_JACK.cpp b/src/arch/Sound/RageSoundDriver_JACK.cpp index c7566e81fa..34eeae8646 100644 --- a/src/arch/Sound/RageSoundDriver_JACK.cpp +++ b/src/arch/Sound/RageSoundDriver_JACK.cpp @@ -113,7 +113,7 @@ RString RageSoundDriver_JACK::ConnectPorts() vector portNames; 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; if( portNames.size() == 0 ) { // The user has NOT specified any ports to connect to. Search @@ -143,7 +143,8 @@ RString RageSoundDriver_JACK::ConnectPorts() { jack_port_t *out = jack_port_by_name( client, *portName ); // Make sure the port is a sink. - if( ! jack_port_flags( out ) & JackPortIsInput ) continue; + if( ! ( jack_port_flags( out ) & JackPortIsInput ) ) + continue; if( out != NULL ) { From b2744946c9e32757c6c4d27e79392acf086bcc2b Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 8 Feb 2014 21:35:43 -0500 Subject: [PATCH 2/2] fix memory leak in JACK driver --- src/arch/Sound/RageSoundDriver_JACK.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/arch/Sound/RageSoundDriver_JACK.cpp b/src/arch/Sound/RageSoundDriver_JACK.cpp index 34eeae8646..0b18cf4757 100644 --- a/src/arch/Sound/RageSoundDriver_JACK.cpp +++ b/src/arch/Sound/RageSoundDriver_JACK.cpp @@ -114,14 +114,19 @@ RString RageSoundDriver_JACK::ConnectPorts() split(PREFSMAN->m_iSoundDevice.Get(), ",", portNames, true); const char *port_out_l = NULL, *port_out_r = NULL; + const char **ports = NULL; if( portNames.size() == 0 ) { // The user has NOT specified any ports to connect to. Search // for all physical sinks and use the first two. - const char **ports; ports = jack_get_ports( client, NULL, NULL, JackPortIsInput | JackPortIsPhysical ); + if( ports == NULL ) + return "Couldn't get JACK ports"; if( ports[0] == NULL ) + { + jack_free( ports ); return "No physical sinks!"; + } port_out_l = ports[0]; if( ports[1] == NULL ) @@ -167,11 +172,13 @@ RString RageSoundDriver_JACK::ConnectPorts() 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"; + 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( ret == "") ret = "Couldn't connect right JACK port"; + if( ports != NULL ) + jack_free( ports ); return ret; }