spa: update the UNPOSITIONED flag

When we can't parse valid positions, make sure the UNPOSITIONED flag is
set for raw audio info.
This commit is contained in:
Wim Taymans 2024-11-14 11:06:11 +01:00
parent 388f330700
commit 2ad8904ac8

View file

@ -52,8 +52,10 @@ spa_audio_info_raw_update(struct spa_audio_info_raw *info, const char *key, cons
if (spa_atou32(val, &v, 0) && (force || info->channels == 0)) if (spa_atou32(val, &v, 0) && (force || info->channels == 0))
info->channels = SPA_MIN(v, SPA_AUDIO_MAX_CHANNELS); info->channels = SPA_MIN(v, SPA_AUDIO_MAX_CHANNELS);
} else if (spa_streq(key, SPA_KEY_AUDIO_POSITION)) { } else if (spa_streq(key, SPA_KEY_AUDIO_POSITION)) {
if (force || info->channels == 0) if (force || info->channels == 0) {
spa_audio_parse_position(val, strlen(val), info->position, &info->channels); if (spa_audio_parse_position(val, strlen(val), info->position, &info->channels) > 0)
SPA_FLAG_CLEAR(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
}
} }
return 0; return 0;
} }
@ -64,6 +66,7 @@ spa_audio_info_raw_init_dict_keys(struct spa_audio_info_raw *info,
const struct spa_dict *dict, ...) const struct spa_dict *dict, ...)
{ {
spa_zero(*info); spa_zero(*info);
SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
if (dict) { if (dict) {
const char *val, *key; const char *val, *key;
va_list args; va_list args;