mirror of https://github.com/mpv-player/mpv
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).
This commit is contained in:
parent
0c70f94c53
commit
4d2ed847ce
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue