aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-04 16:55:12 +0100
committerMax Kellermann <max@duempel.org>2008-11-04 16:55:12 +0100
commit7e84c73b17b2230a49fe51dc09f4e3b85fa9d8a7 (patch)
tree5459d17618ee9c8d3f36017bb8e03408cad6f23a /src/decoder
parent5e486964e81462c2e178b6967dda1f73cda57d9c (diff)
downloadmpd-7e84c73b17b2230a49fe51dc09f4e3b85fa9d8a7.tar.gz
mpd-7e84c73b17b2230a49fe51dc09f4e3b85fa9d8a7.tar.xz
mpd-7e84c73b17b2230a49fe51dc09f4e3b85fa9d8a7.zip
ffmpeg: moved code to ffmpeg_find_audio_stream()
Diffstat (limited to '')
-rw-r--r--src/decoder/ffmpeg_plugin.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index 605d58ef2..71958b77b 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -130,6 +130,17 @@ static bool ffmpeg_init(void)
return true;
}
+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 ==
+ CODEC_TYPE_AUDIO)
+ return i;
+
+ return -1;
+}
+
static bool
ffmpeg_helper(struct input_stream *input,
bool (*callback)(struct ffmpeg_context *ctx),
@@ -139,7 +150,6 @@ ffmpeg_helper(struct input_stream *input,
AVCodecContext *codec_context;
AVCodec *codec;
int audio_stream;
- unsigned i;
struct ffmpeg_stream stream = {
.url = "mpd://X", /* only the mpd:// prefix matters */
};
@@ -163,14 +173,7 @@ ffmpeg_helper(struct input_stream *input,
return false;
}
- audio_stream = -1;
- for(i=0; i<format_context->nb_streams; i++) {
- if (format_context->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO &&
- audio_stream < 0) {
- audio_stream=i;
- }
- }
-
+ audio_stream = ffmpeg_find_audio_stream(format_context);
if (audio_stream == -1) {
ERROR("No audio stream inside!\n");
return false;