From 52b73d411524567ba0a8b522fbc0a5c41a45720c Mon Sep 17 00:00:00 2001 From: David Gow Date: Mon, 29 May 2023 15:36:59 +0800 Subject: [PATCH] pipewire: Set 'application.id' if SDL_HINT_APP_ID set If SDL_HINT_APP_ID is set, pass it as the application.id to pipewire. This gives any pipewire-based tools a hint to find an associated .desktop file for icons, etc. --- src/audio/pipewire/SDL_pipewire.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index af6ffde02..0cb1268ab 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -1127,7 +1127,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *_this, const char *devname) const struct spa_pod *params = NULL; struct SDL_PrivateAudioData *priv; struct pw_properties *props; - const char *app_name, *stream_name, *stream_role, *error; + const char *app_name, *app_id, *stream_name, *stream_role, *error; Uint32 node_id = _this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(_this->handle); SDL_bool iscapture = _this->iscapture; int res; @@ -1144,6 +1144,9 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *_this, const char *devname) } } + /* App ID. Default to NULL if not available. */ + app_id = SDL_GetHint(SDL_HINT_APP_ID); + stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); if (stream_name == NULL || *stream_name == '\0') { stream_name = "Audio Stream"; @@ -1205,6 +1208,9 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *_this, const char *devname) PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_CATEGORY, iscapture ? "Capture" : "Playback"); PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_ROLE, stream_role); PIPEWIRE_pw_properties_set(props, PW_KEY_APP_NAME, app_name); + if (app_id != NULL) { + PIPEWIRE_pw_properties_set(props, PW_KEY_APP_ID, app_id); + } PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_NAME, stream_name); PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_DESCRIPTION, stream_name); PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%i", _this->spec.samples, _this->spec.freq);