- while( ( p_obj = vlc_object_find( p_playlist->p_libvlc, VLC_OBJECT_VOUT,
- FIND_CHILD ) ) )
- {
- if( p_obj->p_parent != VLC_OBJECT(p_playlist->p_libvlc) )
- {
- vlc_object_release( p_obj );
- break;
- }
- msg_Dbg( p_playlist, "garbage collector destroying 1 vout" );
- vlc_object_detach( p_obj );
- vlc_object_release( p_obj );
- vout_Destroy( (vout_thread_t *)p_obj );
- }
- while( ( p_obj = vlc_object_find( p_playlist, VLC_OBJECT_SOUT,
- FIND_CHILD ) ) )
+ p_playlist->b_cant_sleep = false;
+ vlc_mutex_unlock( &p_playlist->gc_lock );
+}
+
+/* Input Callback */
+static void input_state_changed( const vlc_event_t * event, void * data )
+{
+ (void)event;
+ playlist_t * p_playlist = data;
+ playlist_Signal( p_playlist );
+}
+
+/* Input Callback */
+static void input_selected_stream_changed( const vlc_event_t * event, void * data )
+{
+ (void)event;
+ playlist_t * p_playlist = data;
+ PL_LOCK;
+ p_playlist->gc_date = mdate();
+ vlc_object_signal_unlocked( p_playlist );
+ PL_UNLOCK;
+}
+
+/* Internals */
+void playlist_release_current_input( playlist_t * p_playlist )
+{
+ vlc_assert_locked( &(vlc_internals(p_playlist)->lock) );
+
+ if( !p_playlist->p_input ) return;
+
+ input_thread_t * p_input = p_playlist->p_input;
+ vlc_event_manager_t * p_em = input_get_event_manager( p_input );
+
+ vlc_event_detach( p_em, vlc_InputStateChanged,
+ input_state_changed, p_playlist );
+ vlc_event_detach( p_em, vlc_InputSelectedStreamChanged,
+ input_selected_stream_changed, p_playlist );
+ p_playlist->p_input = NULL;
+
+ /* Release the playlist lock, because we may get stuck
+ * in vlc_object_release() for some time. */
+ PL_UNLOCK;
+ vlc_object_release( p_input );
+ PL_LOCK;
+}
+
+void playlist_set_current_input(
+ playlist_t * p_playlist, input_thread_t * p_input )
+{
+ vlc_assert_locked( &(vlc_internals(p_playlist)->lock) );
+
+ playlist_release_current_input( p_playlist );
+
+ if( p_input )