diff --git a/src/audio/pipeline/pipeline-params.c b/src/audio/pipeline/pipeline-params.c index 36936b8283a0..c54d30347f8a 100644 --- a/src/audio/pipeline/pipeline-params.c +++ b/src/audio/pipeline/pipeline-params.c @@ -49,20 +49,20 @@ static int pipeline_comp_params_neg(struct comp_dev *current, err = audio_buffer_set_params(calling_buf, &ppl_data->params->params, BUFFER_UPDATE_FORCE); break; -// default: -// /* return 0 if params matches */ -//msz if (!buffer_params_match(calling_buf, -// &ppl_data->params->params, -// BUFF_PARAMS_FRAME_FMT | -// BUFF_PARAMS_RATE)) { -// /* -// * parameters conflict with an active pipeline, -// * drop an error and reject the .params() command. -// */ -// pipe_err(current->pipeline, -// "pipeline_comp_params_neg(): params conflict with existing active pipeline!"); -// err = -EINVAL; -// } + default: + /* return 0 if params matches */ + if (!audio_buffer_params_match(calling_buf, + &ppl_data->params->params, + BUFF_PARAMS_FRAME_FMT | + BUFF_PARAMS_RATE)) { + /* + * parameters conflict with an active pipeline, + * drop an error and reject the .params() command. + */ + pipe_err(current->pipeline, + "pipeline_comp_params_neg(): params conflict with existing active pipeline!"); + err = -EINVAL; + } } return err; } diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index 55a8beefd6ca..549c0309a669 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -168,14 +168,13 @@ struct buffer_cb_free { static inline struct sof_audio_buffer *buffer_from_list(struct list_item *clist, int dir) { - return NULL; - //msz -} + struct comp_buffer *comp_buffer = + ((dir) == PPL_DIR_DOWNSTREAM ? + container_of(clist, struct comp_buffer, source_list) : + container_of(clist, struct comp_buffer, sink_list)); -//#define buffer_from_list(ptr, dir) \ -// ((dir) == PPL_DIR_DOWNSTREAM ? \ -// container_of(ptr, struct comp_buffer, source_list) : \ -// container_of(ptr, struct comp_buffer, sink_list)) + return comp_buffer ? &comp_buffer->audio_buffer : NULL; +} #define buffer_set_cb(buffer, func, data, type) \ do { \ @@ -261,14 +260,15 @@ void buffer_attach(struct comp_buffer *buffer, struct list_item *head, int dir); */ void buffer_detach(struct comp_buffer *buffer, struct list_item *head, int dir); -static inline struct comp_dev *buffer_get_comp(struct sof_audio_buffer *buffer, int dir) +static inline struct comp_dev *buffer_get_comp(struct sof_audio_buffer *audio_buffer, int dir) { -// struct comp_dev *comp = (dir == PPL_DIR_DOWNSTREAM) ? -// comp_buffer_get_sink_component(buffer) : -// comp_buffer_get_source_component(buffer); -// return comp; - return NULL; - //msz + struct comp_buffer *comp_buffer = + container_of(audio_buffer, struct comp_buffer, audio_buffer); + struct comp_dev *comp = (dir == PPL_DIR_DOWNSTREAM) ? + comp_buffer_get_sink_component(comp_buffer) : + comp_buffer_get_source_component(comp_buffer); + + return comp; } static inline uint32_t buffer_pipeline_id(const struct comp_buffer *buffer) diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index e33d0313e86f..5e9c6a60e477 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -135,16 +135,18 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag, * has only one sink or one source buffer. */ if (list_is_empty(source_list) != list_is_empty(sink_list)) { -// if (list_is_empty(sink_list)) -// buf = list_first_item(source_list, -// struct comp_buffer, -// sink_list); -// else -// buf = list_first_item(sink_list, -// struct comp_buffer, -// source_list); - //msz - + struct comp_buffer *comp_buffer; + + if (list_is_empty(sink_list)) + comp_buffer = list_first_item(source_list, + struct comp_buffer, + sink_list); + else + comp_buffer = list_first_item(sink_list, + struct comp_buffer, + source_list); + + buf = &comp_buffer->audio_buffer; /* update specific pcm parameter with buffer parameter if * specific flag is set. */ @@ -156,7 +158,7 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag, audio_buffer_set_params(buf, params, BUFFER_UPDATE_FORCE); /* set component period frames */ - //msz component_set_nearest_period_frames(dev, audio_stream_get_rate(&buf->stream)); + component_set_nearest_period_frames(dev, audio_buffer_get_rate(buf)); } else { /* for other components we iterate over all downstream buffers * (for playback) or upstream buffers (for capture). @@ -165,7 +167,7 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag, list_for_item(clist, buffer_list) { buf = buffer_from_list(clist, dir); -// comp_update_params(flag, params, buf); + comp_update_params(flag, params, buf); audio_buffer_set_params(buf, params, BUFFER_UPDATE_FORCE); }