On 11/01/2013 11:24 AM, Luiz Augusto von Dentz wrote: > Hi David, > > On Fri, Nov 1, 2013 at 11:31 AM, David Henningsson > <david.henningsson at canonical.com> wrote: >> On 11/01/2013 10:18 AM, Luiz Augusto von Dentz wrote: >>> Hi David, >>> >>> On Thu, Oct 31, 2013 at 11:22 AM, David Henningsson >>> <david.henningsson at canonical.com> wrote: >>>> 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. >>> >>> Sure will add it np. >>> >>>> >>>>> --- >>>>> 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); >>>> } >>> >>> What about assert if there is no profile that can be used? It already >>> asserts if the profile hash table is empty which is kind similar >>> situation here when no profile is available so perhaps we should >>> assert? >>> >> >> Hmm. I'm thinking of HDMI only cards which at PA start time are >> unconnected, and then later connected to an HDMI monitor. What will your >> code do in this use case? >> >> But maybe an unconnected HDMI card leads to unavailable ports, but not >> unavailable profiles... > > In Bluetooth case there is the 'off' profile which has no sinks or > sources but it is always available, perhaps HDMI can use the same > concept? Sure; the same "off" profile does exist for HDMI, but it will be an additional step to select the new profile manually after having it plugged in - there's no logic (currently) that says "I was on a 5.1 profile last time I used HDMI, so therefore I select this profile now that it is plugged in again". I suspect this might be annoying for some users. But actually, I also suspect that those profiles remain available even when HDMI is unconnected, so perhaps not much of a problem. -- David Henningsson, Canonical Ltd. https://launchpad.net/~diwic