mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
device-manager: Some efficiency and safety tweaks
This commit is contained in:
parent
26f1ec7e0e
commit
6e67653aee
1 changed files with 9 additions and 4 deletions
|
|
@ -431,7 +431,7 @@ static uint32_t get_role_index(const char* role) {
|
||||||
static role_indexes_t *get_highest_priority_device_indexes(struct userdata *u, const char *prefix) {
|
static role_indexes_t *get_highest_priority_device_indexes(struct userdata *u, const char *prefix) {
|
||||||
role_indexes_t *indexes, highest_priority_available;
|
role_indexes_t *indexes, highest_priority_available;
|
||||||
pa_datum key;
|
pa_datum key;
|
||||||
pa_bool_t done;
|
pa_bool_t done, sink_mode;
|
||||||
|
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
pa_assert(prefix);
|
pa_assert(prefix);
|
||||||
|
|
@ -442,6 +442,8 @@ static role_indexes_t *get_highest_priority_device_indexes(struct userdata *u, c
|
||||||
}
|
}
|
||||||
pa_zero(highest_priority_available);
|
pa_zero(highest_priority_available);
|
||||||
|
|
||||||
|
sink_mode = (strcmp(prefix, "sink:") == 0);
|
||||||
|
|
||||||
done = !pa_database_first(u->database, &key, NULL);
|
done = !pa_database_first(u->database, &key, NULL);
|
||||||
|
|
||||||
/* Find all existing devices with the same prefix so we find the highest priority device for each role */
|
/* Find all existing devices with the same prefix so we find the highest priority device for each role */
|
||||||
|
|
@ -465,7 +467,7 @@ static role_indexes_t *get_highest_priority_device_indexes(struct userdata *u, c
|
||||||
pa_bool_t found = FALSE;
|
pa_bool_t found = FALSE;
|
||||||
char *device_name = get_name(name, prefix);
|
char *device_name = get_name(name, prefix);
|
||||||
|
|
||||||
if (strcmp(prefix, "sink:") == 0) {
|
if (sink_mode) {
|
||||||
pa_sink *sink;
|
pa_sink *sink;
|
||||||
|
|
||||||
PA_IDXSET_FOREACH(sink, u->core->sinks, idx) {
|
PA_IDXSET_FOREACH(sink, u->core->sinks, idx) {
|
||||||
|
|
@ -944,15 +946,18 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
||||||
if ((e = read_entry(u, device)) && ENTRY_VERSION == e->version) {
|
if ((e = read_entry(u, device)) && ENTRY_VERSION == e->version) {
|
||||||
pa_datum key, data;
|
pa_datum key, data;
|
||||||
pa_bool_t done;
|
pa_bool_t done;
|
||||||
char* prefix;
|
char* prefix = NULL;
|
||||||
uint32_t priority;
|
uint32_t priority;
|
||||||
pa_bool_t haschanged = FALSE;
|
pa_bool_t haschanged = FALSE;
|
||||||
|
|
||||||
if (strncmp(device, "sink:", 5) == 0)
|
if (strncmp(device, "sink:", 5) == 0)
|
||||||
prefix = pa_xstrdup("sink:");
|
prefix = pa_xstrdup("sink:");
|
||||||
else
|
else if (strncmp(device, "source:", 7) == 0)
|
||||||
prefix = pa_xstrdup("source:");
|
prefix = pa_xstrdup("source:");
|
||||||
|
|
||||||
|
if (!prefix)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
priority = e->priority[role_index];
|
priority = e->priority[role_index];
|
||||||
|
|
||||||
/* Now we need to load up all the other entries of this type and shuffle the priroities around */
|
/* Now we need to load up all the other entries of this type and shuffle the priroities around */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue