Skip to content

Commit

Permalink
buf: use buffer source API in components
Browse files Browse the repository at this point in the history
This commit makes all components use API for accessing
the previous/next component

pipeline code, like module adapter or ipc helpers was
omitted intentionally

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
  • Loading branch information
marcinszkudlinski authored and lgirdwood committed Oct 2, 2024
1 parent 684cbb9 commit 40eac5d
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd)
do {
sourceb = comp_dev_get_first_data_producer(dev);

dev = sourceb->source;
dev = comp_buffer_get_source_component(sourceb);

if (!dev) {
comp_err(asrc_dev, "At beginning, no DAI found.");
Expand Down
10 changes: 6 additions & 4 deletions src/audio/buffers/comp_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,10 @@ void comp_update_buffer_produce(struct comp_buffer *buffer, uint32_t bytes)
/* return if no bytes */
if (!bytes) {
#if CONFIG_SOF_LOG_DBG_BUFFER
struct comp_dev *src_component = comp_buffer_get_source_component(buffer);
buf_dbg(buffer, "comp_update_buffer_produce(), no bytes to produce, source->comp.id = %u, source->comp.type = %u, sink->comp.id = %u, sink->comp.type = %u",
buffer->source ? dev_comp_id(buffer->source) : (unsigned int)UINT32_MAX,
buffer->source ? dev_comp_type(buffer->source) : (unsigned int)UINT32_MAX,
src_component ? dev_comp_id(src_component) : (unsigned int)UINT32_MAX,
src_component ? dev_comp_type(src_component) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_id(buffer->sink) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_type(buffer->sink) : (unsigned int)UINT32_MAX);
#endif
Expand Down Expand Up @@ -522,9 +523,10 @@ void comp_update_buffer_consume(struct comp_buffer *buffer, uint32_t bytes)
/* return if no bytes */
if (!bytes) {
#if CONFIG_SOF_LOG_DBG_BUFFER
struct comp_dev *src_component = comp_buffer_get_source_component(buffer);
buf_dbg(buffer, "comp_update_buffer_consume(), no bytes to consume, source->comp.id = %u, source->comp.type = %u, sink->comp.id = %u, sink->comp.type = %u",
buffer->source ? dev_comp_id(buffer->source) : (unsigned int)UINT32_MAX,
buffer->source ? dev_comp_type(buffer->source) : (unsigned int)UINT32_MAX,
src_component ? dev_comp_id(src_component) : (unsigned int)UINT32_MAX,
src_component ? dev_comp_type(src_component) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_id(buffer->sink) : (unsigned int)UINT32_MAX,
buffer->sink ? dev_comp_type(buffer->sink) : (unsigned int)UINT32_MAX);
#endif
Expand Down
3 changes: 1 addition & 2 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,7 @@ static inline void execute_aec(struct google_rtc_audio_processing_comp_data *cd)
static bool ref_stream_active(struct google_rtc_audio_processing_comp_data *cd)
{
#ifdef CONFIG_IPC_MAJOR_3
return cd->ref_comp_buffer->source &&
cd->ref_comp_buffer->source->state == COMP_STATE_ACTIVE;
return (comp_buffer_get_source_state(cd->ref_comp_buffer) == COMP_STATE_ACTIVE);
#else
return true;
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/audio/mixer/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int mixer_reset(struct processing_module *mod)
/* FIXME: this is racy and implicitly protected by serialised IPCs */
bool stop = false;

if (source->source && source->source->state > COMP_STATE_READY)
if (comp_buffer_get_source_state(source) > COMP_STATE_READY)
stop = true;

/* only mix the sources with the same state with mixer */
Expand Down Expand Up @@ -233,8 +233,8 @@ static int mixer_prepare(struct processing_module *mod,
* done.
*/
mixer_set_frame_alignment(&source->stream);
stop = source->source && (source->source->state == COMP_STATE_PAUSED ||
source->source->state == COMP_STATE_ACTIVE);
stop = comp_buffer_get_source_state(source) == COMP_STATE_PAUSED ||
comp_buffer_get_source_state(source) == COMP_STATE_ACTIVE;

/* only prepare downstream if we have no active sources */
if (stop)
Expand Down
9 changes: 5 additions & 4 deletions src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ static int mixout_process(struct processing_module *mod,
* sof_source implementation.
*/
unused_in_between_buf = comp_buffer_get_from_source(sources[i]);
mixin = unused_in_between_buf->source;
mixin = comp_buffer_get_source_component(unused_in_between_buf);

pending_frames = get_mixin_pending_frames(md, mixin);
if (!pending_frames)
Expand All @@ -501,7 +501,7 @@ static int mixout_process(struct processing_module *mod,
struct comp_dev *mixin;

unused_in_between_buf = comp_buffer_get_from_source(sources[i]);
mixin = unused_in_between_buf->source;
mixin = comp_buffer_get_source_component(unused_in_between_buf);

pending_frames = get_mixin_pending_frames(md, mixin);
if (!pending_frames)
Expand Down Expand Up @@ -569,8 +569,9 @@ static int mixout_reset(struct processing_module *mod)
* sof_source implementation.
*/
source_buf = comp_buffer_get_from_source(mod->sources[i]);
stop = (dev->pipeline == source_buf->source->pipeline &&
source_buf->source->state > COMP_STATE_PAUSED);
stop = (dev->pipeline ==
comp_buffer_get_source_component(source_buf)->pipeline &&
comp_buffer_get_source_state(source_buf) > COMP_STATE_PAUSED);

if (stop)
/* should not reset the downstream components */
Expand Down
6 changes: 3 additions & 3 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static int mux_process(struct processing_module *mod,
/* align source streams with their respective configurations */
j = 0;
comp_dev_for_each_producer(dev, source) {
if (source->source->state == dev->state) {
if (comp_buffer_get_source_state(source) == dev->state) {
if (frames)
frames = MIN(frames, input_buffers[j].size);
else
Expand Down Expand Up @@ -330,7 +330,7 @@ static int mux_process(struct processing_module *mod,
/* Update consumed and produced */
j = 0;
comp_dev_for_each_producer(dev, source) {
if (source->source->state == dev->state)
if (comp_buffer_get_source_state(source) == dev->state)
mod->input_buffers[j].consumed = source_bytes;
j++;
}
Expand All @@ -349,7 +349,7 @@ static int mux_reset(struct processing_module *mod)

if (dir == SOF_IPC_STREAM_PLAYBACK) {
comp_dev_for_each_producer(dev, source) {
int state = source->source->state;
int state = comp_buffer_get_source_state(source);

/* only mux the sources with the same state with mux */
if (state > COMP_STATE_READY)
Expand Down
2 changes: 1 addition & 1 deletion src/audio/selector/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ static int selector_trigger(struct comp_dev *dev, int cmd)
* kpb_init_draining() and kpb_draining_task() are interrupted by
* new pipeline_task()
*/
type = dev_comp_type(sourceb->source);
type = dev_comp_type(comp_buffer_get_source_component(sourceb));

return type == SOF_COMP_KPB ? PPL_STATUS_PATH_TERMINATE : ret;
}
Expand Down
4 changes: 3 additions & 1 deletion src/include/sof/audio/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ void buffer_detach(struct comp_buffer *buffer, struct list_item *head, int dir);

static inline struct comp_dev *buffer_get_comp(struct comp_buffer *buffer, int dir)
{
struct comp_dev *comp = dir == PPL_DIR_DOWNSTREAM ? buffer->sink : buffer->source;
struct comp_dev *comp = (dir == PPL_DIR_DOWNSTREAM) ?
buffer->sink :
comp_buffer_get_source_component(buffer);
return comp;
}

Expand Down
5 changes: 3 additions & 2 deletions src/samples/audio/smart_amp_test_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static int smart_amp_copy(struct comp_dev *dev)
if (sad->feedback_buf) {
struct comp_buffer *buf = sad->feedback_buf;

if (buf->source && comp_get_state(buf->source) == dev->state) {
if (comp_buffer_get_source_state(buf) == dev->state) {
/* feedback */
avail_feedback_frames =
audio_stream_get_avail_frames(&buf->stream);
Expand Down Expand Up @@ -501,7 +501,8 @@ static int smart_amp_prepare(struct comp_dev *dev)
/* searching for stream and feedback source buffers */
comp_dev_for_each_producer(dev, source_buffer) {
/* FIXME: how often can this loop be run? */
if (source_buffer->source->ipc_config.type == SOF_COMP_DEMUX)
if (comp_buffer_get_source_component(source_buffer)->ipc_config.type ==
SOF_COMP_DEMUX)
sad->feedback_buf = source_buffer;
else
sad->source_buf = source_buffer;
Expand Down

0 comments on commit 40eac5d

Please sign in to comment.