Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline2.0: add API to access sink/src components linked to a buffer #9530

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 @@ -480,9 +480,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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would need a "__unused" attribute to not create compiler warnings when buf_dbg() is a no-op.

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 @@ -520,9 +521,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 @@ -298,7 +298,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 @@ -329,7 +329,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 @@ -348,7 +348,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