diff options
author | Max Kellermann <max@duempel.org> | 2014-12-22 21:58:01 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-22 22:24:10 +0100 |
commit | 7f3fecbdf581faf7e98135d5cac535dee6faedf5 (patch) | |
tree | dc9ad3e87573267aad47050cdd3cf1c6615ed0d9 /src | |
parent | a2c6d5e1483138b0068d3010843e72d82249e3d2 (diff) | |
download | mpd-7f3fecbdf581faf7e98135d5cac535dee6faedf5.tar.gz mpd-7f3fecbdf581faf7e98135d5cac535dee6faedf5.tar.xz mpd-7f3fecbdf581faf7e98135d5cac535dee6faedf5.zip |
decoder/ffmpeg: simplify mpd_ffmpeg_open_input()
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/FfmpegDecoderPlugin.cxx | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 36b13a4d1..c9bea0830 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -57,23 +57,19 @@ extern "C" { #include <assert.h> #include <string.h> -/** - * API compatibility wrapper for av_open_input_stream() and - * avformat_open_input(). - */ -static int -mpd_ffmpeg_open_input(AVFormatContext **ic_ptr, - AVIOContext *pb, +static AVFormatContext * +FfmpegOpenInput(AVIOContext *pb, const char *filename, AVInputFormat *fmt) { AVFormatContext *context = avformat_alloc_context(); if (context == nullptr) - return AVERROR(ENOMEM); + return nullptr; context->pb = pb; - *ic_ptr = context; - return avformat_open_input(ic_ptr, filename, fmt, nullptr); + + avformat_open_input(&context, filename, fmt, nullptr); + return context; } static bool @@ -557,10 +553,9 @@ ffmpeg_decode(Decoder &decoder, InputStream &input) return; } - AVFormatContext *format_context = nullptr; - if (mpd_ffmpeg_open_input(&format_context, stream.io, - input.GetURI(), - input_format) != 0) { + AVFormatContext *format_context = + FfmpegOpenInput(stream.io, input.GetURI(), input_format); + if (format_context == nullptr) { LogError(ffmpeg_domain, "Open failed"); return; } @@ -605,9 +600,9 @@ ffmpeg_scan_stream(InputStream &is, if (!stream.Open()) return false; - AVFormatContext *f = nullptr; - if (mpd_ffmpeg_open_input(&f, stream.io, is.GetURI(), - input_format) != 0) + AVFormatContext *f = + FfmpegOpenInput(stream.io, is.GetURI(), input_format); + if (f == nullptr) return false; bool result = FfmpegScanStream(*f, *handler, handler_ctx); |