aboutsummaryrefslogtreecommitdiffstats
path: root/src/MixerControl.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-10 18:02:44 +0200
committerMax Kellermann <max@duempel.org>2013-09-04 18:14:22 +0200
commit29030b54c98b0aee65fbc10ebf7ba36bed98c02c (patch)
tree79766830b55ebca38ddbce84d8d548227eedb69e /src/MixerControl.cxx
parentc9fcc7f14860777458153eb2d13c773ccfa1daa2 (diff)
downloadmpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.gz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.xz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.zip
util/Error: new error passing library
Replaces GLib's GError.
Diffstat (limited to '')
-rw-r--r--src/MixerControl.cxx29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/MixerControl.cxx b/src/MixerControl.cxx
index bbb3ede2c..86db5dde4 100644
--- a/src/MixerControl.cxx
+++ b/src/MixerControl.cxx
@@ -20,8 +20,7 @@
#include "config.h"
#include "MixerControl.hxx"
#include "MixerInternal.hxx"
-
-#include <glib.h>
+#include "util/Error.hxx"
#include <assert.h>
#include <stddef.h>
@@ -32,13 +31,13 @@
Mixer *
mixer_new(const struct mixer_plugin *plugin, void *ao,
const config_param &param,
- GError **error_r)
+ Error &error)
{
Mixer *mixer;
assert(plugin != NULL);
- mixer = plugin->init(ao, param, error_r);
+ mixer = plugin->init(ao, param, error);
assert(mixer == NULL || mixer->IsPlugin(*plugin));
@@ -59,7 +58,7 @@ mixer_free(Mixer *mixer)
}
bool
-mixer_open(Mixer *mixer, GError **error_r)
+mixer_open(Mixer *mixer, Error &error)
{
bool success;
@@ -73,7 +72,7 @@ mixer_open(Mixer *mixer, GError **error_r)
else if (mixer->plugin->open == NULL)
success = mixer->open = true;
else
- success = mixer->open = mixer->plugin->open(mixer, error_r);
+ success = mixer->open = mixer->plugin->open(mixer, error);
mixer->failed = !success;
@@ -127,26 +126,22 @@ mixer_failed(Mixer *mixer)
}
int
-mixer_get_volume(Mixer *mixer, GError **error_r)
+mixer_get_volume(Mixer *mixer, Error &error)
{
int volume;
assert(mixer != NULL);
if (mixer->plugin->global && !mixer->failed &&
- !mixer_open(mixer, error_r))
+ !mixer_open(mixer, error))
return -1;
const ScopeLock protect(mixer->mutex);
if (mixer->open) {
- GError *error = NULL;
-
- volume = mixer->plugin->get_volume(mixer, &error);
- if (volume < 0 && error != NULL) {
- g_propagate_error(error_r, error);
+ volume = mixer->plugin->get_volume(mixer, error);
+ if (volume < 0 && error.IsDefined())
mixer_failed(mixer);
- }
} else
volume = -1;
@@ -154,17 +149,17 @@ mixer_get_volume(Mixer *mixer, GError **error_r)
}
bool
-mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r)
+mixer_set_volume(Mixer *mixer, unsigned volume, Error &error)
{
assert(mixer != NULL);
assert(volume <= 100);
if (mixer->plugin->global && !mixer->failed &&
- !mixer_open(mixer, error_r))
+ !mixer_open(mixer, error))
return false;
const ScopeLock protect(mixer->mutex);
return mixer->open &&
- mixer->plugin->set_volume(mixer, volume, error_r);
+ mixer->plugin->set_volume(mixer, volume, error);
}