diff options
author | Max Kellermann <max@duempel.org> | 2009-02-16 01:39:52 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-16 01:39:52 +0100 |
commit | 83ce0e5325b9bcf9b339ea9c69b658d45b4125cf (patch) | |
tree | fa7438905b1fa2219832ecfc4c1d4e9ecc40c55e /src/audio.c | |
parent | 37bc31d161d486d0499cf64123b7561f57dd0c53 (diff) | |
download | mpd-83ce0e5325b9bcf9b339ea9c69b658d45b4125cf.tar.gz mpd-83ce0e5325b9bcf9b339ea9c69b658d45b4125cf.tar.xz mpd-83ce0e5325b9bcf9b339ea9c69b658d45b4125cf.zip |
mixer_api: replaced method "control()" with "{get,set}_volume()"
The method control() is too complicated, and overengineered. Replace
it with two trivial functions: get_volume() and set_volume().
Diffstat (limited to 'src/audio.c')
-rw-r--r-- | src/audio.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/audio.c b/src/audio.c index e5b043962..a6deff082 100644 --- a/src/audio.c +++ b/src/audio.c @@ -71,10 +71,10 @@ bool mixer_control_setvol(unsigned int device, int volume, int rel) mixer = ao_plugin_get_mixer(output->plugin, output->data); if (mixer != NULL) { if (rel) { - int cur_volume; - if (!mixer_control(mixer, AC_MIXER_GETVOL, &cur_volume)) { + int cur_volume = mixer_get_volume(mixer); + if (cur_volume < 0) return false; - } + volume = volume + cur_volume; } if (volume > 100) @@ -82,7 +82,7 @@ bool mixer_control_setvol(unsigned int device, int volume, int rel) else if (volume < 0) volume = 0; - return mixer_control(mixer, AC_MIXER_SETVOL, &volume); + return mixer_set_volume(mixer, volume); } return false; } @@ -97,8 +97,16 @@ bool mixer_control_getvol(unsigned int device, int *volume) output = audio_output_get(device); mixer = ao_plugin_get_mixer(output->plugin, output->data); - if (mixer != NULL) - return mixer_control(mixer, AC_MIXER_GETVOL, volume); + if (mixer != NULL) { + int volume2; + + volume2 = mixer_get_volume(mixer); + if (volume2 < 0) + return false; + + *volume = volume2; + return true; + } return false; } |