PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits: 2af43a8b by Christopher Arndt at 2021-05-03T12:19:17+00:00 Add port order metadata to JACK sink / source ports 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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/550> - - - - - 2 changed files: - src/modules/jack/module-jack-sink.c - src/modules/jack/module-jack-source.c Changes: ===================================== 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); ===================================== 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); View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/2af43a8baf47495b8832a725f082a52b68aba71a -- View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/2af43a8baf47495b8832a725f082a52b68aba71a You're receiving this email because of your account on gitlab.freedesktop.org.
_______________________________________________ pulseaudio-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/pulseaudio-commits
