[pulseaudio-discuss] [PATCH] device-port, switch-on-port-available: fix automatic profile changing when current profile is off

Georg Chini georg at chini.tk
Mon Aug 7 20:03:26 UTC 2017


On 31.07.2017 08:42, Tanu Kaskinen wrote:
> module-switch-on-port-available didn't do anything when a port changes
> its status if the card didn't have any sinks or sources. This was to
> avoid bad things during card initialization, but the if condition also
> prevented any profile switches away from the "off" profile, because the
> card has no sinks or sources when the "off" profile is active.
>
> pa_card nowadays has the "linked" flag that
> module-switch-on-port-available could have checked instead, but since it
> doesn't make sense to emit port status change events before the card has
> been initialized, I added the check in pa_device_port_set_available()
> instead.
>
> BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=101794
> ---
>   src/modules/module-switch-on-port-available.c | 5 -----
>   src/pulsecore/device-port.c                   | 2 +-
>   2 files changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
> index b9a0f3b3a..4020987fd 100644
> --- a/src/modules/module-switch-on-port-available.c
> +++ b/src/modules/module-switch-on-port-available.c
> @@ -281,11 +281,6 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
>           return PA_HOOK_OK;
>       }
>   
> -    if (pa_idxset_size(port->card->sinks) == 0 && pa_idxset_size(port->card->sources) == 0)
> -        /* This card is not initialized yet. We'll handle it in
> -           sink_new / source_new callbacks later. */
> -        return PA_HOOK_OK;
> -
>       switch (port->available) {
>       case PA_AVAILABLE_YES:
>           switch_to_port(port);
> diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
> index 76a7e80a1..5cf4ac639 100644
> --- a/src/pulsecore/device-port.c
> +++ b/src/pulsecore/device-port.c
> @@ -92,7 +92,7 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
>        * before the card object has been created. The card object should probably
>        * be created before port objects, and then p->card could be non-NULL for
>        * the whole lifecycle of pa_device_port. */
> -    if (p->card) {
> +    if (p->card && p->card->linked) {
>           /* A sink or source whose active port is unavailable can't be the
>            * default sink/source, so port availability changes may affect the
>            * default sink/source choice. */

Looks good to me.



More information about the pulseaudio-discuss mailing list