player/loadfile: cancel playback cleanly if thread fails to start

Currently it would crash, due to already canceled and freed resources.
This commit is contained in:
Kacper Michajłow 2024-07-10 20:44:15 +02:00
parent 66fdec8a67
commit aea5b3dbea
1 changed files with 5 additions and 0 deletions

View File

@ -1247,6 +1247,10 @@ static void open_demux_reentrant(struct MPContext *mpctx)
if (!mpctx->open_active)
start_open(mpctx, url, mpctx->playing->stream_flags, false);
// If thread failed to start, cancel the playback
if (!mpctx->open_active)
goto cancel;
// User abort should cancel the opener now.
mp_cancel_set_parent(mpctx->open_cancel, mpctx->playback_abort);
@ -1265,6 +1269,7 @@ static void open_demux_reentrant(struct MPContext *mpctx)
mpctx->error_playing = mpctx->open_res_error;
}
cancel:
cancel_open(mpctx); // cleanup
}