Skip to content

Commit 928ccb9

Browse files
Merge pull request #227 from huangjunsen0406/refactor/audio_codec
fix(audio): 修复音频设备选择逻辑中的边界检查
2 parents 8c0070e + 986a117 commit 928ccb9

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)