diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index e6badacd2..606002a05 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1062,6 +1062,10 @@ static int enum_pcm_formats(struct state *state, uint32_t index, uint32_t *next, } } } + if (j > 1) + choice->body.type = SPA_CHOICE_Enum; + spa_pod_builder_pop(b, &f[1]); + if (j == 0) { char buf[1024]; int i, r, offs; @@ -1090,9 +1094,6 @@ static int enum_pcm_formats(struct state *state, uint32_t index, uint32_t *next, spa_log_warn(state->log, "%s: access:%s", state->props.device, buf); return -ENOTSUP; } - if (j > 1) - choice->body.type = SPA_CHOICE_Enum; - spa_pod_builder_pop(b, &f[1]); if ((res = add_rate(state, 1, 1, false, index & 0xffff, next, 0, params, b)) != 1) return res; diff --git a/spa/plugins/bluez5/a2dp-codec-aac.c b/spa/plugins/bluez5/a2dp-codec-aac.c index 418d33898..e440c3657 100644 --- a/spa/plugins/bluez5/a2dp-codec-aac.c +++ b/spa/plugins/bluez5/a2dp-codec-aac.c @@ -193,12 +193,12 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags, spa_pod_builder_int(b, f->value); } } - if (i == 0) - return -EINVAL; if (i > 1) choice->body.type = SPA_CHOICE_Enum; spa_pod_builder_pop(b, &f[1]); + if (i == 0) + return -EINVAL; if (SPA_FLAG_IS_SET(conf.channels, AAC_CHANNELS_1 | AAC_CHANNELS_2)) { spa_pod_builder_add(b, diff --git a/spa/plugins/bluez5/a2dp-codec-aptx.c b/spa/plugins/bluez5/a2dp-codec-aptx.c index fb59fcb09..dbd60fad4 100644 --- a/spa/plugins/bluez5/a2dp-codec-aptx.c +++ b/spa/plugins/bluez5/a2dp-codec-aptx.c @@ -247,12 +247,13 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags, spa_pod_builder_int(b, 16000); spa_pod_builder_int(b, 16000); } - if (i == 0) - return -EINVAL; if (i > 1) choice->body.type = SPA_CHOICE_Enum; spa_pod_builder_pop(b, &f[1]); + if (i == 0) + return -EINVAL; + if (SPA_FLAG_IS_SET(conf.channel_mode, APTX_CHANNEL_MODE_MONO | APTX_CHANNEL_MODE_STEREO)) { spa_pod_builder_add(b, SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(2, 1, 2), diff --git a/spa/plugins/bluez5/a2dp-codec-faststream.c b/spa/plugins/bluez5/a2dp-codec-faststream.c index 90167e2cd..ce70e43f3 100644 --- a/spa/plugins/bluez5/a2dp-codec-faststream.c +++ b/spa/plugins/bluez5/a2dp-codec-faststream.c @@ -148,11 +148,11 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags, spa_pod_builder_int(b, 44100); spa_pod_builder_int(b, 44100); } - if (i == 0) - return -EINVAL; if (i > 1) choice->body.type = SPA_CHOICE_Enum; spa_pod_builder_pop(b, &f[1]); + if (i == 0) + return -EINVAL; position[0] = SPA_AUDIO_CHANNEL_FL; position[1] = SPA_AUDIO_CHANNEL_FR; diff --git a/spa/plugins/bluez5/a2dp-codec-ldac.c b/spa/plugins/bluez5/a2dp-codec-ldac.c index 46d643593..3ec20b720 100644 --- a/spa/plugins/bluez5/a2dp-codec-ldac.c +++ b/spa/plugins/bluez5/a2dp-codec-ldac.c @@ -184,12 +184,13 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags, spa_pod_builder_int(b, 96000); spa_pod_builder_int(b, 96000); } - if (i == 0) - return -EINVAL; if (i > 1) choice->body.type = SPA_CHOICE_Enum; spa_pod_builder_pop(b, &f[1]); + if (i == 0) + return -EINVAL; + if (conf.channel_mode & LDACBT_CHANNEL_MODE_MONO && conf.channel_mode & (LDACBT_CHANNEL_MODE_STEREO | LDACBT_CHANNEL_MODE_DUAL_CHANNEL)) { diff --git a/src/modules/module-protocol-native/v0/protocol-native.c b/src/modules/module-protocol-native/v0/protocol-native.c index b3b35d8db..91ce017a1 100644 --- a/src/modules/module-protocol-native/v0/protocol-native.c +++ b/src/modules/module-protocol-native/v0/protocol-native.c @@ -400,7 +400,7 @@ struct spa_pod_prop_body0 { static int remap_from_v2(uint32_t type, void *body, uint32_t size, struct pw_impl_client *client, struct spa_pod_builder *builder) { - int res; + int res = 0; switch (type) { case SPA_TYPE_Id: @@ -445,17 +445,17 @@ static int remap_from_v2(uint32_t type, void *body, uint32_t size, struct pw_imp if (b->value.type == SPA_TYPE_Id) { uint32_t id; if ((res = spa_pod_get_id(&b->value, &id)) < 0) - return res; + goto done; + spa_pod_builder_id(builder, pw_protocol_native0_type_from_v2(client, id)); SPA_POD_PROP_ALTERNATIVE_FOREACH0(b, size, alt) if ((res = remap_from_v2(b->value.type, alt, b->value.size, client, builder)) < 0) - return res; + break; } else { spa_pod_builder_raw(builder, &b->value, size - sizeof(struct spa_pod)); } - +done: spa_pod_builder_pop(builder, &f); - break; } case SPA_TYPE_Object: @@ -493,7 +493,7 @@ static int remap_from_v2(uint32_t type, void *body, uint32_t size, struct pw_imp SPA_POD_BODY(p), p->size, client, builder)) < 0) - return res; + break; } spa_pod_builder_pop(builder, &f); break; @@ -506,14 +506,14 @@ static int remap_from_v2(uint32_t type, void *body, uint32_t size, struct pw_imp spa_pod_builder_push_struct(builder, &f); SPA_POD_FOREACH(b, size, p) if ((res = remap_from_v2(p->type, SPA_POD_BODY(p), p->size, client, builder)) < 0) - return res; + break; spa_pod_builder_pop(builder, &f); break; } default: break; } - return 0; + return res; } static int remap_to_v2(struct pw_impl_client *client, const struct spa_type_info *info,