summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-11-09 16:35:44 +0100
committerwm4 <wm4@nowhere>2016-11-09 16:44:06 +0100
commit67467103e8c7a143c8eafda86d312dfa0c949266 (patch)
tree5adee2ce7c9bd653ec9afab40457d7d37c50631a /audio
parenta55e8ff31cc974843e28282ccbdc46dd3e70a5af (diff)
downloadmpv-67467103e8c7a143c8eafda86d312dfa0c949266.tar.bz2
mpv-67467103e8c7a143c8eafda86d312dfa0c949266.tar.xz
dec_video, dec_audio: avoid full reinit on switches to the same segment
Same deal as with the previous commit. (Unfortunately, this code is still duplicated.)
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/dec_audio.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 3028d9988e..39e867cf42 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -257,12 +257,15 @@ void audio_work(struct dec_audio *da)
struct demux_packet *new_segment = da->new_segment;
da->new_segment = NULL;
- // Could avoid decoder reinit; would still need flush.
- da->codec = new_segment->codec;
- if (da->ad_driver)
- da->ad_driver->uninit(da);
- da->ad_driver = NULL;
- audio_init_best_codec(da);
+ if (da->codec == new_segment->codec) {
+ audio_reset_decoding(da);
+ } else {
+ da->codec = new_segment->codec;
+ if (da->ad_driver)
+ da->ad_driver->uninit(da);
+ da->ad_driver = NULL;
+ audio_init_best_codec(da);
+ }
da->start = new_segment->start;
da->end = new_segment->end;