mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
device-manager: Change the prefer/defer options to a single 'reorder' command.
We put in the devices from the wire into a hashmap and then add all like type device in the database and then order them based on priority (with the ones specified on the wire always being in that order at the top of the list.
This commit is contained in:
parent
45a4d26aca
commit
8a5778dcc5
4 changed files with 167 additions and 149 deletions
|
|
@ -43,8 +43,7 @@ enum {
|
|||
SUBCOMMAND_RENAME,
|
||||
SUBCOMMAND_DELETE,
|
||||
SUBCOMMAND_ROLE_DEVICE_PRIORITY_ROUTING,
|
||||
SUBCOMMAND_PREFER_DEVICE,
|
||||
SUBCOMMAND_DEFER_DEVICE,
|
||||
SUBCOMMAND_REORDER,
|
||||
SUBCOMMAND_SUBSCRIBE,
|
||||
SUBCOMMAND_EVENT
|
||||
};
|
||||
|
|
@ -330,14 +329,14 @@ pa_operation *pa_ext_device_manager_enable_role_device_priority_routing(
|
|||
return o;
|
||||
}
|
||||
|
||||
pa_operation *pa_ext_device_manager_prefer_device(
|
||||
pa_operation *pa_ext_device_manager_reorder_devices_for_role(
|
||||
pa_context *c,
|
||||
const char* role,
|
||||
const char* device,
|
||||
const char** devices,
|
||||
pa_context_success_cb_t cb,
|
||||
void *userdata) {
|
||||
|
||||
uint32_t tag;
|
||||
uint32_t tag, i;
|
||||
pa_operation *o = NULL;
|
||||
pa_tagstruct *t = NULL;
|
||||
|
||||
|
|
@ -349,52 +348,22 @@ pa_operation *pa_ext_device_manager_prefer_device(
|
|||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 14, PA_ERR_NOTSUPPORTED);
|
||||
|
||||
pa_assert(role);
|
||||
pa_assert(device);
|
||||
pa_assert(devices);
|
||||
|
||||
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_EXTENSION, &tag);
|
||||
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
|
||||
pa_tagstruct_puts(t, "module-device-manager");
|
||||
pa_tagstruct_putu32(t, SUBCOMMAND_PREFER_DEVICE);
|
||||
pa_tagstruct_putu32(t, SUBCOMMAND_REORDER);
|
||||
pa_tagstruct_puts(t, role);
|
||||
pa_tagstruct_puts(t, device);
|
||||
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||
i = 0; while (devices[i]) i++;
|
||||
pa_tagstruct_putu32(t, i);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
pa_operation *pa_ext_device_manager_defer_device(
|
||||
pa_context *c,
|
||||
const char* role,
|
||||
const char* device,
|
||||
pa_context_success_cb_t cb,
|
||||
void *userdata) {
|
||||
|
||||
uint32_t tag;
|
||||
pa_operation *o = NULL;
|
||||
pa_tagstruct *t = NULL;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 14, PA_ERR_NOTSUPPORTED);
|
||||
|
||||
pa_assert(role);
|
||||
pa_assert(device);
|
||||
|
||||
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_EXTENSION, &tag);
|
||||
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
|
||||
pa_tagstruct_puts(t, "module-device-manager");
|
||||
pa_tagstruct_putu32(t, SUBCOMMAND_DEFER_DEVICE);
|
||||
pa_tagstruct_puts(t, role);
|
||||
pa_tagstruct_puts(t, device);
|
||||
i = 0;
|
||||
while (devices[i])
|
||||
pa_tagstruct_puts(t, devices[i++]);
|
||||
|
||||
pa_pstream_send_tagstruct(c->pstream, t);
|
||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue