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.
main
David Gow 2023-05-29 15:36:59 +08:00 committed by Frank Praznik
parent f74549ef2e
commit 52b73d4115
1 changed files with 7 additions and 1 deletions

View File

@ -1127,7 +1127,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *_this, const char *devname)
const struct spa_pod *params = NULL; const struct spa_pod *params = NULL;
struct SDL_PrivateAudioData *priv; struct SDL_PrivateAudioData *priv;
struct pw_properties *props; 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); Uint32 node_id = _this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(_this->handle);
SDL_bool iscapture = _this->iscapture; SDL_bool iscapture = _this->iscapture;
int res; 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); stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
if (stream_name == NULL || *stream_name == '\0') { if (stream_name == NULL || *stream_name == '\0') {
stream_name = "Audio Stream"; 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_CATEGORY, iscapture ? "Capture" : "Playback");
PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_ROLE, stream_role); PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_ROLE, stream_role);
PIPEWIRE_pw_properties_set(props, PW_KEY_APP_NAME, app_name); 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_NAME, stream_name);
PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_DESCRIPTION, 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); PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%i", _this->spec.samples, _this->spec.freq);