[pulseaudio-discuss] [PATCH 1/3] refactor default sink/source handling
Tanu Kaskinen
tanuk at iki.fi
Tue Jan 31 14:13:52 UTC 2017
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?
> > @@ -690,6 +692,11 @@ void pa_sink_unlink(pa_sink* s) {
> > pa_namereg_unregister(s->core, s->name);
> > pa_idxset_remove_by_data(s->core->sinks, s, NULL);
> >
> > + if (s == s->core->configured_default_sink)
> > + pa_core_set_configured_default_sink(s->core, NULL);
> > +
> > + pa_core_update_default_sink(s->core);
> > +
>
> Maybe the update should go into an else block since setting the
> configured default sink will call an update?
Ok, I'll do that.
> > @@ -632,6 +634,11 @@ void pa_source_unlink(pa_source *s) {
> > pa_namereg_unregister(s->core, s->name);
> > pa_idxset_remove_by_data(s->core->sources, s, NULL);
> >
> > + if (s == s->core->configured_default_source)
> > + pa_core_set_configured_default_source(s->core, NULL);
> > +
> > + pa_core_update_default_source(s->core);
> > +
> > if (s->card)
> > pa_idxset_remove_by_data(s->card->sources, s, NULL);
>
> Same comment for this update too.
Ok.
--
Tanu
https://www.patreon.com/tanuk
More information about the pulseaudio-discuss
mailing list