summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-27 22:28:35 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-04-28 08:33:57 +0900
commita8c764acb487267d2f806b03f22d742e2628e621 (patch)
treee435a245afa0a3604e717237d450f6bef803ed96
parent62a66e2ff8201446af55e62e3358c712fc74eb80 (diff)
downloadmpv-a8c764acb487267d2f806b03f22d742e2628e621.tar.bz2
mpv-a8c764acb487267d2f806b03f22d742e2628e621.tar.xz
player: fix removing external tracks at runtime
This could make the player crash on exit if the "sub_reload" command was used successfully. the reason was that the mpctx->sources array could have dangling pointers to the unloaded demuxers. Also fix a memory leak by actually always freeing the per-stream subtitle decoders (which are a hack to make ordered chapters behave better). (cherry picked from commit 4d2ed847ce8d2b4a8fde5673d0bd3accd2ccce6f)
-rw-r--r--player/loadfile.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 33f27d6b14..c0888466e8 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -653,8 +653,16 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track)
for (int n = mpctx->num_tracks - 1; n >= 0 && !in_use; n--)
in_use |= mpctx->tracks[n]->demuxer == d;
- if (!in_use)
+ if (!in_use) {
+ for (int n = 0; n < mpctx->num_sources; n++) {
+ if (mpctx->sources[n] == d) {
+ MP_TARRAY_REMOVE_AT(mpctx->sources, mpctx->num_sources, n);
+ break;
+ }
+ }
+ uninit_stream_sub_decoders(d);
free_demuxer_and_stream(d);
+ }
mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);