diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index d7872a85..b82d0ca7 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -677,15 +677,17 @@ int JackEngine::ClientActivate(int refnum, bool is_real_time) fGraphManager->ActivatePort(output_ports[i]); } + // Notify client + NotifyActivate(refnum); + // Then issue port registration notification - for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY) ; i++) { + for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) { NotifyPortRegistation(input_ports[i], true); } - for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY) ; i++) { + for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) { NotifyPortRegistation(output_ports[i], true); } - NotifyActivate(refnum); return 0; } } @@ -744,6 +746,7 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns jack_log("JackEngine::PortRegister ref = %ld name = %s type = %s flags = %d buffer_size = %d", refnum, name, type, flags, buffer_size); AssertRefnum(refnum); assert(fClientTable[refnum]); + JackClientInterface* client = fClientTable[refnum]; // Check if port name already exists if (fGraphManager->GetPort(name) != NO_PORT) { @@ -753,6 +756,8 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns *port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, fEngineControl->fBufferSize); if (*port_index != NO_PORT) { + if (client->GetClientControl()->fActive) + NotifyPortRegistation(*port_index, true); return 0; } else { return -1; @@ -764,11 +769,14 @@ int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index) jack_log("JackEngine::PortUnRegister ref = %ld port_index = %ld", refnum, port_index); AssertRefnum(refnum); assert(fClientTable[refnum]); + JackClientInterface* client = fClientTable[refnum]; // Disconnect port ==> notification is sent PortDisconnect(refnum, port_index, ALL_PORTS); if (fGraphManager->ReleasePort(refnum, port_index) == 0) { + if (client->GetClientControl()->fActive) + NotifyPortRegistation(port_index, false); return 0; } else { return -1; diff --git a/tests/test.cpp b/tests/test.cpp index 1c558bc2..9477d731 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -821,6 +821,8 @@ int main (int argc, char *argv[]) printf("error : port_set_name function can't be tested...\n"); } + port_callback_reg = 0; // number of port registration received by the callback + /** * Activate the client * @@ -839,6 +841,20 @@ int main (int argc, char *argv[]) if (port_rename_clbk == 0) printf("!!! ERROR !!! Jack_Port_Rename_Callback was not called !!.\n"); + + + /** + * Test if portregistration callback have been called. + * + */ + + jack_sleep(1 * 1000); + + if (1 == port_callback_reg) { + Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", 1, port_callback_reg); + } else { + printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", 1, port_callback_reg); + } /** * Test if init callback initThread have been called. @@ -1094,11 +1110,14 @@ int main (int argc, char *argv[]) } jack_sleep(1 * 1000); // To hope all port registration and reorder callback have been received... + + // Check port registration callback if (j == port_callback_reg) { Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", j, port_callback_reg); } else { - printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", j, k); + printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", j, port_callback_reg); } + if (reorder == (2 * j)) { Log("%i graph reorder callback have been received... ok\n", reorder); } else { @@ -1146,6 +1165,7 @@ int main (int argc, char *argv[]) * Deregister all ports previously created. * */ + port_callback_reg = 0; // to check registration callback Log("Deregistering all ports of the client...\n"); inports = jack_get_ports(client1, NULL, NULL, 0); a = 0; @@ -1159,6 +1179,13 @@ int main (int argc, char *argv[]) } a++; } + + // Check port registration callback again + if (j == port_callback_reg) { + Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", j, port_callback_reg); + } else { + printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", j, port_callback_reg); + } free(inports); // free array of ports (as mentionned in the doc of jack_get_ports)