diff --git a/src/audio/dp_queue.c b/src/audio/dp_queue.c index a201dde82130..3b79154a8ac3 100644 --- a/src/audio/dp_queue.c +++ b/src/audio/dp_queue.c @@ -201,10 +201,10 @@ static int dp_queue_set_ipc_params(struct dp_queue *dp_queue, if (dp_queue->_hw_params_configured && !force_update) return 0; - dp_queue->audio_stream_params.frame_fmt = params->frame_fmt; - dp_queue->audio_stream_params.rate = params->rate; - dp_queue->audio_stream_params.channels = params->channels; - dp_queue->audio_stream_params.buffer_fmt = params->buffer_fmt; + dp_queue->audio_stream_params->frame_fmt = params->frame_fmt; + dp_queue->audio_stream_params->rate = params->rate; + dp_queue->audio_stream_params->channels = params->channels; + dp_queue->audio_stream_params->buffer_fmt = params->buffer_fmt; dp_queue->_hw_params_configured = true; @@ -246,7 +246,7 @@ static const struct sink_ops dp_queue_sink_ops = { }; struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags, - uint32_t id) + uint32_t id, struct sof_audio_stream_params *audio_stream_params) { struct dp_queue *dp_queue; @@ -260,14 +260,15 @@ struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, ui return NULL; dp_queue->_flags = flags; + dp_queue->audio_stream_params = audio_stream_params; CORE_CHECK_STRUCT_INIT(dp_queue, flags & DP_QUEUE_MODE_SHARED); /* initiate structures */ source_init(dp_queue_get_source(dp_queue), &dp_queue_source_ops, - &dp_queue->audio_stream_params); + dp_queue->audio_stream_params); sink_init(dp_queue_get_sink(dp_queue), &dp_queue_sink_ops, - &dp_queue->audio_stream_params); + dp_queue->audio_stream_params); list_init(&dp_queue->list); @@ -287,7 +288,7 @@ struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, ui if (!dp_queue->_data_buffer) goto err; - dp_queue->audio_stream_params.id = id; + dp_queue->audio_stream_params->id = id; tr_info(&dp_queue_tr, "DpQueue created, id: %u shared: %u min_available: %u min_free_space %u, size %u", id, dp_queue_is_shared(dp_queue), min_available, min_free_space, dp_queue->data_buffer_size); diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 90cfc755dc54..f5c1fb83b95a 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -170,9 +170,12 @@ static int module_adapter_dp_queue_prepare(struct comp_dev *dev) size_t min_free_space = sink_get_min_free_space(audio_stream_get_sink(&source_buffer->stream)); - /* create a shadow dp queue */ + /* create a shadow dp queue + * shadow queue must share runtime_stream_params with the source_buffer + */ dp_queue = dp_queue_create(min_available, min_free_space, dp_mode, - buf_get_id(source_buffer)); + buf_get_id(source_buffer), + &source_buffer->stream.runtime_stream_params); if (!dp_queue) goto err; @@ -183,11 +186,6 @@ static int module_adapter_dp_queue_prepare(struct comp_dev *dev) */ mod->sources[i] = dp_queue_get_source(dp_queue); - /* copy parameters from buffer to be shadowed */ - memcpy_s(&dp_queue->audio_stream_params, - sizeof(dp_queue->audio_stream_params), - &source_buffer->stream.runtime_stream_params, - sizeof(source_buffer->stream.runtime_stream_params)); i++; } mod->num_of_sources = i; @@ -204,9 +202,12 @@ static int module_adapter_dp_queue_prepare(struct comp_dev *dev) size_t min_free_space = sink_get_min_free_space(audio_stream_get_sink(&sink_buffer->stream)); - /* create a shadow dp queue */ + /* create a shadow dp queue + * shadow queue must share runtime_stream_params with the sink_buffer + */ dp_queue = dp_queue_create(min_available, min_free_space, dp_mode, - buf_get_id(sink_buffer)); + buf_get_id(sink_buffer), + &sink_buffer->stream.runtime_stream_params); if (!dp_queue) goto err; @@ -217,11 +218,6 @@ static int module_adapter_dp_queue_prepare(struct comp_dev *dev) */ mod->sinks[i] = dp_queue_get_sink(dp_queue); - /* copy parameters from buffer to be shadowed */ - memcpy_s(&dp_queue->audio_stream_params, - sizeof(dp_queue->audio_stream_params), - &sink_buffer->stream.runtime_stream_params, - sizeof(sink_buffer->stream.runtime_stream_params)); /* calculate time required the module to provide OBS data portion - a period */ unsigned int sink_period = 1000000 * sink_get_min_free_space(mod->sinks[i]) / (sink_get_frame_bytes(mod->sinks[i]) * diff --git a/src/include/sof/audio/dp_queue.h b/src/include/sof/audio/dp_queue.h index 6d160877c662..201500aa6c5b 100644 --- a/src/include/sof/audio/dp_queue.h +++ b/src/include/sof/audio/dp_queue.h @@ -111,7 +111,15 @@ struct dp_queue { struct list_item list; /**< fields for connection queues in a list */ /* public: read only */ - struct sof_audio_stream_params audio_stream_params; + + /* note! + * as dpQueue is currently used as a shadow for comp_buffer only for DP components, + * the audio_stream_params vector must be shared between comp_buffer and dp_queue + * the audio_stream_params pointer should point to the proper comp_buffer structure + * + * to be changed to the structure itself when pipeline2.0 is introduced + */ + struct sof_audio_stream_params *audio_stream_params; size_t data_buffer_size; /* private: */ @@ -138,9 +146,12 @@ struct dp_queue { * * @param id a stream ID, accessible later by sink_get_id/source_get_id * + * @param audio_stream_params pointer to audio params vector, shared between dp_queue and + * comp_buffer for dp modules + * */ struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags, - uint32_t id); + uint32_t id, struct sof_audio_stream_params *audio_stream_params); /** * @brief remove the queue from the list, free dp queue memory