int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst) { jack_log("JackEngine::PortDisconnect ref = %d src = %d dst = %d", refnum, src, dst); if (dst == ALL_PORTS) { jack_int_t connections[CONNECTION_NUM_FOR_PORT]; fGraphManager->GetConnections(src, connections); JackPort* port = fGraphManager->GetPort(src); int res = 0; if (port->GetFlags() & JackPortIsOutput) { for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) { if (PortDisconnect(refnum, src, connections[i]) != 0) { res = -1; } } } else { for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) { if (PortDisconnect(refnum, connections[i], src) != 0) { res = -1; } } } return res; } 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 JackClient::HandleLatencyCallback(int status) { jack_latency_callback_mode_t mode = (status == 0) ? JackCaptureLatency : JackPlaybackLatency; jack_latency_range_t latency = { UINT32_MAX, 0 }; /* first setup all latency values of the ports. * this is based on the connections of the ports. */ list<jack_port_id_t>::iterator it; for (it = fPortList.begin(); it != fPortList.end(); it++) { JackPort* port = GetGraphManager()->GetPort(*it); if ((port->GetFlags() & JackPortIsOutput) && (mode == JackPlaybackLatency)) { GetGraphManager()->RecalculateLatency(*it, mode); } if ((port->GetFlags() & JackPortIsInput) && (mode == JackCaptureLatency)) { GetGraphManager()->RecalculateLatency(*it, mode); } } if (!fLatency) { /* * default action is to assume all ports depend on each other. * then always take the maximum latency. */ if (mode == JackPlaybackLatency) { /* iterate over all OutputPorts, to find maximum playback latency */ for (it = fPortList.begin(); it != fPortList.end(); it++) { JackPort* port = GetGraphManager()->GetPort(*it); if (port->GetFlags() & JackPortIsOutput) { jack_latency_range_t other_latency; port->GetLatencyRange(mode, &other_latency); if (other_latency.max > latency.max) { latency.max = other_latency.max; } if (other_latency.min < latency.min) { latency.min = other_latency.min; } } } if (latency.min == UINT32_MAX) { latency.min = 0; } /* now set the found latency on all input ports */ for (it = fPortList.begin(); it != fPortList.end(); it++) { JackPort* port = GetGraphManager()->GetPort(*it); if (port->GetFlags() & JackPortIsInput) { port->SetLatencyRange(mode, &latency); } } } if (mode == JackCaptureLatency) { /* iterate over all InputPorts, to find maximum playback latency */ for (it = fPortList.begin(); it != fPortList.end(); it++) { JackPort* port = GetGraphManager()->GetPort(*it); if (port->GetFlags() & JackPortIsInput) { jack_latency_range_t other_latency; port->GetLatencyRange(mode, &other_latency); if (other_latency.max > latency.max) { latency.max = other_latency.max; } if (other_latency.min < latency.min) { latency.min = other_latency.min; } } } if (latency.min == UINT32_MAX) { latency.min = 0; } /* now set the found latency on all output ports */ for (it = fPortList.begin(); it != fPortList.end(); it++) { JackPort* port = GetGraphManager()->GetPort(*it); if (port->GetFlags() & JackPortIsOutput) { port->SetLatencyRange(mode, &latency); } } } return 0; } /* we have a latency callback setup by the client, * lets use it... */ fLatency(mode, fLatencyArg); return 0; }