mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
device-manager: Fix copy+paste code that looped over the tagstruct when not necessary
This commit is contained in:
parent
103897a1e3
commit
95f28393ab
1 changed files with 37 additions and 40 deletions
|
|
@ -478,56 +478,53 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SUBCOMMAND_ROLE_DEVICE_PRIORITY_ROUTING:
|
case SUBCOMMAND_ROLE_DEVICE_PRIORITY_ROUTING: {
|
||||||
|
|
||||||
while (!pa_tagstruct_eof(t)) {
|
pa_bool_t enable;
|
||||||
pa_bool_t enable;
|
uint32_t sridx = PA_INVALID_INDEX;
|
||||||
uint32_t sridx = PA_INVALID_INDEX;
|
uint32_t idx;
|
||||||
uint32_t idx;
|
pa_module *module;
|
||||||
pa_module *module;
|
|
||||||
|
|
||||||
if (pa_tagstruct_get_boolean(t, &enable) < 0)
|
if (pa_tagstruct_get_boolean(t, &enable) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* If this is the first run, check for stream restore module */
|
/* If this is the first run, check for stream restore module */
|
||||||
if (!u->checked_stream_restore) {
|
if (!u->checked_stream_restore) {
|
||||||
u->checked_stream_restore = TRUE;
|
u->checked_stream_restore = TRUE;
|
||||||
|
|
||||||
for (module = pa_idxset_first(u->core->modules, &idx); module; module = pa_idxset_next(u->core->modules, &idx)) {
|
for (module = pa_idxset_first(u->core->modules, &idx); module; module = pa_idxset_next(u->core->modules, &idx)) {
|
||||||
if (strcmp(module->name, "module-stream-restore") == 0) {
|
if (strcmp(module->name, "module-stream-restore") == 0) {
|
||||||
pa_log_debug("Detected module-stream-restore is currently in use");
|
pa_log_debug("Detected module-stream-restore is currently in use");
|
||||||
u->stream_restore_used = TRUE;
|
u->stream_restore_used = TRUE;
|
||||||
sridx = module->index;
|
sridx = module->index;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u->role_device_priority_routing = enable;
|
|
||||||
if (enable) {
|
|
||||||
if (u->stream_restore_used) {
|
|
||||||
if (PA_INVALID_INDEX == sridx) {
|
|
||||||
/* As a shortcut on first load, we have sridx filled in, but otherwise we search for it. */
|
|
||||||
for (module = pa_idxset_first(u->core->modules, &idx); module; module = pa_idxset_next(u->core->modules, &idx)) {
|
|
||||||
if (strcmp(module->name, "module-stream-restore") == 0) {
|
|
||||||
sridx = module->index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (PA_INVALID_INDEX != sridx) {
|
|
||||||
pa_log_debug("Unloading module-stream-restore to enable role-based device-priority routing");
|
|
||||||
pa_module_unload_request_by_index(u->core, sridx, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (u->stream_restore_used) {
|
|
||||||
/* We want to reload module-stream-restore */
|
|
||||||
if (!pa_module_load(u->core, "module-stream-restore", ""))
|
|
||||||
pa_log_warn("Failed to load module-stream-restore while disabling role-based device-priority routing");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger_save(u);
|
u->role_device_priority_routing = enable;
|
||||||
|
if (enable) {
|
||||||
|
if (u->stream_restore_used) {
|
||||||
|
if (PA_INVALID_INDEX == sridx) {
|
||||||
|
/* As a shortcut on first load, we have sridx filled in, but otherwise we search for it. */
|
||||||
|
for (module = pa_idxset_first(u->core->modules, &idx); module; module = pa_idxset_next(u->core->modules, &idx)) {
|
||||||
|
if (strcmp(module->name, "module-stream-restore") == 0) {
|
||||||
|
sridx = module->index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (PA_INVALID_INDEX != sridx) {
|
||||||
|
pa_log_debug("Unloading module-stream-restore to enable role-based device-priority routing");
|
||||||
|
pa_module_unload_request_by_index(u->core, sridx, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (u->stream_restore_used) {
|
||||||
|
/* We want to reload module-stream-restore */
|
||||||
|
if (!pa_module_load(u->core, "module-stream-restore", ""))
|
||||||
|
pa_log_warn("Failed to load module-stream-restore while disabling role-based device-priority routing");
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SUBCOMMAND_SUBSCRIBE: {
|
case SUBCOMMAND_SUBSCRIBE: {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue