summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Arndt <chris@chrisarndt.de>2021-05-01 16:57:13 +0200
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>2021-05-03 12:19:17 +0000
commit2af43a8baf47495b8832a725f082a52b68aba71a (patch)
treed23270f12ae21474a40fd586018d772db38f6508
parent39125a0f2b68513139961ba61dc9b4a405b766b0 (diff)
Add port order metadata to JACK sink / source portsHEADmaster
Adds JACK metadata property to ports created by *module-jack-sink* and *module-jack-source* with key `JACK_METADATA_ORDER`, the port index (1-based, in order of creation) as value and type `http://www.w3.org/2001/XMLSchema#int`. This allows JACK applications, which use JACK metadata, to list or display these ports in correct order. See also: https://jackaudio.org/api/group__Metadata.html Signed-off-by: Christopher Arndt <chris@chrisarndt.de> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/550>
-rw-r--r--src/modules/jack/module-jack-sink.c17
-rw-r--r--src/modules/jack/module-jack-source.c17
2 files changed, 34 insertions, 0 deletions
diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
index a7c723073..5a690cbb5 100644
--- a/src/modules/jack/module-jack-sink.c
+++ b/src/modules/jack/module-jack-sink.c
@@ -28,6 +28,8 @@
#include <unistd.h>
#include <jack/jack.h>
+#include <jack/metadata.h>
+#include <jack/uuid.h>
#include <pulse/util.h>
#include <pulse/xmalloc.h>
@@ -69,6 +71,8 @@ PA_MODULE_USAGE(
"connect=<connect ports?>");
#define DEFAULT_SINK_NAME "jack_out"
+#define METADATA_TYPE_INT "http://www.w3.org/2001/XMLSchema#int"
+#define METADATA_KEY_ORDER "http://jackaudio.org/metadata/order"
struct userdata {
pa_core *core;
@@ -301,6 +305,8 @@ int pa__init(pa_module*m) {
const char **ports = NULL, **p;
pa_sink_new_data data;
jack_latency_range_t r;
+ jack_uuid_t port_uuid;
+ char port_order[4];
size_t n;
pa_assert(m);
@@ -389,6 +395,17 @@ int pa__init(pa_module*m) {
pa_log("jack_port_register() failed.");
goto fail;
}
+
+ /* Set order of ports as JACK metadata, if possible. */
+ /* See: https://jackaudio.org/api/group__Metadata.html */
+ port_uuid = jack_port_uuid(u->port[i]);
+
+ if (!jack_uuid_empty(port_uuid)) {
+ if (snprintf(port_order, 4, "%d", i+1) >= 4)
+ pa_log("Port order metadata value > 999 truncated.");
+ if (jack_set_property(u->client, port_uuid, METADATA_KEY_ORDER, port_order, METADATA_TYPE_INT) != 0)
+ pa_log("jack_set_property() failed.");
+ }
}
pa_sink_new_data_init(&data);
diff --git a/src/modules/jack/module-jack-source.c b/src/modules/jack/module-jack-source.c
index c4541913c..dbee5a68e 100644
--- a/src/modules/jack/module-jack-source.c
+++ b/src/modules/jack/module-jack-source.c
@@ -28,6 +28,8 @@
#include <unistd.h>
#include <jack/jack.h>
+#include <jack/metadata.h>
+#include <jack/uuid.h>
#include <pulse/util.h>
#include <pulse/xmalloc.h>
@@ -59,6 +61,8 @@ PA_MODULE_USAGE(
"connect=<connect ports?>");
#define DEFAULT_SOURCE_NAME "jack_in"
+#define METADATA_TYPE_INT "http://www.w3.org/2001/XMLSchema#int"
+#define METADATA_KEY_ORDER "http://jackaudio.org/metadata/order"
struct userdata {
pa_core *core;
@@ -249,6 +253,8 @@ int pa__init(pa_module*m) {
const char **ports = NULL, **p;
pa_source_new_data data;
jack_latency_range_t r;
+ jack_uuid_t port_uuid;
+ char port_order[4];
size_t n;
pa_assert(m);
@@ -331,6 +337,17 @@ int pa__init(pa_module*m) {
pa_log("jack_port_register() failed.");
goto fail;
}
+
+ /* Set order of ports as JACK metadata, if possible. */
+ /* See: https://jackaudio.org/api/group__Metadata.html */
+ port_uuid = jack_port_uuid(u->port[i]);
+
+ if (!jack_uuid_empty(port_uuid)) {
+ if (snprintf(port_order, 4, "%d", i+1) >= 4)
+ pa_log("Port order metadata value > 999 truncated.");
+ if (jack_set_property(u->client, port_uuid, METADATA_KEY_ORDER, port_order, METADATA_TYPE_INT) != 0)
+ pa_log("jack_set_property() failed.");
+ }
}
pa_source_new_data_init(&data);