demux: add demux_prepare_active_look_up() function

This commit adds demux_prepare_active_look_up()
function. It contains channel parameter checking.
Look up table should not include elements referring
to channels higher than those actually set in
source/sink buffers.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
Bartosz Kokoszko 2020-11-04 11:51:12 +01:00 committed by Liam Girdwood
parent acc022b4c4
commit 85986e1f4f
1 changed files with 31 additions and 1 deletions

View File

@ -349,6 +349,34 @@ static void mux_prepare_active_look_up(struct comp_dev *dev,
}
}
static void demux_prepare_active_look_up(struct comp_dev *dev,
struct audio_stream *sink,
const struct audio_stream *source,
struct mux_look_up *look_up)
{
struct comp_data *cd = comp_get_drvdata(dev);
uint8_t active_elem;
uint8_t elem;
cd->active_lookup.num_elems = 0;
active_elem = 0;
/* init pointers */
for (elem = 0; elem < look_up->num_elems; elem++) {
if ((look_up->copy_elem[elem].in_ch >
(source->channels - 1)) ||
(look_up->copy_elem[elem].out_ch >
(sink->channels - 1)))
continue;
cd->active_lookup.copy_elem[active_elem] =
look_up->copy_elem[elem];
active_elem++;
cd->active_lookup.num_elems = active_elem;
}
}
/* process and copy stream data from source to sink buffers */
static int demux_copy(struct comp_dev *dev)
{
@ -429,9 +457,11 @@ static int demux_copy(struct comp_dev *dev)
if (!sinks[i])
continue;
demux_prepare_active_look_up(dev, &sinks[i]->stream,
&source->stream, look_ups[i]);
buffer_invalidate(source, source_bytes);
cd->demux(dev, &sinks[i]->stream, &source->stream, frames,
look_ups[i]);
&cd->active_lookup);
buffer_writeback(sinks[i], sinks_bytes[i]);
}