Commit f1631119 authored by sletz's avatar sletz
Browse files

Fix port_rename callback : now both old name and new name are given as parameters.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3835 0c269be4-1314-0410-8aa9-9f06e86f4224
parent efe1ddd3
......@@ -27,6 +27,10 @@ Devin Anderson
Jackdmp changes log
---------------------------
2009-12-01 Stephane Letz <letz@grame.fr>
* Fix port_rename callback : now both old name and new name are given as parameters.
2009-11-30 Stephane Letz <letz@grame.fr>
* Devin Anderson patch for Jack FFADO driver issues with lost MIDI bytes between periods (and more).
......
......@@ -254,7 +254,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
case kPortRenameCallback:
jack_log("JackClient::kPortRenameCallback port = %ld");
if (fPortRename) {
fPortRename(value1, GetGraphManager()->GetPort(value1)->GetName(), fPortRenameArg);
fPortRename(value1, message, GetGraphManager()->GetPort(value1)->GetName(), fPortRenameArg);
}
break;
......
......@@ -322,9 +322,9 @@ void JackEngine::NotifyPortRegistation(jack_port_id_t port_index, bool onoff)
NotifyClients((onoff ? kPortRegistrationOnCallback : kPortRegistrationOffCallback), false, "", port_index, 0);
}
void JackEngine::NotifyPortRename(jack_port_id_t port)
void JackEngine::NotifyPortRename(jack_port_id_t port, const char* old_name)
{
NotifyClients(kPortRenameCallback, false, "", port, 0);
NotifyClients(kPortRenameCallback, false, old_name, port, 0);
}
void JackEngine::NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff)
......@@ -846,8 +846,10 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds
int JackEngine::PortRename(int refnum, jack_port_id_t port, const char* name)
{
AssertRefnum(refnum);
char old_name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
strcpy(old_name, fGraphManager->GetPort(port)->GetName());
fGraphManager->GetPort(port)->SetName(name);
NotifyPortRename(port);
NotifyPortRename(port, old_name);
return 0;
}
......
......@@ -69,7 +69,7 @@ class SERVER_EXPORT JackEngine
void NotifyPortRegistation(jack_port_id_t port_index, bool onoff);
void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff);
void NotifyPortRename(jack_port_id_t src);
void NotifyPortRename(jack_port_id_t src, const char* old_name);
void NotifyActivate(int refnum);
public:
......
......@@ -202,7 +202,7 @@ typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int
*
* @return zero on success, non-zero on error
*/
typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* new_name, void *arg);
typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void *arg);
/**
* Prototype for the client supplied function that is called
......
......@@ -85,6 +85,7 @@ int reorder = 0; // graph reorder callback
int RT = 0; // is real time or not...
int FW = 0; // freewheel mode
int init_clbk = 0; // init callback
int port_rename_clbk = 0; // portrename callback
int i, j, k = 0;
int port_callback_reg = 0;
jack_nframes_t cur_buffer_size, old_buffer_size, cur_pos;
......@@ -180,6 +181,12 @@ void Jack_Client_Registration_Callback(const char* name, int val, void *arg)
client_register--;
}
int Jack_Port_Rename_Callback(jack_port_id_t port, const char* old_name, const char* new_name, void *arg)
{
Log("Rename callback has been successfully called with old_name '%s' and new_name '%s'. (msg from callback)\n");
port_rename_clbk = 1;
}
int Jack_Update_Buffer_Size(jack_nframes_t nframes, void *arg)
{
cur_buffer_size = jack_get_buffer_size(client1);
......@@ -679,6 +686,7 @@ int main (int argc, char *argv[])
printf("!!! ERROR !!! while calling jack_set_thread_init_callback()...\n");
if (jack_set_freewheel_callback(client1, Jack_Freewheel_Callback, 0) != 0 )
printf("\n!!! ERROR !!! while calling jack_set_freewheel_callback()...\n");
if (jack_set_process_callback(client1, process1, 0) != 0) {
printf("Error when calling jack_set_process_callback() !\n");
......@@ -694,6 +702,9 @@ int main (int argc, char *argv[])
if (jack_set_graph_order_callback(client1, Jack_Graph_Order_Callback, 0) != 0) {
printf("Error when calling Jack_Graph_Order_Callback() !\n");
}
if (jack_set_port_rename_callback(client1, Jack_Port_Rename_Callback, 0) != 0 )
printf("\n!!! ERROR !!! while calling jack_set_rename_callback()...\n");
if (jack_set_xrun_callback(client1, Jack_XRun_Callback, 0 ) != 0) {
printf("Error when calling jack_set_xrun_callback() !\n");
......@@ -818,13 +829,23 @@ int main (int argc, char *argv[])
printf ("Fatal error : cannot activate client1\n");
exit(1);
}
/**
* Test if portrename callback have been called.
*
*/
jack_port_set_name (output_port1, "renamed-port#");
jack_sleep(1 * 1000);
if (port_rename_clbk == 0)
printf("!!! ERROR !!! Jack_Port_Rename_Callback was not called !!.\n");
/**
* Test if init callback initThread have been called.
*
*/
if (init_clbk == 0)
printf("!!! ERROR !!! JackThreadInitCallback was not called !!.\n");
printf("!!! ERROR !!! Jack_Thread_Init_Callback was not called !!.\n");
jack_sleep(10 * 1000); // test see the clock in the graph at the begining...
......
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