[pulseaudio-discuss] [PATCH v2 3/8] sink-input: clear the preferred_sink if it is default_sink

Georg Chini georg at chini.tk
Sun Jun 30 10:47:29 UTC 2019


On 17.01.19 07:53, Hui Wang wrote:
> When the user moves a stream to the current default sink, the
> preferred_sink should be set to NULL and module-stream-restore
> should clear the routing for that stream in the stream database. From
> that point on the stream will be always routed to the default sink.
>
> Signed-off-by: Hui Wang <hui.wang at canonical.com>
> ---
>   src/modules/module-stream-restore.c | 19 ++++++++++++++-----
>   src/pulsecore/sink-input.c          |  6 +++++-
>   2 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
> index 366f1a5a8..142d1e3b4 100644
> --- a/src/modules/module-stream-restore.c
> +++ b/src/modules/module-stream-restore.c
> @@ -1311,13 +1311,22 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
>               mute_updated = !created_new_entry && (!old->muted_valid || entry->muted != old->muted);
>           }
>   
> -        if (sink_input->preferred_sink != NULL) {
> +        if (sink_input->preferred_sink != NULL || !created_new_entry) {
>               pa_xfree(entry->device);
> -            entry->device = pa_xstrdup(sink_input->preferred_sink);
> -            entry->device_valid = true;
> +            if (sink_input->preferred_sink != NULL) {
> +                entry->device = pa_xstrdup(sink_input->preferred_sink);
> +                entry->device_valid = true;
> +            } else {
> +                entry->device = NULL;
> +                entry->device_valid = false;
> +            }
>   
> -            device_updated = !created_new_entry && (!old->device_valid || !pa_streq(entry->device, old->device));
> -            if (sink_input->sink->card) {
> +            device_updated = !created_new_entry && !pa_safe_streq(entry->device, old->device);
> +            if (entry->device_valid == false) {
> +                pa_xfree(entry->card);
> +                entry->card = NULL;
> +                entry->card_valid = false;
> +            } else {
>                   pa_xfree(entry->card);
>                   entry->card = pa_xstrdup(sink_input->sink->card->name);
>                   entry->card_valid = true;
You still need to check sink_input->sink->card. The virtual sinks don't 
have a card,
so it may well be that the device is valid but there is no card.


More information about the pulseaudio-discuss mailing list