Skip to content

Commit

Permalink
MDRC: Enhance Initialization of multiband_drc_init
Browse files Browse the repository at this point in the history
- Improved documentation for the multiband_drc_init function,
  specifying its purpose, parameters, and initialization steps.
- Clearly defined all initialization steps, including memory
  allocations and configuration checks.
- Enhanced error handling with detailed log messages for each failure
  scenario.
- Added comments to improve code readability and maintainability,
  ensuring future developers can easily understand the initialization
  process.

Signed-off-by: Shriram Shastry <[email protected]>
  • Loading branch information
ShriramShastry committed Aug 18, 2024
1 parent aa39e1e commit 9794ea6
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,21 @@ static int multiband_drc_setup(struct processing_module *mod, int16_t channels,
* End of Multiband DRC setup code. Next the standard component methods.
*/

/**
* @brief Initialize Multiband Dynamic Range Control (DRC) component.
*
* Allocates and initializes memory for the multiband DRC component data, including
* state structure, coefficient blocks, and module interface.
*
* The function checks and ensures that the provided configuration blob size is
* within expected limits. If successful, the component state is reset and multiband
* DRC processing is enabled by default.
*
* @param[in] mod Pointer to the processing module to be initialized.
*
* @return 0 on success, -EINVAL if configuration blob size is too large,
* -ENOMEM if memory allocation fails for component data.
*/
static int multiband_drc_init(struct processing_module *mod)
{
struct module_data *md = &mod->priv;
Expand Down Expand Up @@ -351,12 +366,6 @@ static int multiband_drc_init(struct processing_module *mod)
md->private = cd;
cd->multiband_drc_func = NULL;
cd->crossover_split = NULL;
/* Initialize to enabled is a workaround for IPC4 kernel version 6.6 and
* before where the processing is never enabled via switch control. New
* kernel sends the IPC4 switch control and sets this to desired state
* before prepare.
*/
multiband_drc_process_enable(&cd->process_enabled);

/* Handler for configuration data */
cd->model_handler = comp_data_blob_handler_new(dev);
Expand All @@ -370,14 +379,21 @@ static int multiband_drc_init(struct processing_module *mod)
ret = comp_init_data_blob(cd->model_handler, bs, cfg->data);
if (ret < 0) {
comp_err(dev, "multiband_drc_init(): comp_init_data_blob() failed.");
goto cd_fail;
goto cd_model_fail;
}
multiband_drc_reset_state(&cd->state);

/* Initialize to enabled is a workaround for IPC4 kernel version 6.6 and
* before where the processing is never enabled via switch control. New
* kernel sends the IPC4 switch control and sets this to desired state
* before prepare.
*/
multiband_drc_process_enable(&cd->process_enabled);
return 0;

cd_fail:
cd_model_fail:
comp_data_blob_handler_free(cd->model_handler);
cd_fail:
rfree(cd);
return ret;
}
Expand Down

0 comments on commit 9794ea6

Please sign in to comment.