aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/mixer/alsa_mixer.c3
-rw-r--r--src/mixer/oss_mixer.c2
-rw-r--r--src/mixer_control.c16
3 files changed, 16 insertions, 5 deletions
diff --git a/src/mixer/alsa_mixer.c b/src/mixer/alsa_mixer.c
index c5aac13d4..892cef2b4 100644
--- a/src/mixer/alsa_mixer.c
+++ b/src/mixer/alsa_mixer.c
@@ -162,7 +162,6 @@ alsa_mixer_get_volume(struct mixer *mixer)
if (err < 0) {
g_warning("problems getting alsa volume: %s (snd_mixer_%s)\n",
snd_strerror(err), "handle_events");
- alsa_mixer_close(mixer);
return false;
}
@@ -172,7 +171,6 @@ alsa_mixer_get_volume(struct mixer *mixer)
if (err < 0) {
g_warning("problems getting alsa volume: %s (snd_mixer_%s)\n",
snd_strerror(err), "selem_get_playback_volume");
- alsa_mixer_close(mixer);
return false;
}
@@ -216,7 +214,6 @@ alsa_mixer_set_volume(struct mixer *mixer, unsigned volume)
if (err < 0) {
g_warning("problems setting alsa volume: %s\n",
snd_strerror(err));
- alsa_mixer_close(mixer);
return false;
}
diff --git a/src/mixer/oss_mixer.c b/src/mixer/oss_mixer.c
index 13e325823..96339e85c 100644
--- a/src/mixer/oss_mixer.c
+++ b/src/mixer/oss_mixer.c
@@ -150,7 +150,6 @@ oss_mixer_get_volume(struct mixer *mixer)
ret = ioctl(om->device_fd, MIXER_READ(om->volume_control), &level);
if (ret < 0) {
- oss_mixer_close(mixer);
g_warning("unable to read oss volume\n");
return false;
}
@@ -184,7 +183,6 @@ oss_mixer_set_volume(struct mixer *mixer, unsigned volume)
ret = ioctl(om->device_fd, MIXER_WRITE(om->volume_control), &level);
if (ret < 0) {
g_warning("unable to set oss volume\n");
- oss_mixer_close(mixer);
return false;
}
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;