aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/ffmpeg_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-30 19:03:41 +0100
committerMax Kellermann <max@duempel.org>2008-10-30 19:03:41 +0100
commitb15c4cdeb5c65f3f8a4588a8c0ccba537a4f7436 (patch)
treeec98ffad3447352cb2a11188c542966821618407 /src/decoder/ffmpeg_plugin.c
parentf3b4a28518e90f98e99e5d5196568136c4ec34f5 (diff)
downloadmpd-b15c4cdeb5c65f3f8a4588a8c0ccba537a4f7436.tar.gz
mpd-b15c4cdeb5c65f3f8a4588a8c0ccba537a4f7436.tar.xz
mpd-b15c4cdeb5c65f3f8a4588a8c0ccba537a4f7436.zip
ffmpeg: use return value of decoder_data()
decoder_data() always returns the current command. If we use this, we can save a lot of decoder_get_command() calls.
Diffstat (limited to 'src/decoder/ffmpeg_plugin.c')
-rw-r--r--src/decoder/ffmpeg_plugin.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index 5f00ead29..57e7325c4 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -213,7 +213,7 @@ ffmpeg_try_decode(struct input_stream *input)
return input->seekable && ffmpeg_helper(input, NULL, NULL);
}
-static void
+static enum decoder_command
ffmpeg_send_packet(struct decoder *decoder, const AVPacket *packet,
AVCodecContext *codec_context,
const AVRational *time_base)
@@ -233,15 +233,15 @@ ffmpeg_send_packet(struct decoder *decoder, const AVPacket *packet,
if (len < 0) {
WARNING("skipping frame!\n");
- return;
+ return decoder_get_command(decoder);
}
assert(audio_size >= 0);
- decoder_data(decoder, NULL, 1,
- audio_buf, audio_size,
- position,
- codec_context->bit_rate / 1000, NULL);
+ return decoder_data(decoder, NULL, 1,
+ audio_buf, audio_size,
+ position,
+ codec_context->bit_rate / 1000, NULL);
}
static bool
@@ -252,6 +252,7 @@ ffmpeg_decode_internal(BasePtrs *base)
AVFormatContext *pFormatCtx = base->pFormatCtx;
AVPacket packet;
struct audio_format audio_format;
+ enum decoder_command cmd;
int current, total_time;
total_time = 0;
@@ -272,8 +273,19 @@ ffmpeg_decode_internal(BasePtrs *base)
decoder_initialized(decoder, &audio_format, total_time);
do {
+ if (av_read_frame(pFormatCtx, &packet) < 0)
+ /* end of file */
+ break;
+
+ if (packet.stream_index == base->audioStream)
+ cmd = ffmpeg_send_packet(decoder, &packet, aCodecCtx,
+ &pFormatCtx->streams[base->audioStream]->time_base);
+ else
+ cmd = decoder_get_command(decoder);
+
+ av_free_packet(&packet);
- if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
+ if (cmd == DECODE_COMMAND_SEEK) {
current = decoder_seek_where(decoder) * AV_TIME_BASE;
if (av_seek_frame(pFormatCtx, -1, current, 0) < 0)
@@ -281,17 +293,7 @@ ffmpeg_decode_internal(BasePtrs *base)
else
decoder_command_finished(decoder);
}
-
- if (av_read_frame(pFormatCtx, &packet) < 0)
- /* end of file */
- break;
-
- if (packet.stream_index == base->audioStream)
- ffmpeg_send_packet(decoder, &packet, aCodecCtx,
- &pFormatCtx->streams[base->audioStream]->time_base);
-
- av_free_packet(&packet);
- } while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
+ } while (cmd != DECODE_COMMAND_STOP);
return true;
}