Skip to content

[RFC]selector: validate params in the params callback and fix prepare call… - #1070

Closed
ranj063 wants to merge 1 commit into
thesofproject:masterfrom
ranj063:fix/selector
Closed

ranj063 wants to merge 1 commit into
thesofproject:masterfrom
ranj063:fix/selector

Conversation

@ranj063

@ranj063 ranj063 commented Mar 2, 2019

Copy link
Copy Markdown
Collaborator

…back

This patch introduces 3 main changes to the selector comp:

  1. Use process ipc struct for selector
  2. Validate the selector params in the params callback. The source
    and sink channels can be obtained from the source/sink comp params
  3. Validate source/sink period bytes before resizing buffer in
    prepare().
  4. Also need clarification on how selected channel should be set.
    Does this come from the ipc struct or from a enum kcontrol?

Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com

…back

This patch introduces 3 main changes to the selector comp:
1. Use process ipc struct for selector
2. Validate the selector params in the params callback. The source
and sink channels can be obtained from the source/sink comp params
3. Validate source/sink period bytes before resizing buffer in
prepare().

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@ranj063
ranj063 requested a review from keyonjie March 2, 2019 03:48
Comment thread src/audio/selector.c
* FIXME: where should sel_channel come from?
* from a kcontrol or ipc params
*/
ret = sel_set_channel_values(cd, sourceb->source->params.channels,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Source/sink params (depends on pipe direction) won't be set at this point, so your code won't work correctly. Selector component should overwrite next components' params, so it needs those in/out channels count parameters.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@tlauda yes you are right about this. I think we should set this in prepare() instead of params. Then the source/sink params would already be set.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ranj063 Getting in/out channels based on the connected components is not a great idea. The purpose of the selector component is to force the change. Let's assume that we have playback pipeline and in the middle of the pipeline we have the component, which only requires 1 channel. We would put selector before that component to get that 1 channel, but how the selector would know that it should change the out channels? Params from the host would set the host format, so basically all the components would have e.g. 2 channels.
In the long term we should think about changing component API to have something like in and out format for every comp. With such API your change would be valid and expected.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@tlauda params from the host would change the channels but if a component knows it only needs 1 channel, it will ignore the channel from the host params and set it to 1 anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ranj063 Such component can support multiple formats and 1 channel on input can be just for specific topology. With your approach we transfer responsibility to that component instead of selector, which would require for that component to have additional custom field anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@tlauda what custom field would that be? Take the detect component for example, it knows that it only needs 1 channel. and the selector can use this information from the detect comp.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ranj063 I'm thinking more about generic case, where you have components, which can work for every channel configuration, but for specific topology they require specific channel number. One of the components in the topology needs to decide, that the channels number must be reduced.

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.

@ranj063 @tlauda Regarding component input parameters: one of the component design assumptions was that output channel ID (index) will be selected in the topology w/o requirement to have a dedicated app (the latter could be supported as an optional/ additional configuration channel)

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.

@ranj063 I'll second @tlauda statement that "In the long term we should think about changing component API to have something like in and out format for every comp" for every component in and out. A classic example is a preprocessing component with AEC that accepts on the 1st input 1-4 channels from mics and 2nd one 1-2 channels of reference signal from playback path. I assume that component can be compiled for platform specific configuration.

Comment thread src/audio/selector.c
* FIXME: where should sel_channel come from?
* from a kcontrol or ipc params
*/
ret = sel_set_channel_values(cd, sourceb->source->params.channels,

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.

@ranj063 @tlauda Regarding component input parameters: one of the component design assumptions was that output channel ID (index) will be selected in the topology w/o requirement to have a dedicated app (the latter could be supported as an optional/ additional configuration channel)

Comment thread src/audio/selector.c
* FIXME: where should sel_channel come from?
* from a kcontrol or ipc params
*/
ret = sel_set_channel_values(cd, sourceb->source->params.channels,

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.

@ranj063 I'll second @tlauda statement that "In the long term we should think about changing component API to have something like in and out format for every comp" for every component in and out. A classic example is a preprocessing component with AEC that accepts on the 1st input 1-4 channels from mics and 2nd one 1-2 channels of reference signal from playback path. I assume that component can be compiled for platform specific configuration.

@tlauda

tlauda commented Mar 7, 2019

Copy link
Copy Markdown
Contributor

@ranj063 Should we close this based on our discussions or maybe you'll just leave the comp_process changes and remove the rest?

@ranj063

ranj063 commented Mar 7, 2019

Copy link
Copy Markdown
Collaborator Author

@ranj063 Should we close this based on our discussions or maybe you'll just leave the comp_process changes and remove the rest?

@tlauda yes, I will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants