Skip to content

Commit 986a117

Browse files
fix(audio): 修复音频设备选择逻辑中的边界检查
- 更新设备ID的边界检查逻辑,确保在选择音频设备时不会超出设备列表范围,提升稳定性。
1 parent becfb02 commit 986a117

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/audio_codecs/audio_codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _auto_pick_device(self, kind: str) -> Optional[int]:
8888
if "WASAPI" in name:
8989
key = "default_input_device" if kind == "input" else "default_output_device"
9090
cand = ha.get(key, -1)
91-
if isinstance(cand, int) and cand >= 0:
91+
if isinstance(cand, int) and 0 <= cand < len(devices):
9292
d = devices[cand]
9393
if (kind == "input" and d["max_input_channels"] > 0) or (
9494
kind == "output" and d["max_output_channels"] > 0

0 commit comments

Comments
 (0)