diff --git a/apps/auracast.py b/apps/auracast.py index 42c1cab..739d7f1 100644 --- a/apps/auracast.py +++ b/apps/auracast.py @@ -1,4 +1,4 @@ -# Copyright 2024 Google LLC +# Copyright 2025 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -826,7 +826,7 @@ async def run_broadcast( ) print('Setup ISO Data Path') - def on_drain(packet_queue): + def on_flow(packet_queue): print( f'\rPACKETS: pending={packet_queue.pending}, ' f'queued={packet_queue.queued}, completed={packet_queue.completed}', @@ -842,7 +842,7 @@ async def run_broadcast( packet_queue = bis_link.data_packet_queue if packet_queue: - packet_queue.on('drain', lambda: on_drain(packet_queue)) + packet_queue.on('flow', lambda: on_flow(packet_queue)) for frame in itertools.cycle(frames): mid = len(frame) // 2 diff --git a/bumble/host.py b/bumble/host.py index 48c03e0..4511d78 100644 --- a/bumble/host.py +++ b/bumble/host.py @@ -1,4 +1,4 @@ -# Copyright 2021-2022 Google LLC +# Copyright 2021-2025 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ class DataPacketQueue(pyee.EventEmitter): but not completed yet. Packets are no longer "in flight" when the controller declares them as completed. - The queue emits a 'drain' event whenever one or more packets are completed. + The queue emits a 'flow' event whenever one or more packets are completed. """ max_packet_size: int @@ -126,7 +126,7 @@ class DataPacketQueue(pyee.EventEmitter): Remove all packets associated with a connection. All packets associated with the connection that are in flight are implicitly - marked as completed, but no 'drain' event is emitted. + marked as completed, but no 'flow' event is emitted. """ packets_to_keep = [ @@ -180,7 +180,7 @@ class DataPacketQueue(pyee.EventEmitter): self._completed = self._queued self._check_queue() - self.emit('drain') + self.emit('flow') # ----------------------------------------------------------------------------- @@ -920,23 +920,9 @@ class Host(AbortableEventEmitter): for connection_handle, num_completed_packets in zip( event.connection_handles, event.num_completed_packets ): - if connection := self.connections.get(connection_handle): - connection.acl_packet_queue.on_packets_completed( - num_completed_packets, connection_handle - ) - return - - if cis_link := self.cis_links.get(connection_handle): - cis_link.packet_queue.on_packets_completed( - num_completed_packets, connection_handle - ) - return - - if bis_link := self.bis_links.get(connection_handle): - bis_link.packet_queue.on_packets_completed( - num_completed_packets, connection_handle - ) - return + if queue := self.get_data_packet_queue(connection_handle): + queue.on_packets_completed(num_completed_packets, connection_handle) + continue if connection_handle not in self.sco_links: logger.warning( diff --git a/tests/host_test.py b/tests/host_test.py index 5789b5e..ac3af9d 100644 --- a/tests/host_test.py +++ b/tests/host_test.py @@ -138,15 +138,15 @@ def test_data_packet_queue(): assert queue.completed == 11 drain_listener = unittest.mock.Mock() - queue.on('drain', drain_listener.on_drain) + queue.on('flow', drain_listener.on_flow) queue.enqueue(packet, 123) - assert drain_listener.on_drain.call_count == 0 + assert drain_listener.on_flow.call_count == 0 queue.on_packets_completed(1, 123) - assert drain_listener.on_drain.call_count == 1 + assert drain_listener.on_flow.call_count == 1 queue.enqueue(packet, 123) queue.enqueue(packet, 123) queue.enqueue(packet, 123) queue.flush(123) - assert drain_listener.on_drain.call_count == 1 + assert drain_listener.on_flow.call_count == 1 assert queue.queued == 15 assert queue.completed == 15