-
Notifications
You must be signed in to change notification settings - Fork 351
audio: cadence: add optional API error reporting #10604
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -471,14 +471,32 @@ int cadence_codec_resolve_api_with_id(struct processing_module *mod, uint32_t co | |
| return 0; | ||
| } | ||
|
|
||
| int cadence_codec_process_data(struct processing_module *mod) | ||
| static void cadence_store_api_error_code(struct comp_dev *dev, | ||
| XA_ERRORCODE *api_error_code, | ||
| int ret, const char *cmd_name) | ||
| { | ||
| if (!api_error_code) | ||
| return; | ||
|
|
||
| if (*api_error_code && *api_error_code != ret) | ||
| comp_dbg(dev, "overwriting api error code at %s: old %#x new %#x", | ||
| cmd_name, *api_error_code, ret); | ||
|
|
||
| *api_error_code = ret; | ||
| } | ||
|
|
||
| int cadence_codec_process_data(struct processing_module *mod, | ||
| XA_ERRORCODE *api_error_code) | ||
| { | ||
| struct cadence_codec_data *cd = module_get_private_data(mod); | ||
| struct module_data *codec = &mod->priv; | ||
| struct comp_dev *dev = mod->dev; | ||
| uint32_t done = 0; | ||
| int ret; | ||
|
|
||
| if (api_error_code) | ||
| *api_error_code = 0; | ||
|
|
||
| if (codec->mpd.eos_reached) { | ||
| codec->mpd.produced = 0; | ||
| codec->mpd.consumed = 0; | ||
|
|
@@ -490,11 +508,13 @@ int cadence_codec_process_data(struct processing_module *mod) | |
| /* Signal that the stream is expected to end anytime soon */ | ||
| API_CALL(cd, XA_API_CMD_INPUT_OVER, 0, NULL, ret); | ||
| if (ret != LIB_NO_ERROR) { | ||
| if (api_error_code) | ||
| *api_error_code = ret; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, as this is the first call which can generate return code, it will not override previous code. |
||
|
|
||
| if (LIB_IS_FATAL_ERROR(ret)) { | ||
| comp_err(dev, "input_over failed with error: %x", ret); | ||
| return ret; | ||
| } | ||
| comp_warn(dev, "input_over failed with nonfatal error: %x", ret); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -506,20 +526,24 @@ int cadence_codec_process_data(struct processing_module *mod) | |
|
|
||
| API_CALL(cd, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_EXECUTE, NULL, ret); | ||
| if (ret != LIB_NO_ERROR) { | ||
| cadence_store_api_error_code(dev, api_error_code, ret, | ||
| "XA_API_CMD_EXECUTE_DO_EXECUTE"); | ||
|
|
||
| if (LIB_IS_FATAL_ERROR(ret)) { | ||
| comp_err(dev, "processing failed with error: %x", ret); | ||
| return ret; | ||
| } | ||
| comp_warn(dev, "processing failed with nonfatal error: %x", ret); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if we instead just simply change the level to DBG for the non fatal codes?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these codes are on the other hand are codec specific, the same reason code can mean completely different thing for mp3, ogg, flac, etc. Decoding is really not that simple. Or, keep the prints as comp_dbg() and still have the ability to return the reason code if the caller wants to handle non fatal?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets see how this works in practice, if we need more info we can add it later. |
||
| } | ||
|
|
||
| API_CALL(cd, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DONE_QUERY, &done, ret); | ||
| if (ret != LIB_NO_ERROR) { | ||
| cadence_store_api_error_code(dev, api_error_code, ret, | ||
| "XA_API_CMD_EXECUTE_DONE_QUERY"); | ||
|
|
||
| if (LIB_IS_FATAL_ERROR(ret)) { | ||
| comp_err(dev, "done query failed with error: %x", ret); | ||
| return ret; | ||
| } | ||
| comp_warn(dev, "done query failed with nonfatal error: %x", ret); | ||
| } | ||
|
|
||
| API_CALL(cd, XA_API_CMD_GET_OUTPUT_BYTES, 0, &codec->mpd.produced, ret); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comp_dbg()uses%#xto printintvalues (retand*api_error_code). In C this format expects anunsigned int, so this can trigger format warnings/UB for negative (high-bit-set) error codes. Consider casting tounsigned(or switching the stored type to an unsigned/UWORD32) when printing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, the cadence codebase and defines are sloppy, this is what it is.
The error is described as bits (bit 31 - fatal, bit 11-14 class, etc), but defined as int.