[pulseaudio-discuss] [PATCH] card: Only set active_profile with available profile

David Henningsson david.henningsson at canonical.com
Thu Oct 31 10:22:11 CET 2013


On 10/30/2013 11:58 AM, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz at intel.com>
> 
> If the profile available flag is set to PA_AVAILABLE_NO it means the
> profile shall not be use.

Please add to the comment that this only happens when the card is
created, and only if the active profile has not been specified earlier.


> ---
>  src/pulsecore/card.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
> index e6e0836..ba2222e 100644
> --- a/src/pulsecore/card.c
> +++ b/src/pulsecore/card.c
> @@ -195,9 +195,13 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
>              c->save_profile = data->save_profile;
>  
>      if (!c->active_profile) {
> -        PA_HASHMAP_FOREACH(profile, c->profiles, state)
> +        PA_HASHMAP_FOREACH(profile, c->profiles, state) {
> +            if (profile->available == PA_AVAILABLE_NO)
> +                continue;
> +
>              if (!c->active_profile || profile->priority > c->active_profile->priority)
>                  c->active_profile = profile;
> +        }

Maybe also add a safeguard if all profiles are unavailable, e g like below:

        if (!c->active_profile) {
               c->active_profile = /* The first, or random, profile,
just something */;
                pa_log_warn("No available profiles, selecting
unavailable profile %s", c->active_profile->name);
        }

>      }
>  
>      c->userdata = NULL;
> 



-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list