Skip to content

Commit d38a756

Browse files
committed
Add bounds checking to device gain
1 parent e7b0033 commit d38a756

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src_py/_audio.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def is_playback(self) -> bool:
139139
return _base_audio.is_audio_device_playback(self._state)
140140

141141
# TODO: this doesn't work for the default device ids...
142+
# https://github.com/libsdl-org/SDL/issues/14615
142143
@property
143144
def name(self) -> str:
144145
return _base_audio.get_audio_device_name(self._state)
@@ -165,6 +166,8 @@ def gain(self) -> float:
165166

166167
@gain.setter
167168
def gain(self, value: float) -> None:
169+
if value < 0:
170+
raise ValueError("Gain must be >= 0.")
168171
_base_audio.set_audio_device_gain(self._state, value)
169172

170173

0 commit comments

Comments
 (0)