aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-02-27 19:32:59 +0100
committerMax Kellermann <max@duempel.org>2010-02-27 19:32:59 +0100
commitae569018630fa4655e3fc9f71787aa8c1fa08ebf (patch)
tree154c6c27cc0f415d1c79a98bd244337087b39cf1 /src/decoder
parent4e364854ab2d617dde418d26b50d19480431f813 (diff)
downloadmpd-ae569018630fa4655e3fc9f71787aa8c1fa08ebf.tar.gz
mpd-ae569018630fa4655e3fc9f71787aa8c1fa08ebf.tar.xz
mpd-ae569018630fa4655e3fc9f71787aa8c1fa08ebf.zip
decoder/ffmpeg: implement the libavutil log callback
Pass everything to the GLib logging library. No direct stderr access.
Diffstat (limited to '')
-rw-r--r--src/decoder/ffmpeg_decoder_plugin.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c
index 37ed3bd48..f1cc1c4b5 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/ffmpeg_decoder_plugin.c
@@ -40,11 +40,38 @@
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
+#include <libavutil/log.h>
#endif
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "ffmpeg"
+#ifndef OLD_FFMPEG_INCLUDES
+
+static GLogLevelFlags
+level_ffmpeg_to_glib(int level)
+{
+ if (level <= AV_LOG_FATAL)
+ return G_LOG_LEVEL_CRITICAL;
+
+ if (level <= AV_LOG_ERROR)
+ return G_LOG_LEVEL_WARNING;
+
+ if (level <= AV_LOG_INFO)
+ return G_LOG_LEVEL_MESSAGE;
+
+ return G_LOG_LEVEL_DEBUG;
+}
+
+static void
+mpd_ffmpeg_log_callback(G_GNUC_UNUSED void *ptr, int level,
+ const char *fmt, va_list vl)
+{
+ g_logv(G_LOG_DOMAIN, level_ffmpeg_to_glib(level), fmt, vl);
+}
+
+#endif /* !OLD_FFMPEG_INCLUDES */
+
struct ffmpeg_stream {
/** hack - see url_to_struct() */
char url[64];
@@ -116,6 +143,10 @@ static URLProtocol mpd_ffmpeg_fileops = {
static bool
ffmpeg_init(G_GNUC_UNUSED const struct config_param *param)
{
+#ifndef OLD_FFMPEG_INCLUDES
+ av_log_set_callback(mpd_ffmpeg_log_callback);
+#endif
+
av_register_all();
register_protocol(&mpd_ffmpeg_fileops);
return true;