Commit 43864762 authored by Max Kellermann's avatar Max Kellermann

mixer: assert that the new volume value is valid

Added an assertion in mixer_set_volume(). Removed the range checks from the ALSA and OSS plugins.
parent 49e548e7
......@@ -188,10 +188,6 @@ alsa_mixer_set_volume(struct mixer *mixer, unsigned volume)
vol = volume;
am->volume_set = vol + 0.5;
am->volume_set = am->volume_set > 100
? 100 :
(am->volume_set < 0
? 0 : am->volume_set);
level = (long)(((vol / 100.0) * (am->volume_max - am->volume_min) +
am->volume_min) + 0.5);
......
......@@ -171,9 +171,7 @@ oss_mixer_set_volume(struct mixer *mixer, unsigned volume)
int ret;
assert(om->device_fd >= 0);
if (volume > 100)
volume = 100;
assert(volume <= 100);
level = (volume << 8) + volume;
......
......@@ -165,6 +165,7 @@ mixer_set_volume(struct mixer *mixer, unsigned volume)
bool success;
assert(mixer != NULL);
assert(volume <= 100);
if (mixer->plugin->global && !mixer->failed && !mixer_open(mixer))
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment