summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfalkTX <falktx@gmail.com>2015-07-19 18:44:34 +0200
committerfalkTX <falktx@gmail.com>2015-07-19 18:44:34 +0200
commitfc6344e5f2b7cedf3dc2e6e326e956d6b544d92b (patch)
treeb12a300ed94ea510c86b92542d95d352b8e475a8
parent7f2ceecf02513289f4d7950a347a7c69f7cb5766 (diff)
downloadjack2-fc6344e5f2b7cedf3dc2e6e326e956d6b544d92b.tar.gz
Implement new jack_port_rename API
-rw-r--r--common/JackAPI.cpp36
-rw-r--r--common/JackWeakAPI.c1
-rw-r--r--common/jack/jack.h17
3 files changed, 42 insertions, 12 deletions
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.