pulse-server: fix parsing of format-info

Fixes totem playback
This commit is contained in:
Wim Taymans 2020-11-24 15:11:05 +01:00
parent d0d64de1a0
commit 6ab25c6904
3 changed files with 10 additions and 3 deletions

View file

@ -157,7 +157,7 @@ static inline int spa_json_next(struct spa_json * iter, const char **value)
return -1; return -1;
} }
} }
return iter->depth == 0 ? 0 : -1; return (iter->depth == 0 ? (iter->state == __BARE ? iter->cur - *value : 0) : -1);
} }
static inline int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type) static inline int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)

View file

@ -447,7 +447,7 @@ static const struct spa_pod *format_info_build_param(struct spa_pod_builder *b,
if ((len = spa_json_next(&it[0], &val)) <= 0) if ((len = spa_json_next(&it[0], &val)) <= 0)
return NULL; return NULL;
if (spa_json_is_string(val, len)) { if (spa_json_is_string(val, len)) {
ss.format = format_paname2id(val, len); ss.format = format_paname2id(val+1, len-2);
if (ss.format == SPA_AUDIO_FORMAT_UNKNOWN) if (ss.format == SPA_AUDIO_FORMAT_UNKNOWN)
return NULL; return NULL;
} else if (spa_json_is_array(val, len)) { } else if (spa_json_is_array(val, len)) {
@ -457,6 +457,7 @@ static const struct spa_pod *format_info_build_param(struct spa_pod_builder *b,
if ((str = pw_properties_get(info->props, "format.rate")) == NULL) if ((str = pw_properties_get(info->props, "format.rate")) == NULL)
return NULL; return NULL;
spa_json_init(&it[0], str, strlen(str)); spa_json_init(&it[0], str, strlen(str));
if ((len = spa_json_next(&it[0], &val)) <= 0) if ((len = spa_json_next(&it[0], &val)) <= 0)
return NULL; return NULL;
@ -473,6 +474,7 @@ static const struct spa_pod *format_info_build_param(struct spa_pod_builder *b,
if ((str = pw_properties_get(info->props, "format.channels")) == NULL) if ((str = pw_properties_get(info->props, "format.channels")) == NULL)
return NULL; return NULL;
spa_json_init(&it[0], str, strlen(str)); spa_json_init(&it[0], str, strlen(str));
if ((len = spa_json_next(&it[0], &val)) <= 0) if ((len = spa_json_next(&it[0], &val)) <= 0)
return NULL; return NULL;
@ -488,6 +490,11 @@ static const struct spa_pod *format_info_build_param(struct spa_pod_builder *b,
return NULL; return NULL;
if ((str = pw_properties_get(info->props, "format.channel_map")) != NULL) { if ((str = pw_properties_get(info->props, "format.channel_map")) != NULL) {
spa_json_init(&it[0], str, strlen(str));
if ((len = spa_json_next(&it[0], &val)) <= 0)
return NULL;
if (!spa_json_is_string(val, len))
return NULL;
while ((*str == '\"' || *str == ',') && while ((*str == '\"' || *str == ',') &&
(len = strcspn(++str, "\",")) > 0) { (len = strcspn(++str, "\",")) > 0) {
map.map[map.channels++] = channel_paname2id(str, len); map.map[map.channels++] = channel_paname2id(str, len);

View file

@ -157,7 +157,7 @@ static inline int spa_json_next(struct spa_json * iter, const char **value)
return -1; return -1;
} }
} }
return iter->depth == 0 ? 0 : -1; return (iter->depth == 0 ? (iter->state == __BARE ? iter->cur - *value : 0) : -1);
} }
static inline int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type) static inline int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)