From af310523db41893503d4cf1799783e7d2bd86625 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 28 Mar 2024 17:11:16 +0100 Subject: [PATCH] spa: improve null-audio-sink channels We can just update the channels in the props, we don't need an extra property that can go out of sync with the channels. See #3931 --- spa/plugins/support/null-audio-sink.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/spa/plugins/support/null-audio-sink.c b/spa/plugins/support/null-audio-sink.c index e7f4cff30..91d28db54 100644 --- a/spa/plugins/support/null-audio-sink.c +++ b/spa/plugins/support/null-audio-sink.c @@ -39,7 +39,6 @@ struct props { uint32_t format; uint32_t channels; uint32_t rate; - uint32_t n_pos; uint32_t pos[SPA_AUDIO_MAX_CHANNELS]; char clock_name[64]; unsigned int debug:1; @@ -51,7 +50,6 @@ static void reset_props(struct props *props) props->format = 0; props->channels = 0; props->rate = 0; - props->n_pos = 0; strncpy(props->clock_name, DEFAULT_CLOCK_NAME, sizeof(props->clock_name)); props->debug = false; props->driver = true; @@ -471,10 +469,10 @@ port_enum_formats(struct impl *this, SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(DEFAULT_CHANNELS, 1, INT32_MAX), 0); } - if (this->props.n_pos != 0) { + if (this->props.channels != 0) { spa_pod_builder_prop(builder, SPA_FORMAT_AUDIO_position, 0); spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id, - this->props.n_pos, this->props.pos); + this->props.channels, this->props.pos); } *param = spa_pod_builder_pop(builder, &f[0]); break; @@ -890,10 +888,10 @@ static inline void parse_position(struct impl *this, const char *val, size_t len if (spa_json_enter_array(&it[0], &it[1]) <= 0) spa_json_init(&it[1], val, len); - this->props.n_pos = 0; + this->props.channels = 0; while (spa_json_get_string(&it[1], v, sizeof(v)) > 0 && - this->props.n_pos < SPA_AUDIO_MAX_CHANNELS) { - this->props.pos[this->props.n_pos++] = channel_from_name(v); + this->props.channels < SPA_AUDIO_MAX_CHANNELS) { + this->props.pos[this->props.channels++] = channel_from_name(v); } } @@ -993,9 +991,6 @@ impl_init(const struct spa_handle_factory *factory, "%s", s); } } - if (this->props.n_pos > 0) - this->props.channels = this->props.n_pos; - spa_log_info(this->log, "%p: initialized", this); return 0;