From cb170d1abe3a6dff6f879fa292a57e0e60121ab4 Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Thu, 2 Nov 2023 15:34:25 +0100 Subject: [PATCH] sink/src: add ID to sink/src API add get buffer ID to sink/src api Signed-off-by: Marcin Szkudlinski --- src/audio/dp_queue.c | 8 +++++--- src/audio/module_adapter/module_adapter.c | 6 ++++-- src/audio/sink_api_helper.c | 6 ++++++ src/audio/source_api_helper.c | 5 +++++ src/include/sof/audio/dp_queue.h | 5 ++++- src/include/sof/audio/sink_api.h | 1 + src/include/sof/audio/source_api.h | 1 + 7 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/audio/dp_queue.c b/src/audio/dp_queue.c index 8001594a27bc..a201dde82130 100644 --- a/src/audio/dp_queue.c +++ b/src/audio/dp_queue.c @@ -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; @@ -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 */ diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index f4b77d2fc168..fcea9cfaa7dc 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -189,7 +189,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; @@ -223,7 +224,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; diff --git a/src/audio/sink_api_helper.c b/src/audio/sink_api_helper.c index 46ffbfd6b860..9961ee61dcb8 100644 --- a/src/audio/sink_api_helper.c +++ b/src/audio/sink_api_helper.c @@ -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; +} + diff --git a/src/audio/source_api_helper.c b/src/audio/source_api_helper.c index 69c76a28335d..f1aec4924f9b 100644 --- a/src/audio/source_api_helper.c +++ b/src/audio/source_api_helper.c @@ -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; +} diff --git a/src/include/sof/audio/dp_queue.h b/src/include/sof/audio/dp_queue.h index b187eb7a6f86..1c699f11e273 100644 --- a/src/include/sof/audio/dp_queue.h +++ b/src/include/sof/audio/dp_queue.h @@ -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 diff --git a/src/include/sof/audio/sink_api.h b/src/include/sof/audio/sink_api.h index bb279166c167..e9c1fa7e2d80 100644 --- a/src/include/sof/audio/sink_api.h +++ b/src/include/sof/audio/sink_api.h @@ -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 diff --git a/src/include/sof/audio/source_api.h b/src/include/sof/audio/source_api.h index 36282e761f94..de224f4bc51a 100644 --- a/src/include/sof/audio/source_api.h +++ b/src/include/sof/audio/source_api.h @@ -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);