Skip to content

Pipeline2 0 - audio_buffer / sink / source api extensions and simplifications - #9594

Merged
lgirdwood merged 5 commits into
thesofproject:mainfrom
marcinszkudlinski:pipeline2_0_6
Nov 5, 2024
Merged

lgirdwood merged 5 commits into
thesofproject:mainfrom
marcinszkudlinski:pipeline2_0_6

Conversation

@marcinszkudlinski

@marcinszkudlinski marcinszkudlinski commented Oct 18, 2024 •

Copy link
Copy Markdown
Contributor

There are 3 APIs each buffer must implement (Sink/src/audio_buffer) - for data producers/consumers/maintenance

each of them need to have methods doing same operations - like settings stream parameters

this PR adds methods to audio_buffer API allowing access to stream parameters
It also introduces a simplification: in case of sink/src API provided by buffers the following methods:

  • on_audio_format_set
  • audio_set_ipc_params
  • set_alignment_constants

need to be implement only once (not for sink/sourcer/audio_buffer API separately). Proper implementation will be called by a default wrappers

(how do I miss C++, such things are sooooooo natural there, in C there's a need for sophisticated tricks like this PR)

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. Some minors notes inline, but nothing blocking the series.

Comment thread src/audio/buffers/ring_buffer.c Resolved
Comment thread src/audio/buffers/audio_buffer.c Resolved
Comment thread src/audio/pipeline/pipeline-graph.c Resolved
Comment thread src/audio/buffers/comp_buffer.c Resolved
Comment thread src/audio/buffers/comp_buffer.c Resolved
Comment thread src/audio/buffers/comp_buffer.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why is buffer data cleaning needed? Is this for silence generation? Not sure if this can be of importance for security / privacy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in fact I don't know. Privacy, maybe silence generation?
Just wanted the changes to be 100% transparent and buffer cleaning was in the code

Comment thread src/audio/buffers/comp_buffer.c Resolved
sof_audo_buffer_from_* => sof_audio_buffer_from_*

Signed-off-by: Marcin Szkudlinski <[email protected]>
clean method does clean all buffer data
leaving config as is
Need to be implemented as virtual method
as is implemented difrently in each buffer type

Signed-off-by: Marcin Szkudlinski <[email protected]>
There are 3 APIs each buffer must implement (Sink/src/audio_buffer)
for data producers/consumers/maintenance
each of them need to have methods doing same operations - like settings
stream parameters

this commit provides simplification for buffer implementation -
it is enough to implement those methods for audio_buffer API, default
handlers for sink/src will propagate calls accordingly

Specific handlers for sink and source may still be provided
i.e. in case when sink or source API is not provided by a buffer
but some other data producer (i.e. DAI)

Also a default implementation of .audio_set_ipc_params is provided,
that probably will fit needs of all buffers' implementation,
except of currently used legacy comp_buffer

Signed-off-by: Marcin Szkudlinski <[email protected]>
This commit modifies both existing buffers implementations
to use simplified API for sink/source/audio_buffer

Signed-off-by: Marcin Szkudlinski <[email protected]>
All control structures of buffers shared between cores
are now stored in a non-cached memory alias.
Cache writeback is no longer needed here

Signed-off-by: Marcin Szkudlinski <[email protected]>
@kv2019i

kv2019i commented Oct 29, 2024

Copy link
Copy Markdown
Collaborator

@marcinszkudlinski is this version good to go or do you have a new coming coming? I see you marked some of my (minor) comments resolved but did not update the PR.
@lyakh @lgirdwood good to go?

As per other review, I see no showstoppers here and we could proceed and merge this.

@lgirdwood

Copy link
Copy Markdown
Member

@marcinszkudlinski is this version good to go or do you have a new coming coming? I see you marked some of my (minor) comments resolved but did not update the PR. @lyakh @lgirdwood good to go?

As per other review, I see no showstoppers here and we could proceed and merge this.

Just need the simplification for reset().

@lyakh

lyakh commented Oct 30, 2024

Copy link
Copy Markdown
Collaborator

@lyakh @lgirdwood good to go?

@kv2019i @marcinszkudlinski in fact I'd have one request: I understand that this is a step on the way to a new API, right? But do you have a full set ready yet - at least as a draft? FWIW I usually cannot just design a project and then work on polishing its parts before I have the whole thing together and working in some draft form. So maybe you have the whole series somewhere or maybe you could upload it for reference - as a draft PR?

@marcinszkudlinski

Copy link
Copy Markdown
Contributor Author

I don't have a draft with changes.
What I'm doing is mostly described here:

https://marcinszkudlinski.github.io/sof-docs/PAGES/architectures/firmware/sof-common/pipeline_2_0/pipeline2_0_discussion.html

With closest short-term target: allow using ring_buffer directly, not as a hybrid with comp_buffer, which I hope will be ready in next PR.

Second goal: allow to connect modules directly, without buffers in the middle (as described above, for all modules with internal buffers like DAI and couple of others). I'll put a low level design of this in the document above shortly.

And - I don't really know what else need to be in audio_buffer API. Unfortunately we use C - there's no way to make effective encapsulation of internal data, enforcing of API usage (by putting structures in .c file and make non-inline API functions) is less important that optimalization etc. As a result currently a lot of operations are performed directly on data structures by everybody and everywhere, which is hard to track/find. So I'm making changes step by step, with API growing. This may require sometimes a step back, optimalizations, modifications etc. - as in this PR

@marcinszkudlinski

Copy link
Copy Markdown
Contributor Author

@kv2019i my final version

@marcinszkudlinski

Copy link
Copy Markdown
Contributor Author

@kv2019i @lgirdwood - can we proceed?

@lgirdwood
lgirdwood merged commit 06c9d7e into thesofproject:main Nov 5, 2024
@marcinszkudlinski
marcinszkudlinski deleted the pipeline2_0_6 branch November 5, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants