This commit is contained in:
Sakura-RanChen
2025-08-20 09:30:43 +08:00
parent d138e1dcef
commit 74826c1c59
3 changed files with 26 additions and 7 deletions
@@ -151,6 +151,21 @@ class AudioFlowController:
)
async def simulate_device_consumption(
flow_controller: AudioFlowController, frame_count: int
):
"""
模拟设备消费音频帧的过程
实际应用中应该根据设备反馈来更新消费情况
Args:
flow_controller: 流控制器实例
frame_count: 消费的帧数
"""
# 模拟设备播放延迟(60ms per frame
await asyncio.sleep(frame_count * 0.06)
flow_controller.update_device_consumption(frame_count)
# 流控配置常量
class FlowControlConfig:
"""流控配置常量"""
@@ -183,4 +198,4 @@ class FlowControlConfig:
return AudioFlowController(
max_device_buffer=max_buffer or cls.DEFAULT_MAX_DEVICE_BUFFER,
refill_rate=refill_rate or cls.DEFAULT_REFILL_RATE
)
)