aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer_control.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-26 19:46:33 +0100
committerMax Kellermann <max@duempel.org>2009-03-26 19:46:33 +0100
commit1fcf09a816977db8e12e4534d7c4ced5c053f0de (patch)
tree76cc2e953d60c5c8da8b502125770e78ca6fc125 /src/mixer_control.c
parent617a4fd2d2eff45393c4e243129a4648822d5d86 (diff)
downloadmpd-1fcf09a816977db8e12e4534d7c4ced5c053f0de.tar.gz
mpd-1fcf09a816977db8e12e4534d7c4ced5c053f0de.tar.xz
mpd-1fcf09a816977db8e12e4534d7c4ced5c053f0de.zip
mixer_control: close mixer on failure
When getting or setting the volume fails, the MPD core close the mixer. Moved the duplicated code from the mixer plugins.
Diffstat (limited to '')
-rw-r--r--src/mixer_control.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mixer_control.c b/src/mixer_control.c
index 4e86a9aa2..cb3c2a87e 100644
--- a/src/mixer_control.c
+++ b/src/mixer_control.c
@@ -110,6 +110,18 @@ mixer_auto_close(struct mixer *mixer)
mixer_close(mixer);
}
+/*
+ * Close the mixer due to failure. The mutex must be locked before
+ * calling this function.
+ */
+static void
+mixer_failed(struct mixer *mixer)
+{
+ assert(mixer->open);
+
+ mixer_close(mixer);
+}
+
int
mixer_get_volume(struct mixer *mixer)
{
@@ -124,6 +136,8 @@ mixer_get_volume(struct mixer *mixer)
if (mixer->open) {
volume = mixer->plugin->get_volume(mixer);
+ if (volume < 0)
+ mixer_failed(mixer);
} else
volume = -1;
@@ -146,6 +160,8 @@ mixer_set_volume(struct mixer *mixer, unsigned volume)
if (mixer->open) {
success = mixer->plugin->set_volume(mixer, volume);
+ if (!success)
+ mixer_failed(mixer);
} else
success = false;