If the number of formats is zero, then it is interpreted as no formats set, so we don't try to restore the formats then. The upcoming "factory settings" feature needs to add entries to the database without specifying any formats. --- src/modules/module-device-restore.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c index de8b81b..05b7301 100644 --- a/src/modules/module-device-restore.c +++ b/src/modules/module-device-restore.c @@ -371,7 +371,6 @@ static pa_bool_t perportentry_write(struct userdata *u, const char *basekeyname, name = pa_sprintf_malloc("%s:%s", basekeyname, (port ? port : "null")); n_formats = pa_idxset_size(e->formats); - pa_assert(n_formats > 0); t = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu8(t, e->version); @@ -429,7 +428,7 @@ static struct perportentry* perportentry_read(struct userdata *u, const char *ba pa_tagstruct_get_cvolume(t, &e->volume) < 0 || pa_tagstruct_get_boolean(t, &e->muted_valid) < 0 || pa_tagstruct_get_boolean(t, &e->muted) < 0 || - pa_tagstruct_getu8(t, &n_formats) < 0 || n_formats < 1) { + pa_tagstruct_getu8(t, &n_formats) < 0) { goto fail; } @@ -864,7 +863,7 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct if ((e = perportentry_read(u, name, (sink->active_port ? sink->active_port->name : NULL)))) { - if (!pa_sink_set_formats(sink, e->formats)) + if (pa_idxset_size(e->formats) > 0 && !pa_sink_set_formats(sink, e->formats)) pa_log_debug("Could not set format on sink %s", sink->name); perportentry_free(e); @@ -1009,7 +1008,9 @@ static void read_sink_format_reply(struct userdata *u, pa_tagstruct *reply, pa_s /* Read or create an entry */ name = pa_sprintf_malloc("sink:%s", sink->name); - if (!(e = perportentry_read(u, name, (sink->active_port ? sink->active_port->name : NULL)))) { + if (!(e = perportentry_read(u, name, (sink->active_port ? sink->active_port->name : NULL))) + || pa_idxset_size(e->formats) == 0) { + /* Fake a reply with PCM encoding supported */ pa_format_info *f = pa_format_info_new(); -- 1.7.10.4