aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer_all.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-06 21:52:10 +0200
committerMax Kellermann <max@duempel.org>2009-07-06 21:52:10 +0200
commitd3b5574d7aac0a7f2d4eb785facfad9f37c15dd5 (patch)
tree9255929810567b241a34b7c2c77479c49271b99a /src/mixer_all.c
parent90472526e00c671f76d78341b5e474fcf069d41e (diff)
downloadmpd-d3b5574d7aac0a7f2d4eb785facfad9f37c15dd5.tar.gz
mpd-d3b5574d7aac0a7f2d4eb785facfad9f37c15dd5.tar.xz
mpd-d3b5574d7aac0a7f2d4eb785facfad9f37c15dd5.zip
volume: moved range check to handle_setvol()
Converted the range checks in volume_level_change() to assertions. Changed all volume types to "unsigned", expect for those which must be able to indicate error (-1).
Diffstat (limited to 'src/mixer_all.c')
-rw-r--r--src/mixer_all.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/mixer_all.c b/src/mixer_all.c
index 21ff44c35..980f854a2 100644
--- a/src/mixer_all.c
+++ b/src/mixer_all.c
@@ -70,12 +70,13 @@ mixer_all_get_volume(void)
}
static bool
-output_mixer_set_volume(unsigned i, int volume)
+output_mixer_set_volume(unsigned i, unsigned volume)
{
struct audio_output *output;
struct mixer *mixer;
assert(i < audio_output_count());
+ assert(volume <= 100);
output = audio_output_get(i);
if (!output->enabled)
@@ -85,20 +86,17 @@ output_mixer_set_volume(unsigned i, int volume)
if (mixer == NULL)
return false;
- if (volume > 100)
- volume = 100;
- else if (volume < 0)
- volume = 0;
-
return mixer_set_volume(mixer, volume);
}
bool
-mixer_all_set_volume(int volume)
+mixer_all_set_volume(unsigned volume)
{
bool success = false;
unsigned count = audio_output_count();
+ assert(volume <= 100);
+
for (unsigned i = 0; i < count; i++)
success = output_mixer_set_volume(i, volume)
|| success;