aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer/alsa_mixer.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-26 19:49:31 +0100
committerMax Kellermann <max@duempel.org>2009-03-26 19:49:31 +0100
commit0c9799babeba12ff62b77eeafba39e80cb1a4f6a (patch)
tree41098799f3f4987cd1d0444681a2542af6c566d0 /src/mixer/alsa_mixer.c
parent331b714a7a74b26a99fe46add9443a339e44fb02 (diff)
downloadmpd-0c9799babeba12ff62b77eeafba39e80cb1a4f6a.tar.gz
mpd-0c9799babeba12ff62b77eeafba39e80cb1a4f6a.tar.xz
mpd-0c9799babeba12ff62b77eeafba39e80cb1a4f6a.zip
alsa_mixer: removed superfluous checks
The MPD core guarantees that methods are always invoked in a consistent state. This means we can remove lots of checks from the volume methods.
Diffstat (limited to 'src/mixer/alsa_mixer.c')
-rw-r--r--src/mixer/alsa_mixer.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/mixer/alsa_mixer.c b/src/mixer/alsa_mixer.c
index 9609a837b..75321408f 100644
--- a/src/mixer/alsa_mixer.c
+++ b/src/mixer/alsa_mixer.c
@@ -52,10 +52,6 @@ alsa_mixer_init(const struct config_param *param)
am->control = config_get_block_string(param, "mixer_control",
VOLUME_MIXER_ALSA_CONTROL_DEFAULT);
- am->handle = NULL;
- am->elem = NULL;
- am->volume_min = 0;
- am->volume_max = 0;
am->volume_set = -1;
return &am->base;
@@ -73,8 +69,10 @@ static void
alsa_mixer_close(struct mixer *data)
{
struct alsa_mixer *am = (struct alsa_mixer *)data;
- if (am->handle) snd_mixer_close(am->handle);
- am->handle = NULL;
+
+ assert(am->handle != NULL);
+
+ snd_mixer_close(am->handle);
}
static bool
@@ -147,8 +145,7 @@ alsa_mixer_get_volume(struct mixer *mixer)
int ret;
long level;
- if (am->handle == NULL && !alsa_mixer_open(mixer))
- return -1;
+ assert(am->handle != NULL);
err = snd_mixer_handle_events(am->handle);
if (err < 0) {
@@ -186,8 +183,7 @@ alsa_mixer_set_volume(struct mixer *mixer, unsigned volume)
long level;
int err;
- if (am->handle == NULL && !alsa_mixer_open(mixer))
- return false;
+ assert(am->handle != NULL);
vol = volume;