diff --git a/src/audio/crossover/crossover.c b/src/audio/crossover/crossover.c index e94368c2a881..d54e4fbe5370 100644 --- a/src/audio/crossover/crossover.c +++ b/src/audio/crossover/crossover.c @@ -125,7 +125,8 @@ static int crossover_get_stream_index(struct processing_module *mod, * config->num_sinks if no errors were found. */ static int crossover_assign_sinks(struct processing_module *mod, - struct comp_buffer **sinks, + struct output_stream_buffer *output_buffers, + struct output_stream_buffer **assigned_obufs, bool *enabled) { struct comp_data *cd = module_get_private_data(mod); @@ -157,7 +158,7 @@ static int crossover_assign_sinks(struct processing_module *mod, /* If no config is set, then assign the sinks in order */ if (!config) { - sinks[num_sinks++] = sink; + assigned_obufs[num_sinks++] = &output_buffers[j]; enabled[j++] = true; continue; } @@ -174,14 +175,14 @@ static int crossover_assign_sinks(struct processing_module *mod, break; } - if (sinks[i]) { + if (assigned_obufs[i]) { comp_err(dev, "crossover_assign_sinks(), multiple sinks from pipeline %d are assigned", sink_id); break; } - sinks[i] = sink; + assigned_obufs[i] = &output_buffers[j]; enabled[j++] = true; num_sinks++; } @@ -618,7 +619,7 @@ static int crossover_process_audio_stream(struct processing_module *mod, struct output_stream_buffer *output_buffers, int num_output_buffers) { - struct comp_buffer *sinks[SOF_CROSSOVER_MAX_STREAMS] = { NULL }; + struct output_stream_buffer *assigned_obufs[SOF_CROSSOVER_MAX_STREAMS] = { NULL }; bool enabled_buffers[PLATFORM_MAX_STREAMS] = { false }; struct comp_data *cd = module_get_private_data(mod); struct comp_dev *dev = mod->dev; @@ -653,7 +654,8 @@ static int crossover_process_audio_stream(struct processing_module *mod, * state than the component. Therefore not all sinks are guaranteed * to be assigned: sink[i] can be NULL, 0 <= i <= config->num_sinks */ - num_assigned_sinks = crossover_assign_sinks(mod, sinks, enabled_buffers); + num_assigned_sinks = crossover_assign_sinks(mod, output_buffers, assigned_obufs, + enabled_buffers); if (cd->config && num_assigned_sinks != cd->config->num_sinks) comp_dbg(dev, "crossover_copy(), number of assigned sinks (%i) does not match number of sinks in config (%i).", num_assigned_sinks, cd->config->num_sinks); @@ -670,7 +672,7 @@ static int crossover_process_audio_stream(struct processing_module *mod, if (!frames) return -ENODATA; - cd->crossover_process(cd, input_buffers, sinks, num_sinks, frames); + cd->crossover_process(cd, input_buffers, assigned_obufs, num_sinks, frames); processed_bytes = frames * frame_bytes; mod->input_buffers[0].consumed = processed_bytes; diff --git a/src/audio/crossover/crossover_generic.c b/src/audio/crossover/crossover_generic.c index eb278d34dfc1..ad8b6b930ea9 100644 --- a/src/audio/crossover/crossover_generic.c +++ b/src/audio/crossover/crossover_generic.c @@ -89,10 +89,11 @@ static void crossover_generic_split_4way(int32_t in, #if CONFIG_FORMAT_S16LE static void crossover_s16_default_pass(struct comp_data *cd, struct input_stream_buffer *bsource, - struct comp_buffer __sparse_cache *sinks[], + struct output_stream_buffer **bsinks, int32_t num_sinks, uint32_t frames) { + const struct audio_stream __sparse_cache *sink_stream; const struct audio_stream __sparse_cache *source_stream = bsource->data; int16_t *x; int32_t *y; @@ -102,9 +103,11 @@ static void crossover_s16_default_pass(struct comp_data *cd, for (i = 0; i < n; i++) { x = audio_stream_read_frag_s16(source_stream, i); for (j = 0; j < num_sinks; j++) { - if (!sinks[j]) + if (!bsinks[j]) continue; - y = audio_stream_write_frag_s16((&sinks[j]->stream), i); + + sink_stream = bsinks[j]->data; + y = audio_stream_write_frag_s16(sink_stream, i); *y = *x; } } @@ -114,10 +117,11 @@ static void crossover_s16_default_pass(struct comp_data *cd, #if CONFIG_FORMAT_S24LE || CONFIG_FORMAT_S32LE static void crossover_s32_default_pass(struct comp_data *cd, struct input_stream_buffer *bsource, - struct comp_buffer __sparse_cache *sinks[], + struct output_stream_buffer **bsinks, int32_t num_sinks, uint32_t frames) { + const struct audio_stream __sparse_cache *sink_stream; const struct audio_stream __sparse_cache *source_stream = bsource->data; int32_t *x, *y; int i, j; @@ -126,9 +130,11 @@ static void crossover_s32_default_pass(struct comp_data *cd, for (i = 0; i < n; i++) { x = audio_stream_read_frag_s32(source_stream, i); for (j = 0; j < num_sinks; j++) { - if (!sinks[j]) + if (!bsinks[j]) continue; - y = audio_stream_write_frag_s32((&sinks[j]->stream), i); + + sink_stream = bsinks[j]->data; + y = audio_stream_write_frag_s32(sink_stream, i); *y = *x; } } @@ -138,7 +144,7 @@ static void crossover_s32_default_pass(struct comp_data *cd, #if CONFIG_FORMAT_S16LE static void crossover_s16_default(struct comp_data *cd, struct input_stream_buffer *bsource, - struct comp_buffer __sparse_cache *sinks[], + struct output_stream_buffer **bsinks, int32_t num_sinks, uint32_t frames) { @@ -159,9 +165,9 @@ static void crossover_s16_default(struct comp_data *cd, cd->crossover_split(*x << 16, out, state); for (j = 0; j < num_sinks; j++) { - if (!sinks[j]) + if (!bsinks[j]) continue; - sink_stream = &sinks[j]->stream; + sink_stream = bsinks[j]->data; y = audio_stream_write_frag_s16(sink_stream, idx); *y = sat_int16(Q_SHIFT_RND(out[j], 31, 15)); @@ -176,7 +182,7 @@ static void crossover_s16_default(struct comp_data *cd, #if CONFIG_FORMAT_S24LE static void crossover_s24_default(struct comp_data *cd, struct input_stream_buffer *bsource, - struct comp_buffer __sparse_cache *sinks[], + struct output_stream_buffer **bsinks, int32_t num_sinks, uint32_t frames) { @@ -197,9 +203,9 @@ static void crossover_s24_default(struct comp_data *cd, cd->crossover_split(*x << 8, out, state); for (j = 0; j < num_sinks; j++) { - if (!sinks[j]) + if (!bsinks[j]) continue; - sink_stream = &sinks[j]->stream; + sink_stream = bsinks[j]->data; y = audio_stream_write_frag_s32(sink_stream, idx); *y = sat_int24(Q_SHIFT_RND(out[j], 31, 23)); @@ -214,7 +220,7 @@ static void crossover_s24_default(struct comp_data *cd, #if CONFIG_FORMAT_S32LE static void crossover_s32_default(struct comp_data *cd, struct input_stream_buffer *bsource, - struct comp_buffer __sparse_cache *sinks[], + struct output_stream_buffer **bsinks, int32_t num_sinks, uint32_t frames) { @@ -235,9 +241,9 @@ static void crossover_s32_default(struct comp_data *cd, cd->crossover_split(*x, out, state); for (j = 0; j < num_sinks; j++) { - if (!sinks[j]) + if (!bsinks[j]) continue; - sink_stream = &sinks[j]->stream; + sink_stream = bsinks[j]->data; y = audio_stream_write_frag_s32(sink_stream, idx); *y = out[j]; diff --git a/src/include/sof/audio/crossover/crossover.h b/src/include/sof/audio/crossover/crossover.h index 980a33bf4e84..cefe7de9271e 100644 --- a/src/include/sof/audio/crossover/crossover.h +++ b/src/include/sof/audio/crossover/crossover.h @@ -71,7 +71,7 @@ struct comp_data; typedef void (*crossover_process)(struct comp_data *cd, struct input_stream_buffer *bsource, - struct comp_buffer __sparse_cache *sinks[], + struct output_stream_buffer *bsinks[], int32_t num_sinks, uint32_t frames);