mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
device-manager: Expose the priority lists in the protocol extension.
Also leave space for 'icon' and 'available' details too, althought currently this info is dummy.
This commit is contained in:
parent
4dedba73a6
commit
8b2cc4def3
3 changed files with 86 additions and 38 deletions
|
|
@ -88,6 +88,18 @@ enum {
|
|||
|
||||
typedef uint32_t role_indexes_t[NUM_ROLES];
|
||||
|
||||
static const char* role_names[NUM_ROLES] = {
|
||||
"none",
|
||||
"video",
|
||||
"music",
|
||||
"game",
|
||||
"event",
|
||||
"phone",
|
||||
"animation",
|
||||
"production",
|
||||
"a11y",
|
||||
};
|
||||
|
||||
struct userdata {
|
||||
pa_core *core;
|
||||
pa_module *module;
|
||||
|
|
@ -234,26 +246,28 @@ static void dump_database(struct userdata *u) {
|
|||
pa_log_debug(" Highest priority devices per-role:");
|
||||
|
||||
pa_log_debug(" Sinks:");
|
||||
dump_database_helper(u, ROLE_NONE, "None: ", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Video: ", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Music: ", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Game: ", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Event: ", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Phone: ", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Anim: ", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Prodtn:", TRUE);
|
||||
dump_database_helper(u, ROLE_NONE, "Ally: ", TRUE);
|
||||
for (uint32_t role = ROLE_NONE; role < NUM_ROLES; ++role) {
|
||||
char name[13];
|
||||
uint32_t len = PA_MAX(12u, strlen(role_names[role]));
|
||||
for (int i = 0; i < 12; ++i) name[i] = ' ';
|
||||
strncpy(name, role_names[role], len);
|
||||
name[len] = ':';
|
||||
name[0] -= 32;
|
||||
name[12] = '\0';
|
||||
dump_database_helper(u, role, name, TRUE);
|
||||
}
|
||||
|
||||
pa_log_debug(" Sources:");
|
||||
dump_database_helper(u, ROLE_NONE, "None: ", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Video: ", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Music: ", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Game: ", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Event: ", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Phone: ", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Anim: ", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Prodtn:", FALSE);
|
||||
dump_database_helper(u, ROLE_NONE, "Ally: ", FALSE);
|
||||
for (uint32_t role = ROLE_NONE; role < NUM_ROLES; ++role) {
|
||||
char name[13];
|
||||
uint32_t len = PA_MAX(12u, strlen(role_names[role]));
|
||||
for (int i = 0; i < 12; ++i) name[i] = ' ';
|
||||
strncpy(name, role_names[role], len);
|
||||
name[len] = ':';
|
||||
name[0] -= 32;
|
||||
name[12] = '\0';
|
||||
dump_database_helper(u, role, name, FALSE);
|
||||
}
|
||||
|
||||
pa_log_debug("Completed database dump");
|
||||
}
|
||||
|
|
@ -378,22 +392,10 @@ static uint32_t get_role_index(const char* role) {
|
|||
|
||||
if (strcmp(role, "") == 0)
|
||||
return ROLE_NONE;
|
||||
if (strcmp(role, "video") == 0)
|
||||
return ROLE_VIDEO;
|
||||
if (strcmp(role, "music") == 0)
|
||||
return ROLE_MUSIC;
|
||||
if (strcmp(role, "game") == 0)
|
||||
return ROLE_GAME;
|
||||
if (strcmp(role, "event") == 0)
|
||||
return ROLE_EVENT;
|
||||
if (strcmp(role, "phone") == 0)
|
||||
return ROLE_PHONE;
|
||||
if (strcmp(role, "animation") == 0)
|
||||
return ROLE_ANIMATION;
|
||||
if (strcmp(role, "production") == 0)
|
||||
return ROLE_PRODUCTION;
|
||||
if (strcmp(role, "a11y") == 0)
|
||||
return ROLE_A11Y;
|
||||
for (uint32_t i = ROLE_NONE; i < NUM_ROLES; ++i)
|
||||
if (strcmp(role, role_names[i]) == 0)
|
||||
return i;
|
||||
|
||||
return PA_INVALID_INDEX;
|
||||
}
|
||||
|
||||
|
|
@ -974,10 +976,18 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
pa_datum_free(&key);
|
||||
|
||||
if ((e = read_entry(u, name))) {
|
||||
pa_tagstruct_puts(reply, name);
|
||||
pa_tagstruct_puts(reply, e->description);
|
||||
pa_tagstruct_puts(reply, name);
|
||||
pa_tagstruct_puts(reply, e->description);
|
||||
pa_tagstruct_puts(reply, "audio-card"); /** @todo store the icon */
|
||||
pa_tagstruct_put_boolean(reply, TRUE); /** @todo show current available */
|
||||
pa_tagstruct_putu32(reply, NUM_ROLES);
|
||||
|
||||
pa_xfree(e);
|
||||
for (uint32_t i = ROLE_NONE; i < NUM_ROLES; ++i) {
|
||||
pa_tagstruct_puts(reply, role_names[i]);
|
||||
pa_tagstruct_putu32(reply, e->priority[i]);
|
||||
}
|
||||
|
||||
pa_xfree(e);
|
||||
}
|
||||
|
||||
pa_xfree(name);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <pulse/context.h>
|
||||
#include <pulse/gccmacro.h>
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/pstream-util.h>
|
||||
|
|
@ -128,20 +129,48 @@ static void ext_device_manager_read_cb(pa_pdispatch *pd, uint32_t command, uint3
|
|||
|
||||
while (!pa_tagstruct_eof(t)) {
|
||||
pa_ext_device_manager_info i;
|
||||
pa_bool_t available;
|
||||
|
||||
memset(&i, 0, sizeof(i));
|
||||
available = FALSE;
|
||||
|
||||
if (pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.description) < 0) {
|
||||
pa_tagstruct_gets(t, &i.description) < 0 ||
|
||||
pa_tagstruct_gets(t, &i.icon) < 0 ||
|
||||
pa_tagstruct_get_boolean(t, &available) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.n_role_priorities) < 0) {
|
||||
|
||||
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||
goto finish;
|
||||
}
|
||||
i.available = (uint8_t)available;
|
||||
|
||||
if (i.n_role_priorities > 0) {
|
||||
uint32_t j;
|
||||
i.role_priorities = pa_xnew0(pa_ext_device_manager_role_priority_info, i.n_role_priorities+1);
|
||||
|
||||
for (j = 0; j < i.n_role_priorities; j++) {
|
||||
|
||||
if (pa_tagstruct_gets(t, &i.role_priorities[j].role) < 0 ||
|
||||
pa_tagstruct_getu32(t, &i.role_priorities[j].priority) < 0) {
|
||||
|
||||
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||
pa_xfree(i.role_priorities);
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
/* Terminate with an extra NULL entry, just to make sure */
|
||||
i.role_priorities[j].role = NULL;
|
||||
i.role_priorities[j].priority = 0;
|
||||
}
|
||||
|
||||
if (o->callback) {
|
||||
pa_ext_device_manager_read_cb_t cb = (pa_ext_device_manager_read_cb_t) o->callback;
|
||||
cb(o->context, &i, 0, o->userdata);
|
||||
}
|
||||
|
||||
pa_xfree(i.role_priorities);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,20 @@
|
|||
|
||||
PA_C_DECL_BEGIN
|
||||
|
||||
typedef struct pa_ext_device_manager_role_priority_info {
|
||||
const char *role;
|
||||
uint32_t priority;
|
||||
} pa_ext_device_manager_role_priority_info;
|
||||
|
||||
/** Stores information about one device in the device database that is
|
||||
* maintained by module-device-manager. \since 0.9.19 */
|
||||
typedef struct pa_ext_device_manager_info {
|
||||
const char *name; /**< Identifier string of the device. A string like "sink:" or similar followed by the name of the device. */
|
||||
const char *description; /**< The description of the device when it was last seen, if applicable and saved */
|
||||
const char *icon; /**< The icon given to the device */
|
||||
uint8_t available; /**< Is the device currently available? */
|
||||
uint32_t n_role_priorities; /**< How many role priorities do we have? */
|
||||
pa_ext_device_manager_role_priority_info *role_priorities; /**< An array of role priority structures or NULL */
|
||||
} pa_ext_device_manager_info;
|
||||
|
||||
/** Callback prototype for pa_ext_device_manager_test(). \since 0.9.19 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue