Race condition on player when restoring state
Being able to restore the state of an input is sent to the interface through a player callback, but it is asynchronously presented to the user as they cannot decide whether it must be restored or not in the callback without blocking player/playback too.
During the time this choice is made, the player state can completely change, in particular including input change to another input or no input at all. When there is no input, restoring leads to the following crash and stacktrace
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) vlc_player_input_RestoreMlStates (input=0x0, force_pos=force_pos@entry=true) at ../../src/player/medialib.c:32
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0x0000007f99500414 in vlc_player_RestorePlaybackPos (player=<optimized out>) at ../../src/player/medialib.c:349
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0x0000007f932c4484 in PlayerController::restorePlaybackPos (this=<optimized out>) at ../../modules/gui/qt/player/player_controller.cpp:1524
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0x0000007f93316598 in PlayerController::qt_static_metacall (_o=_o@entry=0x7f7c0c7600, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=_id@entry=100, _a=_a@entry=0x7f91ba55c8)
at gui/qt/player/player_controller.moc.cpp:966
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0x0000007f93318c84 in PlayerController::qt_metacall (this=0x7f7c0c7600, _c=QMetaObject::InvokeMetaMethod, _id=100, _a=0x7f91ba55c8) at gui/qt/player/player_controller.moc.cpp:1583
[#5](https://code.videolan.org/videolan/vlc/-/issues/5) 0x0000007f936514a0 in ?? () from /opt/vlc/lib/vlc/plugins/gui/libqt_plugin.so
}}
Instead, the restoration code should check and synchronize input change with the player to avoid trying to restore too late.