-
Notifications
You must be signed in to change notification settings - Fork 349
pipeline: eos: Add support for End Of Stream state #10143
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
Conversation
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.
Pull Request Overview
This PR adds comprehensive End of Stream (EOS) support to the audio pipeline system. It introduces a new pipeline state to handle end-of-stream scenarios and replaces a simple boolean flag with a state machine for tracking audio stream lifecycle.
- Adds EOS state management to pipelines with
expect_eosflag and state validation - Replaces
hw_params_configuredboolean withsof_audio_stream_stateenum for better stream lifecycle tracking - Implements EOS detection and handling across host, component processing, and mixin modules
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ipc/ipc4/handler.c | Adds EOS pipeline state handling and validation logic |
| src/include/sof/audio/pipeline.h | Adds expect_eos boolean flag to pipeline structure |
| src/include/sof/audio/audio_buffer.h | Replaces hw_params_configured with state-based API functions |
| src/include/module/audio/source_api.h | Adds state getter function for source streams |
| src/include/module/audio/audio_stream.h | Defines new stream state enum replacing boolean flag |
| src/audio/mixin_mixout/mixin_mixout.c | Implements EOS notification handling with delay calculation |
| src/audio/host-zephyr.c | Adds EOS detection when host runs out of available data |
| src/audio/component.c | Implements EOS propagation and silence generation for DP modules |
kv2019i
left a comment
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.
@softwarecki I'm perhaps something in the big picture, but does a pipe end in end-of-stream state? It would the code is adding EOS support but nothing in current PR seems to be actually deciding when EOS has been reached. Or did I miss it? I'd expect if we have e.g. a compressed format decoder as a module, it would know when data ends and signal EOS, but how does a component signal EOS? Is lack of data from host considered EOS (or underrun)?
|
@kv2019i |
Thanks @softwarecki - just some quick questions:
|
|
Thanks @softwarecki , I didn't understand at first this extends SET_STATE to communicate EndOfStream. I think for many (most?) Linux usages, we can use delay reporting (snd_pcm_delay()) to estimate how long it takes to play out submitted PCM samples and application can send out zeroes until it knows all samples are played out (e.g. to ensure desktop/UI sounds are played out completely). E.g. with audio servers this won't be needed as they use a inactivity timer before they close off the PCM (after last application stream has closed). In cases where app is directly using native ALSA HW devices, this could be used to implement a more reliable snd_pcm_drain(), especially when used with SOF PCMs that are connected to DSP pipeline with large internal buffers (like the deep buffer one). Our current implementation just flushes the driver visible ALSA buffer, but we don't have functionality to flush out the audio data in DSP SRAM buffers (as this hasn't really been an issue when audio servers are used). |
0213889 to
4271463
Compare
lgirdwood
left a comment
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.
I think code is fine, for me we just have some readability and need to clarify the status enum (since this is the 3rd status enum).
222c720 to
1d1f82d
Compare
kv2019i
left a comment
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.
One minor note on "inline" usage, but no blockers.
src/audio/component.c
Outdated
| } | ||
| } | ||
|
|
||
| static inline bool comp_check_eos(struct comp_dev *dev) |
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.
Btw why explicit "inline"? This seems like a really long function to inline and unless data pointing otherwise, I'd let the compiler choose.
lgirdwood
left a comment
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.
LGTM - just one open on the inline function and I think good to merge.
|
@softwarecki can you check CI, could be an issue. Thanks ! |
e24231d to
c955a22
Compare
Include two required source files for sink/source api. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Move the check of the ret variable value after the switch to simplify the code. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add support for setting the pipeline in the EOS state. Setting this state sets the except_eos flag in the pipeline, indicating that the end of data to be processed is expected. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add enum describing the state of a audio stream. Change the hw_params_configured field to state. A stream is initially in the STREAM_STATE_INITIAL state. After configuring the parameters, it transitions to the STREAM_STATE_READY state. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add new STREAM_STATE_END_OF_STREAM state indicating the end of a stream. Additional state STREAM_STATE_END_OF_STREAM_FLUSH indicates that end of stream has been detected, but silence is transmitted for the needs of DP modules. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add end of stream support to the host. When the pipeline is in the eos state and host runs out of available data, set the sink to the eos state. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add eos support in the function that calls the module's data processing function. If the end of the stream in the source buffer is detected, pass it to the output buffer. For DP modules, generate silence on the input after end of the stream to allow them to process the remaining data. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add sending notification when end of stream is detected. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
|
Only known errors in CI, proceeding with merge. |
Add support for setting the pipeline in the EOS state. Setting this state sets the
except_eosflag in the pipeline, indicating that the end of data to be processed is expected.Add enum describing the state of a audio stream. Change the
hw_params_configuredfield to state. A stream is initially in theSTREAM_STATE_INITIALstate. After configuring the parameters, it transitions to theSTREAM_STATE_READYstate.Add new
STREAM_STATE_END_OF_STREAMstate indicating the end of a stream. Additional stateSTREAM_STATE_END_OF_STREAM_FLUSHindicates that end of stream has been detected, but silence is transmitted for the needs of DP modules.Add end of stream support to the host. When the pipeline is in the eos state and host runs out of available data, set the sink to the eos state.
Add eos support in the function that calls the module's data processing function. If the end of the stream in the source buffer is detected, pass it to the output buffer. For DP modules, generate silence on the input after end of the stream to allow them to process the remaining data.
Add support in mixin module to sending notification when end of stream is detected.