Skip to content

Commit

Permalink
sink/src: change IBS/OBS in API to more meaningful names
Browse files Browse the repository at this point in the history
there's a big confusion in naming: meaning IBS/OBS from
module point of view is opposite to meaning of OBS/IBS
from buffer or queue point of view

This PR changes
 - IBS to min_available
 - OBS to min_free_space

names like this are less likely to cause confusions

Signed-off-by: Marcin Szkudlinski <[email protected]>
  • Loading branch information
marcinszkudlinski authored and kv2019i committed Sep 26, 2023
1 parent 966ad48 commit 46a9d87
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 36 deletions.
15 changes: 8 additions & 7 deletions src/audio/dp_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ 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 ibs, size_t obs, uint32_t flags)
struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags)
{
struct dp_queue *dp_queue;

Expand All @@ -269,11 +269,11 @@ struct dp_queue *dp_queue_create(size_t ibs, size_t obs, uint32_t flags)
&dp_queue->audio_stream_params);

/* set obs/ibs in sink/source interfaces */
sink_set_obs(&dp_queue->_sink_api, obs);
source_set_ibs(&dp_queue->_source_api, ibs);
sink_set_min_free_space(&dp_queue->_sink_api, min_free_space);
source_set_min_available(&dp_queue->_source_api, min_available);

uint32_t max_ibs_obs = MAX(ibs, obs);
uint32_t min_ibs_obs = MIN(ibs, obs);
uint32_t max_ibs_obs = MAX(min_available, min_free_space);
uint32_t min_ibs_obs = MIN(min_available, min_free_space);

/* calculate required buffer size */
if (max_ibs_obs % min_ibs_obs == 0)
Expand All @@ -288,8 +288,9 @@ struct dp_queue *dp_queue_create(size_t ibs, size_t obs, uint32_t flags)
if (!dp_queue->_data_buffer)
goto err;

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

/* return a pointer to allocated structure */
return dp_queue;
Expand Down
8 changes: 4 additions & 4 deletions src/audio/sink_api_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ int sink_set_alignment_constants(struct sof_sink *sink,
return 0;
}

void sink_set_obs(struct sof_sink *sink, size_t obs)
void sink_set_min_free_space(struct sof_sink *sink, size_t min_free_space)
{
sink->obs = obs;
sink->min_free_space = min_free_space;
}

size_t sink_get_obs(struct sof_sink *sink)
size_t sink_get_min_free_space(struct sof_sink *sink)
{
return sink->obs;
return sink->min_free_space;
}
8 changes: 4 additions & 4 deletions src/audio/source_api_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ int source_set_alignment_constants(struct sof_source *source,
return 0;
}

void source_set_ibs(struct sof_source *source, size_t ibs)
void source_set_min_available(struct sof_source *source, size_t min_available)
{
source->ibs = ibs;
source->min_available = min_available;
}

size_t source_get_ibs(struct sof_source *source)
size_t source_get_min_available(struct sof_source *source)
{
return source->ibs;
return source->min_available;
}
12 changes: 5 additions & 7 deletions src/include/sof/audio/dp_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,16 @@ struct dp_queue {
};

/**
* @param ibs input buffer size
* the size of data to be produced in 1 cycle
* the data producer declares here how much data it will produce in single cycle
*
* @param obs output buffer size
* the size of data to be consumed in 1 cycle
* the data receiver declares here how much data it will consume in single cycle
* @param min_available minimum data available in queue required by the module using
* dp_queue's source api
* @param min_free_space minimum buffer space in queue required by the module using
* dp_queue's sink api
*
* @param flags a combinatin of DP_QUEUE_MODE_* flags determining working mode
*
*/
struct dp_queue *dp_queue_create(size_t ibs, size_t obs, uint32_t flags);
struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags);

