Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ static int mux_cmd(struct comp_dev *dev, int cmd, void *data,
}
}

static void prepare_active_look_up(struct comp_dev *dev,
struct audio_stream *sink,
const struct audio_stream **sources)
static void mux_prepare_active_look_up(struct comp_dev *dev,
struct audio_stream *sink,
const struct audio_stream **sources)
{
struct comp_data *cd = comp_get_drvdata(dev);
const struct audio_stream *source;
Expand All @@ -336,13 +336,47 @@ static void prepare_active_look_up(struct comp_dev *dev,
if (!source)
continue;

if ((cd->lookup[0].copy_elem[elem].in_ch >
(source->channels - 1)) ||
(cd->lookup[0].copy_elem[elem].out_ch >
(sink->channels - 1)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the in_ch and out_ch 0 based? Or '>xx->channels -1' here should be 'xx->channels'? The similar question for the demux part also.

@bkokoszx bkokoszx Nov 5, 2020 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie
in_ch and out_ch is 0 based here, similar as in demux part.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fwiw, a future optimisation could be the removal of the lookup[0] to just lookup. I dont think we have the need for an array here ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie
in_ch and out_ch is 0 based here, similar as in demux part.

OK, then makes sense.

continue;

cd->active_lookup.copy_elem[active_elem] =
cd->lookup[0].copy_elem[elem];
active_elem++;
cd->active_lookup.num_elems = active_elem;
}
}

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)
{
Expand Down Expand Up @@ -423,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]);
}

Expand Down Expand Up @@ -519,7 +555,7 @@ static int mux_copy(struct comp_dev *dev)
}
sink_bytes = frames * audio_stream_frame_bytes(&sink->stream);

prepare_active_look_up(dev, &sink->stream, &sources_stream[0]);
mux_prepare_active_look_up(dev, &sink->stream, &sources_stream[0]);

/* produce output */
cd->mux(dev, &sink->stream, &sources_stream[0], frames,
Expand Down