aboutsummaryrefslogtreecommitdiffstats
path: root/src/DecoderControl.hxx
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/DecoderControl.hxx
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/DecoderControl.hxx28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/DecoderControl.hxx b/src/DecoderControl.hxx
index 31c72657b..98492c450 100644
--- a/src/DecoderControl.hxx
+++ b/src/DecoderControl.hxx
@@ -24,6 +24,7 @@
#include "AudioFormat.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
+#include "util/Error.hxx"
#include <glib.h>
@@ -77,7 +78,7 @@ struct decoder_control {
* The object must be freed when this object transitions to
* any other state (usually #DECODE_STATE_START).
*/
- GError *error;
+ Error error;
bool quit;
bool seek_error;
@@ -218,38 +219,41 @@ struct decoder_control {
}
/**
- * Checks whether an error has occurred, and if so, returns a newly
- * allocated copy of the #GError object.
+ * Checks whether an error has occurred, and if so, returns a
+ * copy of the #Error object.
*
* Caller must lock the object.
*/
- GError *GetError() const {
+ gcc_pure
+ Error GetError() const {
assert(command == DECODE_COMMAND_NONE);
- assert(state != DECODE_STATE_ERROR || error != nullptr);
+ assert(state != DECODE_STATE_ERROR || error.IsDefined());
- return state == DECODE_STATE_ERROR
- ? g_error_copy(error)
- : nullptr;
+ Error result;
+ if (state == DECODE_STATE_ERROR)
+ result.Set(error);
+ return result;
}
/**
* Like dc_get_error(), but locks and unlocks the object.
*/
- GError *LockGetError() const {
+ gcc_pure
+ Error LockGetError() const {
Lock();
- GError *result = GetError();
+ Error result = GetError();
Unlock();
return result;
}
/**
- * Clear the error condition and free the #GError object (if any).
+ * Clear the error condition and free the #Error object (if any).
*
* Caller must lock the object.
*/
void ClearError() {
if (state == DECODE_STATE_ERROR) {
- g_error_free(error);
+ error.Clear();
state = DECODE_STATE_STOP;
}
}