From 80de83f38a43b51a990ea042eddb9b981813e41d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 29 Aug 2018 14:50:58 +0200 Subject: [PATCH] format: make helper function to parse media type --- spa/include/spa/param/audio/format-utils.h | 15 +++++++ spa/include/spa/param/format-utils.h | 43 +++++++++++++++++++ spa/include/spa/param/format.h | 1 + spa/include/spa/param/video/format-utils.h | 1 + spa/plugins/alsa/alsa-sink.c | 13 +----- spa/plugins/alsa/alsa-source.c | 39 ++++------------- spa/plugins/audioconvert/channelmix.c | 5 +-- spa/plugins/audioconvert/fmtconvert.c | 5 +-- spa/plugins/audioconvert/merger.c | 6 +-- spa/plugins/audioconvert/resample.c | 5 +-- spa/plugins/audioconvert/splitter.c | 6 +-- spa/plugins/audiomixer/audiomixer.c | 6 +-- spa/plugins/audiotestsrc/audiotestsrc.c | 23 ++++++---- spa/plugins/bluez5/a2dp-sink.c | 4 +- spa/plugins/ffmpeg/ffmpeg-dec.c | 6 +-- spa/plugins/ffmpeg/ffmpeg-enc.c | 6 +-- spa/plugins/v4l2/v4l2-source.c | 6 +-- spa/plugins/v4l2/v4l2-utils.c | 5 +-- spa/plugins/videotestsrc/videotestsrc.c | 6 +-- spa/plugins/volume/volume.c | 6 +-- src/gst/gstpipewireformat.c | 4 +- .../module-client-node/client-stream.c | 5 +-- src/modules/module-media-session.c | 5 +-- src/modules/module-media-session/floatmix.c | 6 +-- 24 files changed, 127 insertions(+), 100 deletions(-) create mode 100644 spa/include/spa/param/format-utils.h diff --git a/spa/include/spa/param/audio/format-utils.h b/spa/include/spa/param/audio/format-utils.h index fd7c62d51..efb6f85bf 100644 --- a/spa/include/spa/param/audio/format-utils.h +++ b/spa/include/spa/param/audio/format-utils.h @@ -26,7 +26,9 @@ extern "C" { #include +#include #include +#include static inline int spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info) @@ -40,6 +42,19 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r ":", SPA_FORMAT_AUDIO_channelMask, "?i", &info->channel_mask, NULL); } +static inline struct spa_pod * +spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_raw *info) +{ + return spa_pod_builder_object(builder, + SPA_TYPE_OBJECT_Format, id, + "I", SPA_MEDIA_TYPE_audio, + "I", SPA_MEDIA_SUBTYPE_raw, + ":", SPA_FORMAT_AUDIO_format, "I", info->format, + ":", SPA_FORMAT_AUDIO_layout, "I", info->layout, + ":", SPA_FORMAT_AUDIO_rate, "i", info->rate, + ":", SPA_FORMAT_AUDIO_channels, "i", info->channels); +} + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/include/spa/param/format-utils.h b/spa/include/spa/param/format-utils.h new file mode 100644 index 000000000..34095b2e9 --- /dev/null +++ b/spa/include/spa/param/format-utils.h @@ -0,0 +1,43 @@ +/* Simple Plugin API + * Copyright (C) 2016 Wim Taymans + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __SPA_PARAM_FORMAT_UTILS_H__ +#define __SPA_PARAM_FORMAT_UTILS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include +#include + +static inline int +spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype) +{ + return spa_pod_object_parse(format, + "I", media_type, + "I", media_subtype, NULL); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __SPA_PARAM_FORMAT_UTILS */ diff --git a/spa/include/spa/param/format.h b/spa/include/spa/param/format.h index 3ebed5d70..dd97e548e 100644 --- a/spa/include/spa/param/format.h +++ b/spa/include/spa/param/format.h @@ -28,6 +28,7 @@ extern "C" { /** media type for SPA_TYPE_OBJECT_Format */ enum spa_media_type { + SPA_MEDIA_TYPE_START, SPA_MEDIA_TYPE_audio, SPA_MEDIA_TYPE_video, SPA_MEDIA_TYPE_image, diff --git a/spa/include/spa/param/video/format-utils.h b/spa/include/spa/param/video/format-utils.h index 06def9113..15e796dff 100644 --- a/spa/include/spa/param/video/format-utils.h +++ b/spa/include/spa/param/video/format-utils.h @@ -26,6 +26,7 @@ extern "C" { #include #include +#include static inline int spa_format_video_raw_parse(const struct spa_pod *format, diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 3fbaf7644..f87e77e73 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -342,14 +342,7 @@ impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return 0; - param = spa_pod_builder_object(&b, - SPA_TYPE_OBJECT_Format, id, - "I", SPA_MEDIA_TYPE_audio, - "I", SPA_MEDIA_SUBTYPE_raw, - ":", SPA_FORMAT_AUDIO_format, "I", this->current_format.info.raw.format, - ":", SPA_FORMAT_AUDIO_layout, "I", this->current_format.info.raw.layout, - ":", SPA_FORMAT_AUDIO_rate, "i", this->current_format.info.raw.rate, - ":", SPA_FORMAT_AUDIO_channels, "i", this->current_format.info.raw.channels); + param = spa_format_audio_raw_build(&b, id, &this->current_format.info.raw); break; case SPA_PARAM_Buffers: @@ -450,9 +443,7 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - if ((err = spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype)) < 0) + if ((err = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) return err; if (info.media_type != SPA_MEDIA_TYPE_audio || diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index e0179d212..0ca34c7dd 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -305,31 +305,6 @@ static void recycle_buffer(struct state *this, uint32_t buffer_id) } } -static int port_get_format(struct spa_node *node, - enum spa_direction direction, uint32_t port_id, - uint32_t *index, - struct spa_pod **param, - struct spa_pod_builder *builder) -{ - struct state *this = SPA_CONTAINER_OF(node, struct state, node); - - if (!this->have_format) - return -EIO; - if (*index > 0) - return 0; - - *param = spa_pod_builder_object(builder, - SPA_TYPE_OBJECT_Format, SPA_PARAM_Format, - "I", SPA_MEDIA_TYPE_audio, - "I", SPA_MEDIA_SUBTYPE_raw, - ":", SPA_FORMAT_AUDIO_format, "I", this->current_format.info.raw.format, - ":", SPA_FORMAT_AUDIO_layout, "I", this->current_format.info.raw.layout, - ":", SPA_FORMAT_AUDIO_rate, "i", this->current_format.info.raw.rate, - ":", SPA_FORMAT_AUDIO_channels, "i", this->current_format.info.raw.channels); - - return 1; -} - static int impl_node_port_enum_params(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -342,7 +317,6 @@ impl_node_port_enum_params(struct spa_node *node, struct spa_pod *param; struct spa_pod_builder b = { 0 }; uint8_t buffer[1024]; - int res; spa_return_val_if_fail(node != NULL, -EINVAL); spa_return_val_if_fail(index != NULL, -EINVAL); @@ -374,8 +348,12 @@ impl_node_port_enum_params(struct spa_node *node, return spa_alsa_enum_format(this, index, filter, result, builder); case SPA_PARAM_Format: - if ((res = port_get_format(node, direction, port_id, index, ¶m, &b)) <= 0) - return res; + if (!this->have_format) + return -EIO; + if (*index > 0) + return 0; + + param = spa_format_audio_raw_build(&b, id, &this->current_format.info.raw); break; case SPA_PARAM_Buffers: @@ -469,9 +447,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((err = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return err; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index bee9fbabe..3b689a917 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -522,9 +522,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index 0d84a997d..c124bb003 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -676,9 +676,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 7bf356893..266b306c8 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -587,6 +587,7 @@ static int port_set_format(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; + int res; port = GET_PORT(this, direction, port_id); @@ -602,9 +603,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index be863c470..6dc2fd137 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -493,9 +493,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 61e3f389b..5d4b0456f 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -589,6 +589,7 @@ static int port_set_format(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; + int res; port = GET_PORT(this, direction, port_id); @@ -604,9 +605,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index 5a749e032..d82989c38 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -515,6 +515,7 @@ static int port_set_format(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; + int res; port = GET_PORT(this, direction, port_id); @@ -528,9 +529,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 39a008ef3..62137f0e3 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -705,6 +705,8 @@ port_set_format(struct impl *this, uint32_t flags, const struct spa_pod *format) { + int res; + if (format == NULL) { this->have_format = false; clear_buffers(this); @@ -713,9 +715,8 @@ port_set_format(struct impl *this, int idx; int sizes[4] = { 2, 4, 4, 8 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) @@ -724,16 +725,22 @@ port_set_format(struct impl *this, if (spa_format_audio_raw_parse(format, &info.info.raw) < 0) return -EINVAL; - if (info.info.raw.format == SPA_AUDIO_FORMAT_S16) + switch (info.info.raw.format) { + case SPA_AUDIO_FORMAT_S16: idx = 0; - else if (info.info.raw.format == SPA_AUDIO_FORMAT_S32) + break; + case SPA_AUDIO_FORMAT_S32: idx = 1; - else if (info.info.raw.format == SPA_AUDIO_FORMAT_F32) + break; + case SPA_AUDIO_FORMAT_F32: idx = 2; - else if (info.info.raw.format == SPA_AUDIO_FORMAT_F64) + break; + case SPA_AUDIO_FORMAT_F64: idx = 3; - else + break; + default: return -EINVAL; + } this->bpf = sizes[idx] * info.info.raw.channels; this->current_format = info; diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 02f1315eb..ecfcd5d30 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -1066,9 +1066,7 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - if ((err = spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype)) < 0) + if ((err = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) return err; if (info.media_type != SPA_MEDIA_TYPE_audio || diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index 46e5c5f29..d48805292 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -310,6 +310,7 @@ static int port_set_format(struct spa_node *node, { struct impl *this; struct port *port; + int res; if (node == NULL || format == NULL) return -EINVAL; @@ -327,9 +328,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_video_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_video && info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index e7954e329..03eb619c8 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -298,6 +298,7 @@ static int port_set_format(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; + int res; port = GET_PORT(this, direction, port_id); @@ -307,9 +308,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_video_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_video && info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 527ff078c..bfeefe7f4 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -552,6 +552,7 @@ static int port_set_format(struct spa_node *node, struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct spa_video_info info; struct port *port = GET_PORT(this, direction, port_id); + int res; if (format == NULL) { spa_v4l2_stream_off(this); @@ -560,9 +561,8 @@ static int port_set_format(struct spa_node *node, spa_v4l2_close(this); return 0; } else { - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_video) { spa_log_error(this->log, "media type must be video"); diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index acc283b9f..a0cdd4b96 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -544,9 +544,8 @@ spa_v4l2_enum_format(struct impl *this, } if (filter) { - spa_pod_object_parse(filter, - "I", &filter_media_type, - "I", &filter_media_subtype); + if ((res = spa_format_parse(filter, &filter_media_type, &filter_media_subtype)) < 0) + return res; } if (false) { diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index 961fbe62b..af6b6dd65 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -622,6 +622,7 @@ static int port_set_format(struct spa_node *node, const struct spa_pod *format) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); + int res; if (format == NULL) { this->have_format = false; @@ -629,9 +630,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_video_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_video && info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 5058031ad..1de770af2 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -499,6 +499,7 @@ static int port_set_format(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; + int res; port = GET_PORT(this, direction, port_id); @@ -508,9 +509,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/src/gst/gstpipewireformat.c b/src/gst/gstpipewireformat.c index 072f4fdca..ab0b50943 100644 --- a/src/gst/gstpipewireformat.c +++ b/src/gst/gstpipewireformat.c @@ -799,8 +799,8 @@ gst_caps_from_format (const struct spa_pod *format) uint32_t media_type, media_subtype; struct spa_pod_prop *prop; - spa_pod_object_parse(format, "I", &media_type, - "I", &media_subtype); + if (spa_format_parse(format, &media_type, &media_subtype) < 0) + return res; if (media_type == SPA_MEDIA_TYPE_video) { if (media_subtype == SPA_MEDIA_SUBTYPE_raw) { diff --git a/src/modules/module-client-node/client-stream.c b/src/modules/module-client-node/client-stream.c index fa63b19b3..7f5e9d9fb 100644 --- a/src/modules/module-client-node/client-stream.c +++ b/src/modules/module-client-node/client-stream.c @@ -892,9 +892,8 @@ static void client_node_initialized(void *data) return; } - spa_pod_object_parse(format, - "I", &media_type, - "I", &media_subtype); + if (spa_format_parse(format, &media_type, &media_subtype) < 0) + return; pw_log_debug("client-stream %p: %s/%s", &impl->this, spa_debug_type_find_name(spa_debug_types, media_type), diff --git a/src/modules/module-media-session.c b/src/modules/module-media-session.c index 146925893..4fe921d26 100644 --- a/src/modules/module-media-session.c +++ b/src/modules/module-media-session.c @@ -634,9 +634,8 @@ static int collect_audio_format(void *data, uint32_t id, uint32_t media_type, media_subtype; struct spa_audio_info_raw info; - spa_pod_object_parse(param, - "I", &media_type, - "I", &media_subtype); + if (spa_format_parse(param, &media_type, &media_subtype) < 0) + return 0; if (media_type != SPA_MEDIA_TYPE_audio || media_subtype != SPA_MEDIA_SUBTYPE_raw) diff --git a/src/modules/module-media-session/floatmix.c b/src/modules/module-media-session/floatmix.c index 9de291446..54d13917d 100644 --- a/src/modules/module-media-session/floatmix.c +++ b/src/modules/module-media-session/floatmix.c @@ -541,6 +541,7 @@ static int port_set_format(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; + int res; port = GET_PORT(this, direction, port_id); @@ -554,9 +555,8 @@ static int port_set_format(struct spa_node *node, } else { struct spa_audio_info info = { 0 }; - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); + if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0) + return res; if (info.media_type != SPA_MEDIA_TYPE_audio || info.media_subtype != SPA_MEDIA_SUBTYPE_raw)