From 00a570f7de9ef7618e3770c570f3b9005f27d98c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 7 Nov 2018 11:54:23 +0100 Subject: [PATCH] audio-format: set unpossisioned flag If we don't have position information in the format, set the unpositioned flag. Don't set position info in the format when the unpositioned flag is set. --- spa/include/spa/param/audio/format-utils.h | 8 ++++++-- spa/plugins/audioconvert/fmtconvert.c | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/spa/include/spa/param/audio/format-utils.h b/spa/include/spa/param/audio/format-utils.h index 813f02ea2..fef80db71 100644 --- a/spa/include/spa/param/audio/format-utils.h +++ b/spa/include/spa/param/audio/format-utils.h @@ -52,6 +52,9 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r uint32_t n_values = SPA_MIN(SPA_POD_ARRAY_N_VALUES(position), SPA_AUDIO_MAX_CHANNELS); memcpy(info->position, values, n_values * sizeof(uint32_t)); } + else + SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED); + return res; } @@ -67,9 +70,10 @@ spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(info->channels), 0); - if (info->channels > 1) { + if (!SPA_FLAG_CHECK(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) { spa_pod_builder_prop(builder, SPA_FORMAT_AUDIO_position, 0); - spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id, info->channels, info->position); + spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id, + info->channels, info->position); } return spa_pod_builder_pop(builder); } diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index ef1bccac4..f6ecb3d9e 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -354,9 +354,11 @@ static int port_enum_formats(struct spa_node *node, SPA_FORMAT_AUDIO_rate, &SPA_POD_Int(other->info.raw.rate), SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(other->info.raw.channels), 0); - spa_pod_builder_prop(builder, SPA_FORMAT_AUDIO_position, 0); - spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id, - info.info.raw.channels, info.info.raw.position); + if (!SPA_FLAG_CHECK(other->info.raw.flags, SPA_AUDIO_FLAG_UNPOSITIONED)) { + spa_pod_builder_prop(builder, SPA_FORMAT_AUDIO_position, 0); + spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id, + info.info.raw.channels, info.info.raw.position); + } *param = spa_pod_builder_pop(builder); } else { *param = spa_pod_builder_object(builder,