aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/FfmpegInputPlugin.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/input/FfmpegInputPlugin.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 'src/input/FfmpegInputPlugin.cxx')
-rw-r--r--src/input/FfmpegInputPlugin.cxx28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/input/FfmpegInputPlugin.cxx b/src/input/FfmpegInputPlugin.cxx
index f27348b27..1837303bb 100644
--- a/src/input/FfmpegInputPlugin.cxx
+++ b/src/input/FfmpegInputPlugin.cxx
@@ -25,6 +25,8 @@
#include "InputInternal.hxx"
#include "InputStream.hxx"
#include "InputPlugin.hxx"
+#include "util/Error.hxx"
+#include "util/Domain.hxx"
extern "C" {
#include <libavutil/avutil.h>
@@ -62,11 +64,7 @@ struct FfmpegInputStream {
}
};
-static inline GQuark
-ffmpeg_quark(void)
-{
- return g_quark_from_static_string("ffmpeg");
-}
+static constexpr Domain ffmpeg_domain("ffmpeg");
static inline bool
input_ffmpeg_supported(void)
@@ -77,14 +75,13 @@ input_ffmpeg_supported(void)
static bool
input_ffmpeg_init(gcc_unused const config_param &param,
- gcc_unused GError **error_r)
+ Error &error)
{
av_register_all();
/* disable this plugin if there's no registered protocol */
if (!input_ffmpeg_supported()) {
- g_set_error(error_r, ffmpeg_quark(), 0,
- "No protocol");
+ error.Set(ffmpeg_domain, "No protocol");
return false;
}
@@ -94,7 +91,7 @@ input_ffmpeg_init(gcc_unused const config_param &param,
static struct input_stream *
input_ffmpeg_open(const char *uri,
Mutex &mutex, Cond &cond,
- GError **error_r)
+ Error &error)
{
if (!g_str_has_prefix(uri, "gopher://") &&
!g_str_has_prefix(uri, "rtp://") &&
@@ -107,8 +104,8 @@ input_ffmpeg_open(const char *uri,
AVIOContext *h;
int ret = avio_open(&h, uri, AVIO_FLAG_READ);
if (ret != 0) {
- g_set_error(error_r, ffmpeg_quark(), ret,
- "libavformat failed to open the URI");
+ error.Set(ffmpeg_domain, ret,
+ "libavformat failed to open the URI");
return nullptr;
}
@@ -118,15 +115,14 @@ input_ffmpeg_open(const char *uri,
static size_t
input_ffmpeg_read(struct input_stream *is, void *ptr, size_t size,
- GError **error_r)
+ Error &error)
{
FfmpegInputStream *i = (FfmpegInputStream *)is;
int ret = avio_read(i->h, (unsigned char *)ptr, size);
if (ret <= 0) {
if (ret < 0)
- g_set_error(error_r, ffmpeg_quark(), 0,
- "url_read() failed");
+ error.Set(ffmpeg_domain, "avio_read() failed");
i->eof = true;
return false;
@@ -154,7 +150,7 @@ input_ffmpeg_eof(struct input_stream *is)
static bool
input_ffmpeg_seek(struct input_stream *is, goffset offset, int whence,
- gcc_unused GError **error_r)
+ Error &error)
{
FfmpegInputStream *i = (FfmpegInputStream *)is;
int64_t ret = avio_seek(i->h, offset, whence);
@@ -163,7 +159,7 @@ input_ffmpeg_seek(struct input_stream *is, goffset offset, int whence,
i->eof = false;
return true;
} else {
- g_set_error(error_r, ffmpeg_quark(), 0, "url_seek() failed");
+ error.Set(ffmpeg_domain, "avio_seek() failed");
return false;
}
}