Skip to content

Commit 48edc76

Browse files
ujfalusilgirdwood
authored andcommitted
module: cadence: Implement complete process flow with INPUT_OVER+QUERY_DONE
The full processing command flow should start with the INPUT_OVER command when EOS is expected and after the DO_EXECUTE the DONE needs to be checked to see if the decoding has completed. This does not work in the AAC library for some reason, but it will produce one empty frame at the end of the stream, which we can use to detect EOS completion. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent e7c4d21 commit 48edc76

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/audio/module_adapter/module/cadence.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ int cadence_codec_process_data(struct processing_module *mod)
476476
struct cadence_codec_data *cd = module_get_private_data(mod);
477477
struct module_data *codec = &mod->priv;
478478
struct comp_dev *dev = mod->dev;
479+
uint32_t done = 0;
479480
int ret;
480481

481482
if (codec->mpd.eos_reached) {
@@ -485,6 +486,18 @@ int cadence_codec_process_data(struct processing_module *mod)
485486
return 0;
486487
}
487488

489+
if (dev->pipeline->expect_eos) {
490+
/* Signal that the stream is expected to end anytime soon */
491+
API_CALL(cd, XA_API_CMD_INPUT_OVER, 0, NULL, ret);
492+
if (ret != LIB_NO_ERROR) {
493+
if (LIB_IS_FATAL_ERROR(ret)) {
494+
comp_err(dev, "input_over failed with error: %x", ret);
495+
return ret;
496+
}
497+
comp_warn(dev, "input_over failed with nonfatal error: %x", ret);
498+
}
499+
}
500+
488501
API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->mpd.avail, ret);
489502
if (ret != LIB_NO_ERROR) {
490503
comp_err(dev, "failed to set size of input data with error: %x:", ret);
@@ -500,6 +513,15 @@ int cadence_codec_process_data(struct processing_module *mod)
500513
comp_warn(dev, "processing failed with nonfatal error: %x", ret);
501514
}
502515

516+
API_CALL(cd, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DONE_QUERY, &done, ret);
517+
if (ret != LIB_NO_ERROR) {
518+
if (LIB_IS_FATAL_ERROR(ret)) {
519+
comp_err(dev, "done query failed with error: %x", ret);
520+
return ret;
521+
}
522+
comp_warn(dev, "done query failed with nonfatal error: %x", ret);
523+
}
524+
503525
API_CALL(cd, XA_API_CMD_GET_OUTPUT_BYTES, 0, &codec->mpd.produced, ret);
504526
if (ret != LIB_NO_ERROR) {
505527
comp_err(dev, "could not get produced bytes, error %x:",
@@ -513,8 +535,17 @@ int cadence_codec_process_data(struct processing_module *mod)
513535
return ret;
514536
}
515537

516-
if (!codec->mpd.produced && dev->pipeline->expect_eos)
517-
codec->mpd.eos_reached = true;
538+
if (dev->pipeline->expect_eos) {
539+
/*
540+
* AAC decoder cannot signal DONE, check if it stopped
541+
* producing data when EOS is expected
542+
*/
543+
if (cd->api_id == CADENCE_CODEC_AAC_DEC_ID && !codec->mpd.produced)
544+
done = true;
545+
546+
if (done)
547+
codec->mpd.eos_reached = true;
548+
}
518549

519550
return 0;
520551
}

0 commit comments

Comments
 (0)