Summary
Setting mediaList = nil while a media player is attached can stop active playback that the rebuilt list player is supposed to keep running.
Location: Sources/SwiftVLC/Playlist/MediaListPlayer.swift:187-207
Details
rebuildNativePlayer binds the same native media player to the new list player, then offloads stop + release of the old one without detaching that shared media player first:
if let mediaPlayer = _mediaPlayer {
libvlc_media_list_player_set_media_player(replacement, mediaPlayer.pointer)
}
...
DispatchQueue.global(qos: .utility).async {
libvlc_media_list_player_stop_async(oldPointer)
libvlc_media_list_player_release(oldPointer)
}
libvlc_media_list_player_stop_async calls vlc_player_Stop on the underlying media player (media_player.c), and that player is shared with the replacement. So the old handle stops the very player the rebuilt list player just adopted. Reachability: the mediaList = nil setter calls rebuildNativePlayer with _mediaPlayer still set (set mediaPlayer first, then clear mediaList). Refcounting prevents a use-after-free, so the impact is a playback glitch, not a crash.
Suggested fix
When the media player is shared with the replacement, do not call stop_async on the old handle. Detach the old list player's media list (libvlc_media_list_player_set_media_list(old, nil) is not allowed since libVLC asserts non-null, so just skip the stop) and only release it.
Summary
Setting
mediaList = nilwhile a media player is attached can stop active playback that the rebuilt list player is supposed to keep running.Location:
Sources/SwiftVLC/Playlist/MediaListPlayer.swift:187-207Details
rebuildNativePlayerbinds the same native media player to the new list player, then offloads stop + release of the old one without detaching that shared media player first:libvlc_media_list_player_stop_asynccallsvlc_player_Stopon the underlying media player (media_player.c), and that player is shared with the replacement. So the old handle stops the very player the rebuilt list player just adopted. Reachability: themediaList = nilsetter callsrebuildNativePlayerwith_mediaPlayerstill set (setmediaPlayerfirst, then clearmediaList). Refcounting prevents a use-after-free, so the impact is a playback glitch, not a crash.Suggested fix
When the media player is shared with the replacement, do not call
stop_asyncon the old handle. Detach the old list player's media list (libvlc_media_list_player_set_media_list(old, nil)is not allowed since libVLC asserts non-null, so just skip the stop) and only release it.