From 7456dccd3ad1fcf18bcf13c26bac8fd014b4b009 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 29 Jul 2016 19:25:02 +0200 Subject: [PATCH] decoder/ffmpeg: FfmpegOpenInput() returns Error --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index dd411a4e0..533799548 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -58,11 +58,14 @@ extern "C" { static AVFormatContext * FfmpegOpenInput(AVIOContext *pb, const char *filename, - AVInputFormat *fmt) + AVInputFormat *fmt, + Error &error) { AVFormatContext *context = avformat_alloc_context(); - if (context == nullptr) + if (context == nullptr) { + error.Set(ffmpeg_domain, "Out of memory"); return nullptr; + } context->pb = pb; @@ -666,10 +669,11 @@ ffmpeg_decode(Decoder &decoder, InputStream &input) return; } + Error error; AVFormatContext *format_context = - FfmpegOpenInput(stream.io, input.GetURI(), input_format); + FfmpegOpenInput(stream.io, input.GetURI(), input_format, error); if (format_context == nullptr) { - LogError(ffmpeg_domain, "Open failed"); + LogError(error); return; } @@ -718,7 +722,8 @@ ffmpeg_scan_stream(InputStream &is, return false; AVFormatContext *f = - FfmpegOpenInput(stream.io, is.GetURI(), input_format); + FfmpegOpenInput(stream.io, is.GetURI(), input_format, + IgnoreError()); if (f == nullptr) return false;