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

Bluetooth: CAP: Add support for doing just disable for unicast stop #74187

Merged

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Jun 12, 2024

The unicast_stop function is changed to primarily do a
BAP disable instead of a release, with optional
support for releasing the streams once they have been disabled.

fixes #70818

@Thalley Thalley force-pushed the cap_initiator_unicast_stop_update branch 9 times, most recently from 20bfc6f to 13ff2c6 Compare June 18, 2024 08:48
@Thalley Thalley added this to the v4.0.0 milestone Jun 27, 2024
@Thalley Thalley force-pushed the cap_initiator_unicast_stop_update branch from 13ff2c6 to bcbb88d Compare July 15, 2024 13:59
@Thalley Thalley force-pushed the cap_initiator_unicast_stop_update branch from bcbb88d to 6b14334 Compare July 30, 2024 17:51
@Thalley Thalley force-pushed the cap_initiator_unicast_stop_update branch 2 times, most recently from 11939f8 to 01b5556 Compare September 2, 2024 08:54
@Thalley Thalley force-pushed the cap_initiator_unicast_stop_update branch from 01b5556 to 4904b5c Compare September 5, 2024 13:49
@Thalley Thalley marked this pull request as ready for review September 5, 2024 13:49
@zephyrbot zephyrbot added area: Bluetooth area: Bluetooth Qualification Bluetooth Qualification -related issues and pull requests area: Bluetooth Audio labels Sep 5, 2024
}
}

if (!can_disable && !can_stop && !can_release) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does -EALREADY make sense here?

The GNU spec. states it as:
'EALREADY
The socket socket is non-blocking and already has a pending connection in progress (see EINPROGRESS above).'

And while its true that we "already has a pending connection in progress", I think the intent of the wording is when we try to connect a new one.

Could EBUSY make more sense here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The case is here is that all streams are already stopped, and thus -EBUSY doesn't make any sense.

The alternative is that we return 0, but then it's hard for an application to determine whether a request was successfully sent, or if nothing was done.

We need a way to tell the caller that no request was sent because it would not result in any state changes

Copy link
Contributor

@fredrikdanebjer fredrikdanebjer Sep 18, 2024

Choose a reason for hiding this comment

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

I guess this make sense. In regardless, I certainly think 0 would be wrong here :D

@Thalley Thalley force-pushed the cap_initiator_unicast_stop_update branch from ca8f521 to 83a839f Compare September 23, 2024 08:46
subsys/bluetooth/audio/cap_initiator.c Outdated Show resolved Hide resolved
subsys/bluetooth/audio/cap_initiator.c Outdated Show resolved Hide resolved
The unicast_stop function is changed to primarily do a
BAP disable instead of a release, with optional
support for releasing the streams once they have been disabled.

This also adds unittests for the procedure which also
allow us to remove the invalid param testing from the BSIM tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>

bt_cap_common_start_proc(BT_CAP_COMMON_PROC_TYPE_STOP, param->count);
if (!can_disable && can_disable_stream(bap_stream)) {
Copy link
Collaborator

@kruithofa kruithofa Sep 24, 2024

Choose a reason for hiding this comment

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

Somehow missing the link to my original comment. Anyway good point that this is in a loop.
It still could be rewritten as

can_disable = can_disable || can_disable_stream(bap_stream);

which still would do the short circuiting, but I am not sure if that's more readable than what you have now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I think the current version is more explicit. Not sure if there's any performance changes between the two, but I think can_disable = can_disable || can_disable_stream(bap_stream) might be worth as it always does 1 assign and 1 compare, whereas the current version always do 1 comparison and optionally an assign.

@Thalley Thalley added the DNM This PR should not be merged (Do Not Merge) label Sep 26, 2024
@Thalley
Copy link
Collaborator Author

Thalley commented Sep 26, 2024

Investigating a possible issue

@Thalley Thalley removed the DNM This PR should not be merged (Do Not Merge) label Sep 26, 2024
@Thalley
Copy link
Collaborator Author

Thalley commented Sep 26, 2024

Investigating a possible issue

There is indeed an issue, but it's not caused by this PR nor easily fixable by this PR, and will be fixed in #79014

@Thalley Thalley assigned Thalley and unassigned sjanc Sep 30, 2024
@aescolar aescolar merged commit fa4f2ff into zephyrproject-rtos:main Oct 1, 2024
28 of 29 checks passed
@Thalley Thalley deleted the cap_initiator_unicast_stop_update branch October 1, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Audio area: Bluetooth Qualification Bluetooth Qualification -related issues and pull requests area: Bluetooth
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

LE Audio: Invalid behavior bt_cap_initiator_unicast_audio_stop for some remote devices
6 participants