[pulseaudio-discuss] [PATCH v2 2/2] switch-on-port-available: deactivate direction when the no ports are available for that direction

Tanu Kaskinen tanuk at iki.fi
Sat Dec 30 12:41:03 UTC 2017


On Fri, 2017-12-29 at 21:28 +0100, Georg Chini wrote:
> On 29.12.2017 13:49, Tanu Kaskinen wrote:
> > On Fri, 2017-12-29 at 08:25 +0100, Georg Chini wrote:
> > > On 28.12.2017 16:14, Tanu Kaskinen wrote:
> > > > +static void deactivate_direction(pa_card *card, pa_direction_t direction) {
> > > > +    pa_card_profile *profile;
> > > > +    void *state;
> > > > +    pa_card_profile *best_profile = NULL;
> > > > +    const char *direction_str;
> > > > +
> > > > +    PA_HASHMAP_FOREACH(profile, card->profiles, state) {
> > > > +        switch (direction) {
> > > > +            case PA_DIRECTION_OUTPUT:
> > > > +                if (profile->n_sinks != 0)
> > > > +                    continue;
> > > > +                if (!profile_good_for_output(profile, NULL))
> > > 
> > > Should this not be profile_good_for_input()?
> > 
> > No. profile_good_for_output() is called when modifying the output
> > configuration. The function is used to check that the input side
> > doesn't change. I'm occasionally confused about the function naming
> > too, so it would be good to make it more clear...
> > 
> 
> I see, thanks.
> 
> One other question: Is it safe to pass NULL as port to profile_good_for_*()?
> There is a comparison in the function which uses port->priority without
> checking if port is NULL.

It should be safe, because the port pointer is dereferenced only if the
current active sink port is available, and deactivate_direction()
passes NULL only when the sink port is unavailable. However, maybe it's
best to add an extra check just in case.

-- 
Tanu

https://www.patreon.com/tanuk


More information about the pulseaudio-discuss mailing list