|
|
@@ -736,6 +736,35 @@ int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// this check is to prevent apps to self connect to other apps |
|
|
|
// TODO: make this work with multiple clients per app |
|
|
|
int JackEngine::CheckPortsConnect(int refnum, jack_port_id_t src, jack_port_id_t dst) |
|
|
|
{ |
|
|
|
JackPort* src_port = fGraphManager->GetPort(src); |
|
|
|
JackPort* dst_port = fGraphManager->GetPort(dst); |
|
|
|
|
|
|
|
jack_info("CheckPortsConnect(caller = %d, src = %d, dst = %d)", refnum, src_port->GetRefNum(), dst_port->GetRefNum()); |
|
|
|
|
|
|
|
int src_self = src_port->GetRefNum() == refnum ? 1 : 0; |
|
|
|
int dst_self = dst_port->GetRefNum() == refnum ? 1 : 0; |
|
|
|
|
|
|
|
jack_info("src_self is %s", src_self ? "true" : "false"); |
|
|
|
jack_info("dst_self is %s", dst_self ? "true" : "false"); |
|
|
|
|
|
|
|
// 0 means client is connecting other client ports (i.e. control app patchbay functionality) |
|
|
|
// 1 means client is connecting its own port to port of other client (i.e. self hooking into system app) |
|
|
|
// 2 means client is connecting its own ports (i.e. for app internal functionality) |
|
|
|
// TODO: Make this check an engine option and more tweakable (return error or success) |
|
|
|
// MAYBE: make the engine option changable on the fly and expose it through client or control API |
|
|
|
if (src_self + dst_self != 0) |
|
|
|
{ |
|
|
|
jack_info("ignoring port self connect request"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
int JackEngine::PortConnect(int refnum, const char* src, const char* dst) |
|
|
|
{ |
|
|
|
jack_log("JackEngine::PortConnect src = %s dst = %s", src, dst); |
|
|
@@ -776,7 +805,12 @@ int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst) |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
int res = fGraphManager->Connect(src, dst); |
|
|
|
int res = CheckPortsConnect(refnum, src, dst); |
|
|
|
if (res != 1) { |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
res = fGraphManager->Connect(src, dst); |
|
|
|
if (res == 0) |
|
|
|
NotifyPortConnect(src, dst, true); |
|
|
|
return res; |
|
|
@@ -820,15 +854,21 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
} else if (fGraphManager->CheckPorts(src, dst) < 0) { |
|
|
|
return -1; |
|
|
|
} else if (fGraphManager->Disconnect(src, dst) == 0) { |
|
|
|
// Notifications |
|
|
|
NotifyPortConnect(src, dst, false); |
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
if (fGraphManager->CheckPorts(src, dst) < 0) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
int res = CheckPortsConnect(refnum, src, dst); |
|
|
|
if (res != 1) { |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
res = fGraphManager->Disconnect(src, dst); |
|
|
|
if (res == 0) |
|
|
|
NotifyPortConnect(src, dst, false); |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
int JackEngine::PortRename(int refnum, jack_port_id_t port, const char* name) |
|
|
|