/**
* @brief free dp queue memory
Expand Down
4 changes: 2 additions & 2 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ bool module_is_ready_to_process(struct processing_module *mod,
/* default action - the module is ready if there's enough data for processing and enough
* space to store result. IBS/OBS as declared in init_instance
*/
return (source_get_data_available(sources[0]) >= source_get_ibs(sources[0]) &&
sink_get_free_size(sinks[0]) >= sink_get_obs(sinks[0]));
return (source_get_data_available(sources[0]) >= source_get_min_available(sources[0]) &&
sink_get_free_size(sinks[0]) >= sink_get_min_free_space(sinks[0]));
}

int module_process_sink_src(struct processing_module *mod,
Expand Down
4 changes: 2 additions & 2 deletions src/include/sof/audio/sink_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ int sink_set_rate(struct sof_sink *sink, unsigned int rate);
int sink_set_channels(struct sof_sink *sink, unsigned int channels);
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_obs(struct sof_sink *sink, size_t obs);
size_t sink_get_obs(struct sof_sink *sink);
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);

/**
* initial set of audio parameters, provided in sof_ipc_stream_params
Expand Down
4 changes: 3 additions & 1 deletion src/include/sof/audio/sink_api_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ struct sof_sink {
const struct sink_ops *ops; /** operations interface */
size_t requested_write_frag_size; /** keeps number of bytes requested by get_buffer() */
size_t num_of_bytes_processed; /** processed bytes counter */
size_t obs; /** output buffer size as declared in module bind IPC */
size_t min_free_space; /** minimum buffer space required by the module using sink
* it is module's OBS as declared in module bind IPC
*/
struct sof_audio_stream_params *audio_stream_params; /** pointer to audio params */
};

Expand Down
4 changes: 2 additions & 2 deletions src/include/sof/audio/source_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ int source_set_rate(struct sof_source *source, unsigned int rate);
int source_set_channels(struct sof_source *source, unsigned int channels);
int source_set_underrun(struct sof_source *source, bool underrun_permitted);
int source_set_buffer_fmt(struct sof_source *source, uint32_t buffer_fmt);
void source_set_ibs(struct sof_source *source, size_t ibs);
size_t source_get_ibs(struct sof_source *source);
void source_set_min_available(struct sof_source *source, size_t min_available);
size_t source_get_min_available(struct sof_source *source);

/**
* initial set of audio parameters, provided in sof_ipc_stream_params
Expand Down
6 changes: 5 additions & 1 deletion src/include/sof/audio/source_api_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ struct sof_source {
const struct source_ops *ops;
size_t requested_read_frag_size; /** keeps size of data obtained by get_data() */
size_t num_of_bytes_processed; /** processed bytes counter */
size_t ibs; /** input buffer size as declared in module bind IPC */
size_t min_available; /** minimum data available required by the module using
* source
* it is module's IBS as declared in module bind IPC
*/

struct sof_audio_stream_params *audio_stream_params;
};

Expand Down
16 changes: 10 additions & 6 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,17 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
}

/*
* set ibs and obs in sink/src api of created buffer
* IBS of a buffer is OBS of source component
* OBS of a buffer is IBS of destination component
* set min_free_space and min_available in sink/src api of created buffer.
* buffer is connected like:
* source_module -> (sink_ifc) BUFFER (source_ifc) -> sink_module
*
* source_module needs to set its OBS (out buffer size)
* as min_free_space in buffer's sink ifc
* sink_module needs to set its IBS (input buffer size)
* as min_available in buffer's source ifc
*/

source_set_ibs(audio_stream_get_source(&buffer->stream), source_src_cfg.obs);
sink_set_obs(audio_stream_get_sink(&buffer->stream), sink_src_cfg.ibs);
sink_set_min_free_space(audio_stream_get_sink(&buffer->stream), source_src_cfg.obs);
source_set_min_available(audio_stream_get_source(&buffer->stream), sink_src_cfg.ibs);

/*
* Connect and bind the buffer to both source and sink components with the interrupts
Expand Down

0 comments on commit 46a9d87

Please sign in to comment.