Commit 0cdfce24 authored by sletz's avatar sletz
Browse files

Finish port connection callback server side implementation.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1808 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 1afbf147
......@@ -20,6 +20,7 @@ Tim Blechmann
2008-02-01 Stephane Letz <letz@grame.fr>
* Move transport related methods from JackEngine to JackServer.
* Finish port connection callback server side implementation.
2008-01-31 Stephane Letz <letz@grame.fr>
......
......@@ -660,16 +660,6 @@ int JackEngine::PortConnect(int refnum, const char* src, const char* dst)
: PortConnect(refnum, port_src, port_dst);
}
int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst)
{
JackLog("JackEngine::PortDisconnect src = %s dst = %s\n", src, dst);
jack_port_id_t port_src, port_dst;
return (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0)
? -1
: fGraphManager->Disconnect(port_src, port_dst);
}
int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
{
JackLog("JackEngine::PortConnect src = %d dst = %d\n", src, dst);
......@@ -705,33 +695,49 @@ int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
return res;
}
int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst)
{
JackLog("JackEngine::PortDisconnect src = %s dst = %s\n", src, dst);
jack_port_id_t port_src, port_dst;
if (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0) {
return -1;
} else if (fGraphManager->Disconnect(port_src, port_dst) == 0){
NotifyPortConnect(port_src, port_dst, false);
return 0;
} else {
return -1;
}
}
int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
{
JackLog("JackEngine::PortDisconnect src = %d dst = %d\n", src, dst);
if (dst == ALL_PORTS) {
/*
jack_int_t connections[CONNECTION_NUM];
JackPort* port = fGraphManager->GetPort(src);
jack_int_t connections[CONNECTION_NUM];
fGraphManager->GetConnections(src, connections);
if (fGraphManager->DisconnectAll(src) < 0)
return -1;
if (port->fFlags & JackPortIsOutput) {
// Notifications
JackPort* port = fGraphManager->GetPort(src);
if (port->GetFlags() & JackPortIsOutput) {
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) {
JackLog("NotifyPortConnect src = %ld dst = %ld\n false", src, connections[i]);
NotifyPortConnect(src, connections[i], false);
}
} else {
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) {
JackLog("NotifyPortConnect src = %ld dst = %ld\n false", connections[i], src);
NotifyPortConnect(connections[i], src, false);
}
}
*/
return fGraphManager->DisconnectAll(src);
} else if (fGraphManager->CheckPorts(src, dst) < 0) {
return -1;
} else if (fGraphManager->Disconnect(src, dst) == 0) {
// Notifications
NotifyPortConnect(src, dst, false);
return 0;
} else {
......
......@@ -225,6 +225,11 @@ void Jack_Port_Register(jack_port_id_t port, int mode, void *arg)
port_callback_reg++;
}
void Jack_Port_Connect(jack_port_id_t a, jack_port_id_t b, int connect, void* arg)
{
Log("PortConnect src = %ld dst = %ld onoff = %ld (msg from callback)\n", a, b, connect);
}
int Jack_Sync_Callback(jack_transport_state_t state, jack_position_t *pos, void *arg)
{
int res = 0;
......@@ -662,6 +667,10 @@ int main (int argc, char *argv[])
printf("Error when calling jack_set_port_registration_callback() !\n");
}
if (jack_set_port_connect_callback(client1, Jack_Port_Connect, 0) != 0) {
printf("Error when calling jack_set_port_connect_callback() !\n");
}
if (jack_set_client_registration_callback(client1, Jack_Client_Registration_Callback, 0) != 0) {
printf("Error when calling jack_set_client_registration_callback() !\n");
}
......@@ -767,9 +776,9 @@ int main (int argc, char *argv[])
*/
if (jack_activate(client1) < 0) {
printf ("Fatal error : cannot activate client1\n");
exit (1);
exit(1);
}
/**
* Test if init callback initThread have been called.
*
......@@ -1117,7 +1126,7 @@ int main (int argc, char *argv[])
}
// Check client registration callback
sleep(1);
jack_sleep(1000);
if (client_register == 0)
printf("!!! ERROR !!! Client registration callback not called!\n");
......@@ -1599,6 +1608,8 @@ int main (int argc, char *argv[])
jack_port_disconnect(client1, input_port2);
jack_port_disconnect(client1, output_port1);
jack_port_disconnect(client1, output_port2);
jack_sleep(1000);
free(inports);
free(outports);
......@@ -1825,7 +1836,7 @@ int main (int argc, char *argv[])
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*/
*/
if (jack_deactivate(client2) != 0) {
printf("!!! ERROR !!! jack_deactivate does not return 0 for client2 !\n");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment