}
#endif
+ playlist_t *p_playlist = priv->p_playlist;
/* Remove all services discovery */
msg_Dbg( p_libvlc, "removing all services discovery tasks" );
- playlist_ServicesDiscoveryKillAll( priv->p_playlist );
+ playlist_ServicesDiscoveryKillAll( p_playlist );
/* Free playlist */
+ /* Any thread still running must not assume pl_Yield() succeeds. */
msg_Dbg( p_libvlc, "removing playlist" );
- vlc_object_kill( priv->p_playlist );
- vlc_thread_join( priv->p_playlist );
- vlc_object_release( priv->p_playlist );
+ priv->p_playlist = NULL;
+ vlc_object_kill( p_playlist ); /* <-- memory barrier for pl_Yield() */
+ vlc_thread_join( p_playlist );
+ vlc_object_release( p_playlist );
/* Free interaction */
msg_Dbg( p_libvlc, "removing interaction" );
playlist_t *__pl_Yield( vlc_object_t *p_this )
{
- playlist_t *pl = libvlc_priv (p_this->p_libvlc)->p_playlist;
- /* Objects that are destroyed _after_ the playlist cannot use pl_Yield() */
- assert (p_this->i_object_type != VLC_OBJECT_VOUT);
- assert (p_this->i_object_type != VLC_OBJECT_ANNOUNCE);
- assert ((void *)p_this != libvlc_priv (p_this->p_libvlc)->p_interaction);
+ playlist_t *pl;
- assert( pl != NULL );
- vlc_object_yield( pl );
+ barrier ();
+ pl = libvlc_priv (p_this->p_libvlc)->p_playlist;
+ if (pl)
+ vlc_object_yield (pl);
return pl;
}
if( p_playlist->p_fetcher )
vlc_object_release( p_playlist->p_fetcher );
-#ifndef NDEBUG
- libvlc_priv (p_this->p_libvlc)->p_playlist = NULL; /* pl_Yield() will fail */
-#endif
}
/* Destroy remaining objects */