Skip to content

Commit

Permalink
sink/src: add ID to sink/src API
Browse files Browse the repository at this point in the history
add get buffer ID to sink/src api

Signed-off-by: Marcin Szkudlinski <[email protected]>
  • Loading branch information
marcinszkudlinski authored and kv2019i committed Nov 22, 2023
1 parent a62b7cf commit c82226e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/audio/dp_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ static const struct sink_ops dp_queue_sink_ops = {
.audio_set_ipc_params = dp_queue_set_ipc_params_sink,
};

struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags)
struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags,
uint32_t id)
{
struct dp_queue *dp_queue;

Expand Down Expand Up @@ -286,8 +287,9 @@ struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, ui
if (!dp_queue->_data_buffer)
goto err;

tr_info(&dp_queue_tr, "DpQueue created, shared: %u min_available: %u min_free_space %u, size %u",
dp_queue_is_shared(dp_queue), min_available, min_free_space,
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);

/* return a pointer to allocated structure */
Expand Down
6 changes: 4 additions & 2 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ static int module_adapter_dp_queue_prepare(struct comp_dev *dev)
sink_get_min_free_space(audio_stream_get_sink(&source_buffer->stream));

/* create a shadow dp queue */
dp_queue = dp_queue_create(min_available, min_free_space, dp_mode);
dp_queue = dp_queue_create(min_available, min_free_space, dp_mode,
buf_get_id(source_buffer));

if (!dp_queue)
goto err;
Expand Down Expand Up @@ -224,7 +225,8 @@ static int module_adapter_dp_queue_prepare(struct comp_dev *dev)
sink_get_min_free_space(audio_stream_get_sink(&sink_buffer->stream));

/* create a shadow dp queue */
dp_queue = dp_queue_create(min_available, min_free_space, dp_mode);
dp_queue = dp_queue_create(min_available, min_free_space, dp_mode,
buf_get_id(sink_buffer));

if (!dp_queue)
goto err;
Expand Down
6 changes: 6 additions & 0 deletions src/audio/sink_api_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,9 @@ size_t sink_get_min_free_space(struct sof_sink *sink)
{
return sink->min_free_space;
}

uint32_t sink_get_id(struct sof_sink *sink)
{
return sink->audio_stream_params->id;
}

5 changes: 5 additions & 0 deletions src/audio/source_api_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,8 @@ size_t source_get_min_available(struct sof_source *source)
{
return source->min_available;
}

uint32_t source_get_id(struct sof_source *source)
{
return source->audio_stream_params->id;
}
5 changes: 4 additions & 1 deletion src/include/sof/audio/dp_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ struct dp_queue {
*
* @param flags a combinatin of DP_QUEUE_MODE_* flags determining working mode
*
* @param id a stream ID, accessible later by sink_get_id/source_get_id
*
*/
struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags);
struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags,
uint32_t id);

/**
* @brief remove the queue from the list, free dp queue memory
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/audio/sink_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ int sink_set_overrun(struct sof_sink *sink, bool overrun_permitted);
int sink_set_buffer_fmt(struct sof_sink *sink, uint32_t buffer_fmt);
void sink_set_min_free_space(struct sof_sink *sink, size_t min_free_space);
size_t sink_get_min_free_space(struct sof_sink *sink);
uint32_t sink_get_id(struct sof_sink *sink);

/**
* initial set of audio parameters, provided in sof_ipc_stream_params
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/audio/source_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ unsigned int source_get_rate(struct sof_source *source);
unsigned int source_get_channels(struct sof_source *source);
uint32_t source_get_buffer_fmt(struct sof_source *source);
bool source_get_underrun(struct sof_source *source);
uint32_t source_get_id(struct sof_source *source);

/** set of functions for setting audio parameters */
int source_set_frm_fmt(struct sof_source *source, enum sof_ipc_frame frm_fmt);
Expand Down

0 comments on commit c82226e

Please sign in to comment.