switch-on-connect: Improve readability

Make code easier to read by moving pa_proplist_gets out of the if
condition and using pa_safe_streq.
This commit is contained in:
João Paulo Rechi Vita 2018-08-07 20:39:20 -07:00 committed by Tanu Kaskinen
parent cefe037afc
commit e9f5fa94b2

View file

@ -69,12 +69,9 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void*
return PA_HOOK_OK; return PA_HOOK_OK;
/* Don't switch to any internal devices */ /* Don't switch to any internal devices */
if ((s = pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_BUS))) { s = pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_BUS);
if (pa_streq(s, "pci")) if (pa_safe_streq(s, "pci") || pa_safe_streq(s, "isa"))
return PA_HOOK_OK; return PA_HOOK_OK;
else if (pa_streq(s, "isa"))
return PA_HOOK_OK;
}
/* Ignore virtual sinks if not configured otherwise on the command line */ /* Ignore virtual sinks if not configured otherwise on the command line */
if (u->ignore_virtual && !(sink->flags & PA_SINK_HARDWARE)) if (u->ignore_virtual && !(sink->flags & PA_SINK_HARDWARE))
@ -139,12 +136,9 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
return PA_HOOK_OK; return PA_HOOK_OK;
/* Don't switch to any internal devices */ /* Don't switch to any internal devices */
if ((s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_BUS))) { s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_BUS);
if (pa_streq(s, "pci")) if (pa_safe_streq(s, "pci") || pa_safe_streq(s, "isa"))
return PA_HOOK_OK; return PA_HOOK_OK;
else if (pa_streq(s, "isa"))
return PA_HOOK_OK;
}
/* Ignore virtual sources if not configured otherwise on the command line */ /* Ignore virtual sources if not configured otherwise on the command line */
if (u->ignore_virtual && !(source->flags & PA_SOURCE_HARDWARE)) if (u->ignore_virtual && !(source->flags & PA_SOURCE_HARDWARE))