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

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

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

marcinszkudlinski
Copy link
Contributor

@marcinszkudlinski marcinszkudlinski commented Oct 18, 2024

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)

Copy link
Collaborator

@kv2019i kv2019i left a comment

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.

src/audio/buffers/ring_buffer.c Show resolved Hide resolved
src/audio/buffers/audio_buffer.c Show resolved Hide resolved
src/audio/pipeline/pipeline-graph.c Show resolved Hide resolved
src/audio/buffers/comp_buffer.c Outdated Show resolved Hide resolved
src/audio/buffers/comp_buffer.c Show resolved Hide resolved
@@ -152,6 +152,19 @@ static int comp_buffer_sink_set_alignment_constants(struct sof_sink *sink,
return 0;
}

static void comp_buffer_clean(struct sof_audio_buffer *audio_buffer)
Copy link
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
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

src/audio/buffers/comp_buffer.c Outdated Show resolved Hide resolved
sof_audo_buffer_from_* => sof_audio_buffer_from_*

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
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 <marcin.szkudlinski@intel.com>
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 <marcin.szkudlinski@intel.com>
This commit modifies both existing buffers implementations
to use simplified API for sink/source/audio_buffer

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
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 <marcin.szkudlinski@intel.com>
@kv2019i
Copy link
Collaborator

kv2019i commented Oct 29, 2024

@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
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
Copy link
Collaborator

lyakh commented Oct 30, 2024

@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
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
Contributor Author

@kv2019i my final version

@marcinszkudlinski
Copy link
Contributor Author

@kv2019i @lgirdwood - can we proceed?

@lgirdwood lgirdwood merged commit 06c9d7e into thesofproject:main Nov 5, 2024
44 of 47 checks passed
@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