Skip to content

Commit

Permalink
ao/pulse: set similar properties as the pipewire backend
Browse files Browse the repository at this point in the history
Not setting `media.role` especially negatively affects wireplumber's
restore-stream feature as it will save different stream settings for
ao=pulse and ao=pipewire, so they will be restored differently.

For example:

 1. mpv --ao=pipewire ...
 2. mute the stream in pavucontrol
 3. mpv --ao=pulse ...
 4. note that the stream is not muted

To alleviate that issue, set `media.role` the same way it is set
in the pipewire audio backend. (As well as some others.)

See https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3848
  • Loading branch information
pobrn committed Mar 19, 2024
1 parent cbe30f6 commit db80bdf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions audio/out/ao_pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ static int pa_init_boilerplate(struct ao *ao)
struct priv *priv = ao->priv;
char *host = priv->cfg_host && priv->cfg_host[0] ? priv->cfg_host : NULL;
bool locked = false;
pa_proplist *props = pa_proplist_new();

pa_proplist_sets(props, PA_PROP_MEDIA_ROLE, ao->init_flags & AO_INIT_MEDIA_ROLE_MUSIC ? "music" : "video");
pa_proplist_sets(props, PA_PROP_APPLICATION_NAME, ao->client_name);
pa_proplist_sets(props, PA_PROP_APPLICATION_ID, ao->client_name);
pa_proplist_sets(props, PA_PROP_APPLICATION_ICON_NAME, ao->client_name);

if (!(priv->mainloop = pa_threaded_mainloop_new())) {
MP_ERR(ao, "Failed to allocate main loop\n");
Expand All @@ -306,8 +312,8 @@ static int pa_init_boilerplate(struct ao *ao)
pa_threaded_mainloop_lock(priv->mainloop);
locked = true;

if (!(priv->context = pa_context_new(pa_threaded_mainloop_get_api(
priv->mainloop), ao->client_name)))
if (!(priv->context = pa_context_new_with_proplist(pa_threaded_mainloop_get_api(
priv->mainloop), ao->client_name, props)))
{
MP_ERR(ao, "Failed to allocate context\n");
goto fail;
Expand Down Expand Up @@ -336,6 +342,7 @@ static int pa_init_boilerplate(struct ao *ao)
}

pa_threaded_mainloop_unlock(priv->mainloop);
pa_proplist_free(props);
return 0;

fail:
Expand All @@ -349,6 +356,7 @@ static int pa_init_boilerplate(struct ao *ao)
GENERIC_ERR_MSG("Init failed");
pa_threaded_mainloop_unlock(priv->mainloop);
}
pa_proplist_free(props);
uninit(ao);
return -1;
}
Expand Down

0 comments on commit db80bdf

Please sign in to comment.