forked from auracaster/bumble_mirror
rename drain event to flow
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2024 Google LLC
|
# Copyright 2025 Google LLC
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with 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')
|
print('Setup ISO Data Path')
|
||||||
|
|
||||||
def on_drain(packet_queue):
|
def on_flow(packet_queue):
|
||||||
print(
|
print(
|
||||||
f'\rPACKETS: pending={packet_queue.pending}, '
|
f'\rPACKETS: pending={packet_queue.pending}, '
|
||||||
f'queued={packet_queue.queued}, completed={packet_queue.completed}',
|
f'queued={packet_queue.queued}, completed={packet_queue.completed}',
|
||||||
@@ -842,7 +842,7 @@ async def run_broadcast(
|
|||||||
packet_queue = bis_link.data_packet_queue
|
packet_queue = bis_link.data_packet_queue
|
||||||
|
|
||||||
if 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):
|
for frame in itertools.cycle(frames):
|
||||||
mid = len(frame) // 2
|
mid = len(frame) // 2
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2021-2022 Google LLC
|
# Copyright 2021-2025 Google LLC
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with 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
|
but not completed yet. Packets are no longer "in flight" when the controller
|
||||||
declares them as completed.
|
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
|
max_packet_size: int
|
||||||
@@ -126,7 +126,7 @@ class DataPacketQueue(pyee.EventEmitter):
|
|||||||
Remove all packets associated with a connection.
|
Remove all packets associated with a connection.
|
||||||
|
|
||||||
All packets associated with the connection that are in flight are implicitly
|
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 = [
|
packets_to_keep = [
|
||||||
@@ -180,7 +180,7 @@ class DataPacketQueue(pyee.EventEmitter):
|
|||||||
self._completed = self._queued
|
self._completed = self._queued
|
||||||
|
|
||||||
self._check_queue()
|
self._check_queue()
|
||||||
self.emit('drain')
|
self.emit('flow')
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@@ -920,23 +920,9 @@ class Host(AbortableEventEmitter):
|
|||||||
for connection_handle, num_completed_packets in zip(
|
for connection_handle, num_completed_packets in zip(
|
||||||
event.connection_handles, event.num_completed_packets
|
event.connection_handles, event.num_completed_packets
|
||||||
):
|
):
|
||||||
if connection := self.connections.get(connection_handle):
|
if queue := self.get_data_packet_queue(connection_handle):
|
||||||
connection.acl_packet_queue.on_packets_completed(
|
queue.on_packets_completed(num_completed_packets, connection_handle)
|
||||||
num_completed_packets, connection_handle
|
continue
|
||||||
)
|
|
||||||
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 connection_handle not in self.sco_links:
|
if connection_handle not in self.sco_links:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|||||||
@@ -138,15 +138,15 @@ def test_data_packet_queue():
|
|||||||
assert queue.completed == 11
|
assert queue.completed == 11
|
||||||
|
|
||||||
drain_listener = unittest.mock.Mock()
|
drain_listener = unittest.mock.Mock()
|
||||||
queue.on('drain', drain_listener.on_drain)
|
queue.on('flow', drain_listener.on_flow)
|
||||||
queue.enqueue(packet, 123)
|
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)
|
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.enqueue(packet, 123)
|
||||||
queue.enqueue(packet, 123)
|
queue.enqueue(packet, 123)
|
||||||
queue.flush(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.queued == 15
|
||||||
assert queue.completed == 15
|
assert queue.completed == 15
|
||||||
|
|||||||
Reference in New Issue
Block a user