ffmpeg: Use avcodec_flush_buffers when seeking

Previously this would close and reopen the codec context;
that's entirely unnecessary, as all supported versions of
libavcodec support flushing the buffers instead.
This commit is contained in:
Sam Edwards 2018-03-31 03:25:03 -06:00
parent e430428703
commit 8d36908556

View File

@ -437,16 +437,7 @@ seek(double t) {
cleanup();
return;
}
avcodec_close(_audio_ctx);
AVCodec *pAudioCodec = avcodec_find_decoder(_audio_ctx->codec_id);
if(pAudioCodec == 0) {
cleanup();
return;
}
if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) {
cleanup();
return;
}
avcodec_flush_buffers(_audio_ctx);
_buffer_head = 0;
_buffer_tail = 0;
fetch_packet();