diff --git a/ChangeLog b/ChangeLog index 6dc5ba6b..c3b4c4b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,11 +36,16 @@ Matt Flax Lars-Peter Clausen Alexandru Tofan Kim Jeong Yeon +Filipe Coelho --------------------------- Jackdmp changes log --------------------------- +2015-07-19 Filipe Coelho + + * Implement new jack_port_rename API + 2014-07-20 Stephane Letz * Version 1.9.11 started. diff --git a/common/JackAPI.cpp b/common/JackAPI.cpp index dfa0db56..dbe34396 100644 --- a/common/JackAPI.cpp +++ b/common/JackAPI.cpp @@ -159,6 +159,7 @@ extern "C" LIB_EXPORT int jack_recompute_total_latencies(jack_client_t*); LIB_EXPORT int jack_port_set_name(jack_port_t *port, const char* port_name); + LIB_EXPORT int jack_port_rename(jack_client_t *client, jack_port_t *port, const char* port_name); LIB_EXPORT int jack_port_set_alias(jack_port_t *port, const char* alias); LIB_EXPORT int jack_port_unset_alias(jack_port_t *port, const char* alias); LIB_EXPORT int jack_port_get_aliases(const jack_port_t *port, char* const aliases[2]); @@ -635,24 +636,37 @@ LIB_EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client) LIB_EXPORT int jack_port_set_name(jack_port_t* port, const char* name) { JackGlobals::CheckContext("jack_port_set_name"); + jack_error("jack_port_set_name: deprecated"); + // Find a valid client + jack_client_t* client = NULL; + for (int i = 0; i < CLIENT_NUM; i++) { + if ((client = (jack_client_t*)JackGlobals::fClientTable[i])) { + break; + } + } + + return (client) ? jack_port_rename(client, port, name) : -1; +} + +LIB_EXPORT int jack_port_rename(jack_client_t* ext_client, jack_port_t* port, const char* name) +{ + JackGlobals::CheckContext("jack_port_rename"); + + JackClient* client = (JackClient*)ext_client; uintptr_t port_aux = (uintptr_t)port; jack_port_id_t myport = (jack_port_id_t)port_aux; - if (!CheckPort(myport)) { - jack_error("jack_port_set_name called with an incorrect port %ld", myport); + if (client == NULL) { + jack_error("jack_port_rename called with a NULL client"); + return -1; + } else if (!CheckPort(myport)) { + jack_error("jack_port_rename called with an incorrect port %ld", myport); return -1; } else if (name == NULL) { - jack_error("jack_port_set_name called with a NULL port name"); + jack_error("jack_port_rename called with a NULL port name"); return -1; } else { - JackClient* client = NULL; - for (int i = 0; i < CLIENT_NUM; i++) { - // Find a valid client - if ((client = JackGlobals::fClientTable[i])) { - break; - } - } - return (client) ? client->PortRename(myport, name) : -1; + client->PortRename(myport, name); } } diff --git a/common/JackWeakAPI.c b/common/JackWeakAPI.c index 24ba2443..ea2a6899 100644 --- a/common/JackWeakAPI.c +++ b/common/JackWeakAPI.c @@ -207,6 +207,7 @@ DECL_VOID_FUNCTION(jack_port_set_latency_range, (jack_port_t *port, jack_latency DECL_FUNCTION(int, jack_recompute_total_latencies, (jack_client_t* client),(client)); DECL_FUNCTION(int, jack_port_set_name, (jack_port_t *port, const char *port_name), (port, port_name)); +DECL_FUNCTION(int, jack_port_rename, (jack_client_t *client, jack_port_t *port, const char *port_name), (client, port, port_name)); DECL_FUNCTION(int, jack_port_set_alias, (jack_port_t *port, const char *alias), (port, alias)); DECL_FUNCTION(int, jack_port_unset_alias, (jack_port_t *port, const char *alias), (port, alias)); DECL_FUNCTION(int, jack_port_get_aliases, (const jack_port_t *port, char* const aliases[2]), (port,aliases)); diff --git a/common/jack/jack.h b/common/jack/jack.h index 7f7537dc..467c3f58 100644 --- a/common/jack/jack.h +++ b/common/jack/jack.h @@ -887,13 +887,28 @@ int jack_port_tie (jack_port_t *src, jack_port_t *dst) JACK_OPTIONAL_WEAK_DEPREC int jack_port_untie (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; /** + * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN + * NEW JACK CLIENTS + * * Modify a port's short name. May be called at any time. If the * resulting full name (including the @a "client_name:" prefix) is * longer than jack_port_name_size(), it will be truncated. * * @return 0 on success, otherwise a non-zero error code. */ -int jack_port_set_name (jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT; +int jack_port_set_name (jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; + +/** + * Modify a port's short name. May NOT be called from a callback handling a server event. + * If the resulting full name (including the @a "client_name:" prefix) is + * longer than jack_port_name_size(), it will be truncated. + * + * @return 0 on success, otherwise a non-zero error code. + * + * This differs from jack_port_set_name() by triggering PortRename notifications to + * clients that have registered a port rename handler. + */ +int jack_port_rename (jack_client_t* client, jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT; /** * Set @a alias as an alias for @a port. May be called at any time. diff --git a/common/jack/types.h b/common/jack/types.h index 094d4074..2dccf34f 100644 --- a/common/jack/types.h +++ b/common/jack/types.h @@ -403,10 +403,8 @@ typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int * @param port the port that has been renamed * @param new_name the new name * @param arg pointer to a client supplied structure - * - * @return zero on success, non-zero on error */ -typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void *arg); +typedef void (*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 diff --git a/tests/test.cpp b/tests/test.cpp index 750d152c..8a8a8117 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -186,11 +186,10 @@ 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) +void 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", old_name, new_name); port_rename_clbk = 1; - return 0; } int Jack_Update_Buffer_Size(jack_nframes_t nframes, void *arg)