+/* 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 )
+ {
+ vlc_object_yield( p_input );
+ p_playlist->p_input = p_input;
+ vlc_event_manager_t * p_em = input_get_event_manager( p_input );
+ vlc_event_attach( p_em, vlc_InputStateChanged,
+ input_state_changed, p_playlist );
+ vlc_event_attach( p_em, vlc_InputSelectedStreamChanged,
+ input_selected_stream_changed, p_playlist );
+ }
+}
+
+/** Get current playing input.
+ */
+input_thread_t * playlist_CurrentInput( playlist_t * p_playlist )
+{
+ input_thread_t * p_input;
+ PL_LOCK;
+ p_input = p_playlist->p_input;
+ if( p_input ) vlc_object_yield( p_input );
+ PL_UNLOCK;
+ return p_input;
+}
+
+
+/**
+ * @}
+ */
+