mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
version all entries in the database
This commit is contained in:
parent
4cf82c74a1
commit
1db64781bf
3 changed files with 42 additions and 15 deletions
|
|
@ -68,7 +68,10 @@ struct userdata {
|
|||
GDBM_FILE gdbm_file;
|
||||
};
|
||||
|
||||
struct entry {
|
||||
#define ENTRY_VERSION 1
|
||||
|
||||
struct entry PA_GCC_PACKED {
|
||||
uint8_t version;
|
||||
char profile[PA_NAME_MAX];
|
||||
};
|
||||
|
||||
|
|
@ -104,12 +107,17 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
|
|||
goto fail;
|
||||
|
||||
if (data.dsize != sizeof(struct entry)) {
|
||||
pa_log_warn("Database contains entry for card %s of wrong size %lu != %lu", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
|
||||
pa_log_debug("Database contains entry for card %s of wrong size %lu != %lu. Probably due to upgrade, ignoring.", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
e = (struct entry*) data.dptr;
|
||||
|
||||
if (e->version != ENTRY_VERSION) {
|
||||
pa_log_debug("Version of database entry for card %s doesn't match our version. Probably due to upgrade, ignoring.", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!memchr(e->profile, 0, sizeof(e->profile))) {
|
||||
pa_log_warn("Database contains entry for card %s with missing NUL byte in profile name", name);
|
||||
goto fail;
|
||||
|
|
@ -148,6 +156,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
|
|||
return;
|
||||
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
entry.version = ENTRY_VERSION;
|
||||
|
||||
if (!(card = pa_idxset_get_by_index(c->cards, idx)))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -79,10 +79,13 @@ struct userdata {
|
|||
pa_bool_t restore_muted:1;
|
||||
};
|
||||
|
||||
struct entry {
|
||||
#define ENTRY_VERSION 1
|
||||
|
||||
struct entry PA_GCC_PACKED {
|
||||
uint8_t version;
|
||||
pa_bool_t muted:1;
|
||||
pa_channel_map channel_map;
|
||||
pa_cvolume volume;
|
||||
pa_bool_t muted:1;
|
||||
};
|
||||
|
||||
static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) {
|
||||
|
|
@ -117,12 +120,17 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
|
|||
goto fail;
|
||||
|
||||
if (data.dsize != sizeof(struct entry)) {
|
||||
pa_log_warn("Database contains entry for device %s of wrong size %lu != %lu", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
|
||||
pa_log_debug("Database contains entry for device %s of wrong size %lu != %lu. Probably due to upgrade, ignoring.", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
e = (struct entry*) data.dptr;
|
||||
|
||||
if (e->version != ENTRY_VERSION) {
|
||||
pa_log_debug("Version of database entry for device %s doesn't match our version. Probably due to upgrade, ignoring.", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(pa_cvolume_valid(&e->volume))) {
|
||||
pa_log_warn("Invalid volume stored in database for device %s", name);
|
||||
goto fail;
|
||||
|
|
@ -173,6 +181,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
|
|||
return;
|
||||
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
entry.version = ENTRY_VERSION;
|
||||
|
||||
if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK) {
|
||||
pa_sink *sink;
|
||||
|
|
|
|||
|
|
@ -90,16 +90,18 @@ struct userdata {
|
|||
pa_idxset *subscribed;
|
||||
};
|
||||
|
||||
struct entry {
|
||||
#define ENTRY_VERSION 1
|
||||
|
||||
struct entry PA_GCC_PACKED {
|
||||
uint8_t version;
|
||||
pa_bool_t muted_valid:1, relative_volume_valid:1, absolute_volume_valid:1, device_valid:1;
|
||||
pa_bool_t muted:1;
|
||||
pa_channel_map channel_map;
|
||||
char device[PA_NAME_MAX];
|
||||
pa_cvolume relative_volume;
|
||||
pa_cvolume absolute_volume;
|
||||
pa_bool_t muted:1;
|
||||
pa_bool_t device_valid:1, relative_volume_valid:1, absolute_volume_valid:1, muted_valid:1;
|
||||
char device[PA_NAME_MAX];
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
SUBCOMMAND_TEST,
|
||||
SUBCOMMAND_READ,
|
||||
|
|
@ -161,24 +163,29 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
|
|||
if (data.dsize != sizeof(struct entry)) {
|
||||
/* This is probably just a database upgrade, hence let's not
|
||||
* consider this more than a debug message */
|
||||
pa_log_debug("Database contains entry for stream %s of wrong size %lu != %lu", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
|
||||
pa_log_debug("Database contains entry for stream %s of wrong size %lu != %lu. Probably due to uprade, ignoring.", name, (unsigned long) data.dsize, (unsigned long) sizeof(struct entry));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
e = (struct entry*) data.dptr;
|
||||
|
||||
if (e->version != ENTRY_VERSION) {
|
||||
pa_log_debug("Version of database entry for stream %s doesn't match our version. Probably due to upgrade, ignoring.", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!memchr(e->device, 0, sizeof(e->device))) {
|
||||
pa_log_warn("Database contains entry for stream %s with missing NUL byte in device name", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(pa_channel_map_valid(&e->channel_map))) {
|
||||
pa_log_warn("Invalid channel map stored in database for stream %s", name);
|
||||
if (e->device_valid && !pa_namereg_is_valid_name(e->device)) {
|
||||
pa_log_warn("Invalid device name stored in database for stream %s", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (e->device_valid && !pa_namereg_is_valid_name(e->device)) {
|
||||
pa_log_warn("Invalid device name stored in database for stream %s", name);
|
||||
if ((e->relative_volume_valid || e->absolute_volume_valid) && !(pa_channel_map_valid(&e->channel_map))) {
|
||||
pa_log_warn("Invalid channel map stored in database for stream %s", name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -265,6 +272,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
|
|||
return;
|
||||
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
entry.version = ENTRY_VERSION;
|
||||
|
||||
if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK_INPUT) {
|
||||
pa_sink_input *sink_input;
|
||||
|
|
@ -697,6 +705,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
int k;
|
||||
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
entry.version = ENTRY_VERSION;
|
||||
|
||||
if (pa_tagstruct_gets(t, &name) < 0 ||
|
||||
pa_tagstruct_get_channel_map(t, &entry.channel_map) ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue