From d1c5bb956ade7fc414f20c986d3a764c24b86e03 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 27 Jul 2016 14:58:41 +0200 Subject: [PATCH] decoder/ffmpeg: move code to IsAudio() --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index bfaca8033..3d2f90bc3 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -76,13 +76,19 @@ ffmpeg_init(gcc_unused const config_param ¶m) return true; } +gcc_pure +static bool +IsAudio(const AVStream &stream) +{ + return stream.codec->codec_type == AVMEDIA_TYPE_AUDIO; +} + gcc_pure static int ffmpeg_find_audio_stream(const AVFormatContext &format_context) { for (unsigned i = 0; i < format_context.nb_streams; ++i) - if (format_context.streams[i]->codec->codec_type == - AVMEDIA_TYPE_AUDIO) + if (IsAudio(*format_context.streams[i])) return i; return -1;