Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waves: store config blob in a cache in waves.c #8448

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

barry-waves
Copy link
Contributor

Store/apply config blob in a cache to avoid that
cfg.data will be released after prepare.

ret);
module_free_memory(mod, waves_codec->config_blob);
waves_codec->config_blob_size = 0;
return ret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace line 497 with
ret = -ENOMEM;

this can:

  1. keep same with if part.
  2. one return in line 502 is enough for this case.


if (waves_codec->config_blob) {
ret = waves_effect_message(mod, waves_codec->config_blob,
waves_codec->config_blob_size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 734 should align with line 733

src/audio/module_adapter/module/waves/waves.c Outdated Show resolved Hide resolved
@barry-waves barry-waves force-pushed the main branch 2 times, most recently from 10f7210 to 739a583 Compare November 7, 2023 06:18
comp_err(dev,
"waves_effect_cache_config_blob() failed to allocate %d bytes for config blob",
size);
ret = -ENOMEM;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just do return -ENOMEM here (and below) and also avoid a done debug print in an error case, remove the ret variable

}
}
comp_dbg(dev, "waves_effect_cache_config_blob() done");
return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and just return 0 here

comp_dbg(dev, "waves_effect_apply_config_blob_cache()");

if (waves_codec->config_blob) {
ret = waves_effect_message(mod, waves_codec->config_blob,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return waves_effect_message(...) here and return 0 below

src/audio/module_adapter/module/waves/waves.c Show resolved Hide resolved
"waves_effect_cache_config_blob(): failed to copy config blob %d",
ret);
module_free_memory(mod, waves_codec->config_blob);
waves_codec->config_blob_size = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waves_codec->config_blob = NULL; accordingly

@@ -492,6 +536,16 @@ static int waves_effect_message(struct processing_module *mod, void *data, uint3
return 0;
}

static int waves_handle_param_message(struct processing_module *mod, void *data, uint32_t size)
{
int ret = waves_effect_message(mod, data, size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not

int ret = waves_effect_cache_config_blob(mod, data, size);
if (!ret)
    ret = waves_effect_message_from_cache(mod);

or even clearer, decouple these two actions:

  • when apply_config() is called which means the external config is ready --> call waves_effect_cache_config_blob() to store into cache
  • when prepare() is called --> call waves_effect_message_from_cache() to load config blob from cache and set into module

(Note we don't always set config from external every time before prepare)

May need to consider if it is possible that the external config comes latter than prepare? The same for the current design as well (it seems to early return with error if config comes late for the current design, which can be acceptable by the cases we have now in reality) It is always the best practice that takes the above question into account.

@@ -659,6 +717,22 @@ static int waves_codec_init(struct processing_module *mod)
return ret;
}

/* apply config blob */
static int waves_effect_apply_config_blob_cache(struct processing_module *mod)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I beg to state that the commit complicates the design. After that there will be both waves_effect_apply_config() and waves_effect_apply_config_cache(). Moreover, waves_effect_config(), waves_effect_cache_config(), and waves_effect_message().

(Please correct me if there is devil in the details.) I do believe the logic is fair enough as I mentioned in the former comment. That is, two reaction chain in total which can be triggered from external:

  1. set config blob from external:
(...) -> waves_codec_set_configuration() -> waves_effect_apply_config() -> waves_effect_config_save_to_cache()
  1. start module (trigger prepare) from external:
(...) -> waves_codec_prepare() -> waves_effect_config_load_from_cache()

then handle what if...

  • cache is empty when calling waves_effect_config_load_from_cache()?
  • module is processing when calling waves_effect_config_save_to_cache()?

@@ -41,7 +41,9 @@ struct waves_codec_data {
uint32_t response_max_bytes;
uint32_t request_max_bytes;
void *response;
struct module_config setup_cfg;
struct module_config setup_cfg;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel certain that setup_cfg is no longer used

if (ret)
comp_err(dev, "waves_codec_prepare() failed %d", ret);
goto error;

comp_dbg(dev, "waves_codec_prepare() done");
return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be return 0 now

Store/apply config blob in a cache to avoid that
cfg.data will be released after prepare.

Signed-off-by: barry.jan <[email protected]>
@lgirdwood
Copy link
Member

@johnylin76 are all review comments aligned with the latest update ?

@johnylin76
Copy link
Contributor

@johnylin76 are all review comments aligned with the latest update ?

Yes. Thanks

@kv2019i
Copy link
Collaborator

kv2019i commented Nov 27, 2023

Seems ready to go, let me kick the SOF CI once more to get a clean CI sheet.

@kv2019i
Copy link
Collaborator

kv2019i commented Nov 27, 2023

SOFCI TEST

@kv2019i kv2019i merged commit 3917308 into thesofproject:main Nov 27, 2023
42 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants