aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/SndfileDecoderPlugin.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/decoder/SndfileDecoderPlugin.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/decoder/SndfileDecoderPlugin.cxx22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/decoder/SndfileDecoderPlugin.cxx b/src/decoder/SndfileDecoderPlugin.cxx
index 29911a04e..0b83c142a 100644
--- a/src/decoder/SndfileDecoderPlugin.cxx
+++ b/src/decoder/SndfileDecoderPlugin.cxx
@@ -22,6 +22,7 @@
#include "DecoderAPI.hxx"
#include "CheckAudioFormat.hxx"
#include "TagHandler.hxx"
+#include "util/Error.hxx"
#include <sndfile.h>
@@ -40,10 +41,8 @@ static sf_count_t
sndfile_vio_seek(sf_count_t offset, int whence, void *user_data)
{
struct input_stream *is = (struct input_stream *)user_data;
- bool success;
- success = input_stream_lock_seek(is, offset, whence, nullptr);
- if (!success)
+ if (!input_stream_lock_seek(is, offset, whence, IgnoreError()))
return -1;
return input_stream_get_offset(is);
@@ -53,13 +52,11 @@ static sf_count_t
sndfile_vio_read(void *ptr, sf_count_t count, void *user_data)
{
struct input_stream *is = (struct input_stream *)user_data;
- GError *error = nullptr;
- size_t nbytes;
- nbytes = input_stream_lock_read(is, ptr, count, &error);
- if (nbytes == 0 && error != nullptr) {
- g_warning("%s", error->message);
- g_error_free(error);
+ Error error;
+ size_t nbytes = input_stream_lock_read(is, ptr, count, error);
+ if (nbytes == 0 && error.IsDefined()) {
+ g_warning("%s", error.GetMessage());
return -1;
}
@@ -116,7 +113,6 @@ time_to_frame(float t, const AudioFormat *audio_format)
static void
sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
{
- GError *error = nullptr;
SNDFILE *sf;
SF_INFO info;
size_t frame_size;
@@ -135,12 +131,12 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
/* for now, always read 32 bit samples. Later, we could lower
MPD's CPU usage by reading 16 bit samples with
sf_readf_short() on low-quality source files. */
+ Error error;
AudioFormat audio_format;
if (!audio_format_init_checked(audio_format, info.samplerate,
SampleFormat::S32,
- info.channels, &error)) {
- g_warning("%s", error->message);
- g_error_free(error);
+ info.channels, error)) {
+ g_warning("%s", error.GetMessage());
return;
}