aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-26 19:46:39 +0100
committerMax Kellermann <max@duempel.org>2009-03-26 19:46:39 +0100
commit69759b573f549857daef8789741903a03f8e9b22 (patch)
tree8149c37bfabeeb8422237175c062aa5267faa177 /src
parent1fcf09a816977db8e12e4534d7c4ced5c053f0de (diff)
downloadmpd-69759b573f549857daef8789741903a03f8e9b22.tar.gz
mpd-69759b573f549857daef8789741903a03f8e9b22.tar.xz
mpd-69759b573f549857daef8789741903a03f8e9b22.zip
mixer: don't reopen failed mixer automatically
If a (global) mixer has been closed due to failure, don't reopen it with every volume get/set. Leave it closed until it is explicitly opened.
Diffstat (limited to '')
-rw-r--r--src/mixer_api.c1
-rw-r--r--src/mixer_api.h6
-rw-r--r--src/mixer_control.c8
3 files changed, 13 insertions, 2 deletions
diff --git a/src/mixer_api.c b/src/mixer_api.c
index 50bf8c1b1..cff23a397 100644
--- a/src/mixer_api.c
+++ b/src/mixer_api.c
@@ -28,4 +28,5 @@ mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin)
mixer->plugin = plugin;
mixer->mutex = g_mutex_new();
mixer->open = false;
+ mixer->failed = false;
}
diff --git a/src/mixer_api.h b/src/mixer_api.h
index 344d04453..fe27f5119 100644
--- a/src/mixer_api.h
+++ b/src/mixer_api.h
@@ -38,6 +38,12 @@ struct mixer {
* Is the mixer device currently open?
*/
bool open;
+
+ /**
+ * Has this mixer failed, and should not be reopened
+ * automatically?
+ */
+ bool failed;
};
void
diff --git a/src/mixer_control.c b/src/mixer_control.c
index cb3c2a87e..908de5c54 100644
--- a/src/mixer_control.c
+++ b/src/mixer_control.c
@@ -82,6 +82,8 @@ mixer_open(struct mixer *mixer)
else
success = mixer->open = mixer->plugin->open(mixer);
+ mixer->failed = !success;
+
g_mutex_unlock(mixer->mutex);
return success;
@@ -120,6 +122,8 @@ mixer_failed(struct mixer *mixer)
assert(mixer->open);
mixer_close(mixer);
+
+ mixer->failed = true;
}
int
@@ -129,7 +133,7 @@ mixer_get_volume(struct mixer *mixer)
assert(mixer != NULL);
- if (mixer->plugin->global && !mixer_open(mixer))
+ if (mixer->plugin->global && !mixer->failed && !mixer_open(mixer))
return -1;
g_mutex_lock(mixer->mutex);
@@ -153,7 +157,7 @@ mixer_set_volume(struct mixer *mixer, unsigned volume)
assert(mixer != NULL);
- if (mixer->plugin->global && !mixer_open(mixer))
+ if (mixer->plugin->global && !mixer->failed && !mixer_open(mixer))
return false;
g_mutex_lock(mixer->mutex);