aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-12-19 10:20:25 +0100
committerMax Kellermann <max@duempel.org>2014-12-19 10:21:51 +0100
commit8c3be4a5f036420ef2c7f1f53e573547df3b6c9b (patch)
treef89d79d3c277c5aa2c8d4b904ad8e154fad6e510 /src
parent3fe2f7337c666be76454ba0e691efe723f7ea865 (diff)
downloadmpd-8c3be4a5f036420ef2c7f1f53e573547df3b6c9b.tar.gz
mpd-8c3be4a5f036420ef2c7f1f53e573547df3b6c9b.tar.xz
mpd-8c3be4a5f036420ef2c7f1f53e573547df3b6c9b.zip
decoder/ffmpeg: skip _scan_stream() if no audio stream was found
Diffstat (limited to 'src')
-rw-r--r--src/decoder/plugins/FfmpegDecoderPlugin.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
index 04025f2af..27bd671cc 100644
--- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
@@ -473,10 +473,11 @@ static void
FfmpegScanMetadata(const AVFormatContext &format_context, int audio_stream,
const tag_handler &handler, void *handler_ctx)
{
+ assert(audio_stream >= 0);
+
FfmpegScanDictionary(format_context.metadata, &handler, handler_ctx);
- if (audio_stream >= 0)
- FfmpegScanMetadata(*format_context.streams[audio_stream],
- handler, handler_ctx);
+ FfmpegScanMetadata(*format_context.streams[audio_stream],
+ handler, handler_ctx);
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0)
@@ -691,6 +692,10 @@ FfmpegScanStream(AVFormatContext &format_context,
if (find_result < 0)
return false;
+ const int audio_stream = ffmpeg_find_audio_stream(format_context);
+ if (audio_stream < 0)
+ return false;
+
if (format_context.duration != (int64_t)AV_NOPTS_VALUE) {
const auto duration =
SongTime::FromScale<uint64_t>(format_context.duration,
@@ -698,8 +703,7 @@ FfmpegScanStream(AVFormatContext &format_context,
tag_handler_invoke_duration(&handler, handler_ctx, duration);
}
- int idx = ffmpeg_find_audio_stream(format_context);
- FfmpegScanMetadata(format_context, idx, handler, handler_ctx);
+ FfmpegScanMetadata(format_context, audio_stream, handler, handler_ctx);
return true;
}