]> git.sesse.net Git - vlc/blobdiff - src/playlist/item.c
libvlccore: is a pure C library - don't use the C++ linker
[vlc] / src / playlist / item.c
index 15454014ef652aeb124cb5d1fbc359140578e586..20ee6f2e9b4309319b5578cfbbb3541e954b222b 100644 (file)
@@ -106,24 +106,48 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
 
 }
 
+/*****************************************************************************
+ * An input item's meta or duration has changed (Event Callback)
+ *****************************************************************************/
+static void input_item_changed( const vlc_event_t * p_event,
+                                void * user_data )
+{
+    (void)p_event;
+    playlist_item_t * p_item = user_data;
+    var_SetInteger( p_item->p_playlist, "item-change", p_item->i_id );
+}
+
 /*****************************************************************************
  * Listen to vlc_InputItemAddSubItem event
  *****************************************************************************/
 static void install_input_item_observer( playlist_item_t * p_item )
 {
-    vlc_event_attach( &p_item->p_input->event_manager,
-                      vlc_InputItemSubItemAdded,
-                      input_item_subitem_added,
-                      p_item );
+    vlc_event_manager_t * p_em = &p_item->p_input->event_manager;
+    vlc_event_attach( p_em, vlc_InputItemSubItemAdded,
+                      input_item_subitem_added, p_item );
+    vlc_event_attach( p_em, vlc_InputItemDurationChanged,
+                      input_item_changed, p_item );
+    vlc_event_attach( p_em, vlc_InputItemMetaChanged,
+                      input_item_changed, p_item );
+    vlc_event_attach( p_em, vlc_InputItemNameChanged,
+                      input_item_changed, p_item );
+    vlc_event_attach( p_em, vlc_InputItemInfoChanged,
+                      input_item_changed, p_item );
 }
 
 static void uninstall_input_item_observer( playlist_item_t * p_item )
 {
-    vlc_event_detach( &p_item->p_input->event_manager,
-                      vlc_InputItemSubItemAdded,
-                      input_item_subitem_added,
-                      p_item );
-
+    vlc_event_manager_t * p_em = &p_item->p_input->event_manager;
+    vlc_event_detach( p_em, vlc_InputItemSubItemAdded,
+                      input_item_subitem_added, p_item );
+    vlc_event_detach( p_em, vlc_InputItemMetaChanged,
+                      input_item_changed, p_item );
+    vlc_event_detach( p_em, vlc_InputItemDurationChanged,
+                      input_item_changed, p_item );
+    vlc_event_detach( p_em, vlc_InputItemNameChanged,
+                      input_item_changed, p_item );
+    vlc_event_detach( p_em, vlc_InputItemInfoChanged,
+                      input_item_changed, p_item );
 }
 
 /*****************************************************************************
@@ -351,7 +375,7 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
 
     i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist,
                                b_locked );
-    int i_id = i_ret == VLC_SUCCESS ? p_input->i_id : -1;
+    int i_id = (i_ret == VLC_SUCCESS) ? p_input->i_id : -1;
 
     vlc_gc_decref( p_input );
 
@@ -572,7 +596,7 @@ playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist,
                              p_playlist->p_root_onelevel, false );
         }
         p_playlist->b_reset_currently_playing = true;
-        vlc_cond_signal( &p_playlist->object_wait );
+        vlc_object_signal_unlocked( p_playlist );
         var_SetInteger( p_playlist, "item-change", p_item_in_category->
                                                         p_input->i_id );
         if( !b_locked ) PL_UNLOCK;
@@ -700,7 +724,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
     else
         i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
     p_playlist->b_reset_currently_playing = true;
-    vlc_cond_signal( &p_playlist->object_wait );
+    vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
     return i_ret;
 }
 
@@ -726,7 +750,7 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
     val.p_address = p_add;
     p_playlist->b_reset_currently_playing = true;
     if( b_signal )
-        vlc_cond_signal( &p_playlist->object_wait );
+        vlc_object_signal_maybe( p_playlist );
     var_Set( p_playlist, "item-append", val );
     free( p_add );
 }
@@ -784,7 +808,7 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
         if( p_playlist->p_input )
             input_StopThread( p_playlist->p_input );
         p_playlist->request.i_status = PLAYLIST_RUNNING;
-        vlc_cond_signal( &p_playlist->object_wait );
+        vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
     }
     /* Preparse if PREPARSE or SPREPARSE & not enough meta */
     char *psz_artist = input_item_GetArtist( p_item_cat->p_input );
@@ -866,7 +890,7 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
             p_playlist->request.b_request = true;
             p_playlist->request.p_item = NULL;
             msg_Info( p_playlist, "stopping playback" );
-            vlc_cond_signal( &p_playlist->object_wait );
+            vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
         }
         b_delay_deletion = true;
     }