void JackProxyDriver::connect_callback(jack_port_id_t a, jack_port_id_t b, int connect) { jack_port_t* port; int i; // skip port if not our own port = jack_port_by_id(fClient, a); if (!jack_port_is_mine(fClient, port)) { port = jack_port_by_id(fClient, b); if (!jack_port_is_mine(fClient, port)) { return; } } for (i = 0; i < fCaptureChannels; i++) { if (fUpstreamPlaybackPorts[i] == port) { fUpstreamPlaybackPortConnected[i] = connect; } } for (i = 0; i < fPlaybackChannels; i++) { if (fUpstreamCapturePorts[i] == port) { fUpstreamCapturePortConnected[i] = connect; } } }
/* handle jack port connection change */ void Chain::port_connect ( jack_port_id_t a, jack_port_id_t b, int connect ) { if ( _deleting ) return; /* this is called from JACK non-RT thread... */ if ( jack_port_is_mine( client()->jack_client(), jack_port_by_id( client()->jack_client(), a ) ) || jack_port_is_mine( client()->jack_client(), jack_port_by_id( client()->jack_client(), b ) )) { Fl::awake( Chain::update_connection_status, this ); } }
static PyObject* port_is_mine(PyObject* self, PyObject* args) { char * port_name; if (! PyArg_ParseTuple(args, "s", &port_name)) return NULL; if (port_name == NULL) { PyErr_SetString(JackError, "Port name cannot be empty."); return NULL; } pyjack_client_t * client = self_or_global_client(self); if(client->pjc == NULL) { PyErr_SetString(JackNotConnectedError, "Jack connection has not yet been established."); return NULL; } jack_port_t * port = jack_port_by_name(client->pjc, port_name); if (!port) { PyErr_SetString(JackError, "Port name cannot be empty."); return NULL; } int port_mine = jack_port_is_mine(client->pjc, port); return Py_BuildValue("i", port_mine); }
// connect_port static PyObject* port_connect(PyObject* self, PyObject* args) { char* src_name; char* dst_name; pyjack_client_t * client = self_or_global_client(self); if(client->pjc == NULL) { PyErr_SetString(JackNotConnectedError, "Jack connection has not yet been established."); return NULL; } if (! PyArg_ParseTuple(args, "ss", &src_name, &dst_name)) return NULL; jack_port_t * src = jack_port_by_name(client->pjc, src_name); if (!src) { PyErr_SetString(JackUsageError, "Non existing source port."); return NULL; } jack_port_t * dst = jack_port_by_name(client->pjc, dst_name); if (!dst) { PyErr_SetString(JackUsageError, "Non existing destination port."); return NULL; } if(! client->active) { if(jack_port_is_mine(client->pjc, src) || jack_port_is_mine(client->pjc, dst)) { PyErr_SetString(JackUsageError, "Jack client must be activated to connect own ports."); return NULL; } } int error = jack_connect(client->pjc, src_name, dst_name); if (error !=0 && error != EEXIST) { PyErr_SetString(JackError, "Failed to connect ports."); return NULL; } Py_INCREF(Py_None); return Py_None; }