From 83ce0e5325b9bcf9b339ea9c69b658d45b4125cf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 16 Feb 2009 01:39:52 +0100 Subject: 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(). --- src/audio.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/audio.c') 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; } -- cgit v1.2.3