From d3b5574d7aac0a7f2d4eb785facfad9f37c15dd5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Jul 2009 21:52:10 +0200 Subject: 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). --- src/mixer_all.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/mixer_all.c') 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; -- cgit v1.2.3