summaryrefslogtreecommitdiff
path: root/jackd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-07-02 11:05:44 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-07-02 11:05:44 -0400
commit0ac9ef7c813f4e67ab1e9a5fb4aea515fd9f1b31 (patch)
tree2f1feeb5b4ba8c4c31634d4266b479c685354144 /jackd
parent601e3fe33ca2807acf8a7ebc5c056e0eed9b811a (diff)
downloadjack1-0ac9ef7c813f4e67ab1e9a5fb4aea515fd9f1b31.tar.gz
add support for port rename callback.
Diffstat (limited to 'jackd')
-rw-r--r--jackd/engine.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/jackd/engine.c b/jackd/engine.c
index 0fff48c..26df2bd 100644
--- a/jackd/engine.c
+++ b/jackd/engine.c
@@ -136,6 +136,7 @@ static void jack_compute_all_port_total_latencies (jack_engine_t *engine);
static void jack_compute_port_total_latency (jack_engine_t *engine, jack_port_shared_t*);
static int jack_check_client_status (jack_engine_t* engine);
static int jack_do_session_notify (jack_engine_t *engine, jack_request_t *req, int reply_fd );
+static void jack_port_rename_notify (jack_engine_t *engine, const char* old_name, const char* new_name);
static void jack_do_get_client_by_uuid (jack_engine_t *engine, jack_request_t *req);
static void jack_do_get_uuid_by_client_name (jack_engine_t *engine, jack_request_t *req);
static void jack_do_reserve_name (jack_engine_t *engine, jack_request_t *req);
@@ -1371,6 +1372,12 @@ do_request (jack_engine_t *engine, jack_request_t *req, int *reply_fd)
jack_property_change_notify (engine, req->x.property.change, req->x.property.uuid, req->x.property.key);
break;
+ case PortNameChanged:
+ jack_rdlock_graph (engine);
+ jack_port_rename_notify (engine, req->x.connect.source_port, req->x.connect.destination_port);
+ jack_unlock_graph (engine);
+ break;
+
default:
/* some requests are handled entirely on the client
* side, by adjusting the shared memory area(s) */
@@ -4644,6 +4651,47 @@ jack_port_registration_notify (jack_engine_t *engine,
}
}
+static void
+jack_port_rename_notify (jack_engine_t *engine,
+ const char* old_name,
+ const char* new_name)
+{
+ jack_event_t event;
+ jack_client_internal_t *client;
+ JSList *node;
+ jack_port_internal_t* port;
+
+ if ((port = jack_get_port_by_name (engine, new_name)) == NULL) {
+ /* possible race condition: port renamed again
+ since this rename happened. Oh well.
+ */
+ return;
+ }
+
+ event.type = PortRename;
+ event.y.other_id = port->shared->id;
+ snprintf (event.x.name, JACK_PORT_NAME_SIZE-1, old_name);
+ snprintf (event.z.other_name, JACK_PORT_NAME_SIZE-1, new_name);
+
+ for (node = engine->clients; node; node = jack_slist_next (node)) {
+
+ client = (jack_client_internal_t *) node->data;
+
+ if (!client->control->active) {
+ continue;
+ }
+
+ if (client->control->port_rename_cbset) {
+ if (jack_deliver_event (engine, client, &event)) {
+ jack_error ("cannot send port registration"
+ " notification to %s (%s)",
+ client->control->name,
+ strerror (errno));
+ }
+ }
+ }
+}
+
void
jack_client_registration_notify (jack_engine_t *engine,
const char* name, int yn)