pipewire: Don't set a specific stream name if the node name is the same.
Some checks are pending
Build (All) / Create test plan (push) Waiting to run
Build (All) / level1 (push) Blocked by required conditions
Build (All) / level2 (push) Blocked by required conditions

Fixes #15746.
This commit is contained in:
Ryan C. Gordon 2026-06-25 10:35:57 -04:00
parent 607eb5206e
commit 9f4327068e
No known key found for this signature in database
GPG key ID: FA148B892AB48044
2 changed files with 15 additions and 1 deletions

View file

@ -1129,6 +1129,8 @@ static void SDLCALL PIPEWIRE_StreamNameChanged(void *userdata, const char *name,
if (!priv || !priv->stream || !priv->loop) {
return; // stream not ready yet, skip it.
} else if (newValue && (SDL_strcmp(priv->node_name, newValue) == 0)) {
return; // don't set the media and node names to the same thing. Looks bad in the system UI, the node name is enough.
}
struct spa_dict_item items[] = { { PW_KEY_MEDIA_NAME, newValue } };
@ -1251,13 +1253,22 @@ static bool PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
}
// node_name/description describes the app, media_name what's currently playing
const char *node_name = (app_name && *app_name) ? app_name : stream_name;
priv->node_name = SDL_strdup(node_name);
if (!priv->node_name) {
return false; // already set error string.
}
PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_NAME, node_name);
PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_DESCRIPTION, node_name);
PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_NAME, stream_name);
PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%i", device->sample_frames, device->spec.freq);
PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%u", device->spec.freq);
PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_ALWAYS_PROCESS, "true");
// only set a stream-specific name if it's different than the app name, otherwise the system UI might show the stream as "Team Fortress 2 - Team Fortress 2" or whatever. Better to just show the name once.
if ((node_name != stream_name) && (SDL_strcmp(node_name, stream_name) != 0)) {
PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_NAME, stream_name);
}
// UPDATE: This prevents users from moving the audio to a new sink (device) using standard tools. This is slightly in conflict
// with how SDL wants to manage audio devices, but if people want to do it, we should let them, so this is commented out
// for now. We might revisit later.
@ -1339,6 +1350,7 @@ static void PIPEWIRE_CloseDevice(SDL_AudioDevice *device)
PIPEWIRE_pw_thread_loop_destroy(device->hidden->loop);
}
SDL_free(device->hidden->node_name);
SDL_free(device->hidden);
device->hidden = NULL;

View file

@ -33,6 +33,8 @@ struct SDL_PrivateAudioData
struct pw_stream *stream;
struct pw_context *context;
char *node_name;
Sint32 stride; // Bytes-per-frame
int stream_init_status;