Skip to content

Commit

Permalink
dp: make dp_queue using externally provided params set
Browse files Browse the repository at this point in the history
Dp_queue is currently used only as a comp_buffer "shadow"
for DP modules.
Shadow buffers must have the very same param set as main
buffers.
Problem: till now the complete vector of params was
copied from comp_buffer to dp_queue inm prepare method.
Problem is that if anything will change any of params
afterwards, the change won't propagate.
This commit introduces sharing the param vector between
comp_buffer and its shadow

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
  • Loading branch information
marcinszkudlinski committed Apr 19, 2024
1 parent 481b328 commit aa07558
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
17 changes: 9 additions & 8 deletions src/audio/dp_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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);

Expand All @@ -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);
Expand Down
24 changes: 10 additions & 14 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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]) *
Expand Down
15 changes: 13 additions & 2 deletions src/include/sof/audio/dp_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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: */
Expand All @@ -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
Expand Down

0 comments on commit aa07558

Please sign in to comment.