[pulseaudio-discuss] [PATCH 1/3] refactor default sink/source handling

Arun Raghavan arun at arunraghavan.net
Thu Feb 2 07:25:54 UTC 2017



On Tue, 31 Jan 2017, at 07:43 PM, Tanu Kaskinen wrote:
> On Mon, 2017-01-30 at 14:37 +0530, Arun Raghavan wrote:
> > 
> > On Thu, 8 Sep 2016, at 04:36 PM, Tanu Kaskinen wrote:
> > > +void pa_core_update_default_sink(pa_core *core) {
> > > +    pa_sink *best = NULL;
> > > +    pa_sink *sink;
> > > +    uint32_t idx;
> > > +    pa_sink *old_default_sink;
> > > +
> > > +    pa_assert(core);
> > > +
> > > +    PA_IDXSET_FOREACH(sink, core->sinks, idx) {
> > > +        if (!best) {
> > > +            best = sink;
> > > +            continue;
> > > +        }
> > > +
> > > +        if (compare_sinks(sink, best) > 0)
> > > +            best = sink;
> > > +    }
> > > +
> > > +    old_default_sink = core->default_sink;
> > > +
> > > +    if (best == old_default_sink)
> > > +        return;
> > 
> > I initially thought that even if the default sink doesn't change, the
> > default source might (new monitor source with higher priority, for
> > example). But it turns out that if a new monitor source does turn up,
> > it'll get handled in pa_source_put().
> > 
> > The semantics of when these updates are called seem a little hard to
> > track to me.
> 
> Do you have suggestions for making the code easier to follow?

Not really, other than some more documentation for when the default sink
might need to be updated. Maybe document that with either the function,
or the field in pa_core.

-- Arun


More information about the pulseaudio-discuss mailing list