Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bumble/avdtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,7 @@ async def on_close_command(self) -> Message | None:

if self.rtp_channel is None:
# No channel to release, we're done
self.local_endpoint.in_use = 0
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.

It seems in_use is always used to determine whether configure is allowed for the stream endpoint, which is logically equal to stream.state == State.IDLE, since in the AVDTP spec, IDLE is the only state which allows setting configuration.

However, another fact is that we release streams very implicitly - only on another configuration procedure, and this requires in_use == 0.

I think we should have a more aligned and clear lifecycle for streams and local endpoints.

Maybe we can declare in_use as a property = self.stream is not None and self.stream.state == State.IDLE?

We may also clean up protocol.streams table when stream state transitted to IDLE.

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.

Another solution is just to remove in_use attribute and always consider streams in use, so we only need to properly remove them on release.

self.change_state(State.IDLE)
else:
# TODO: set a timer as we wait for the RTP channel to be closed
Expand All @@ -2050,6 +2051,7 @@ async def on_abort_command(self) -> Message | None:
await self.local_endpoint.on_abort_command()
if self.rtp_channel is None:
# No need to wait
self.local_endpoint.in_use = 0
self.change_state(State.IDLE)
else:
# Wait for the RTP channel to be closed
Expand Down
Loading