]> git.sesse.net Git - vlc/commitdiff
Added input_item_ReplaceInfos() and input_item_MergeInfos.
authorLaurent Aimar <fenrir@videolan.org>
Fri, 5 Feb 2010 21:46:36 +0000 (22:46 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 5 Feb 2010 22:23:12 +0000 (23:23 +0100)
They will allow to minimize the number of events sent.

include/vlc_input_item.h
src/input/item.c

index e9940f6fbbfef50ef29a2cb07f9378ce2f124695..70fda328cf96ea24fc712c68dcf16d9099b61a31 100644 (file)
@@ -238,6 +238,8 @@ INPUT_META(TrackID)
 VLC_EXPORT( char *, input_item_GetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
 VLC_EXPORT( int, input_item_AddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) LIBVLC_FORMAT( 4, 5 ) );
 VLC_EXPORT( int, input_item_DelInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name ) );
+VLC_EXPORT( void, input_item_ReplaceInfos, ( input_item_t *, info_category_t * ) );
+VLC_EXPORT( void, input_item_MergeInfos, ( input_item_t *, info_category_t * ) );
 
 /**
  * This function creates a new input_item_t with the provided informations.
index 3ce82c63dba832cbeb0c8ee363ed44799b31fe50..e8e087df59b73454429610e59fff57857f69146b 100644 (file)
@@ -625,7 +625,6 @@ int input_item_DelInfo( input_item_t *p_i,
                         const char *psz_cat,
                         const char *psz_name )
 {
-
     vlc_mutex_lock( &p_i->lock );
     int i_cat;
     info_category_t *p_cat = InputItemFindCat( p_i, &i_cat, psz_cat );
@@ -660,6 +659,51 @@ int input_item_DelInfo( input_item_t *p_i,
 
     return VLC_SUCCESS;
 }
+void input_item_ReplaceInfos( input_item_t *p_item, info_category_t *p_cat )
+{
+    vlc_mutex_lock( &p_item->lock );
+    int i_cat;
+    info_category_t *p_old = InputItemFindCat( p_item, &i_cat, p_cat->psz_name );
+    if( p_old )
+    {
+        info_category_Delete( p_old );
+        p_item->pp_categories[i_cat] = p_cat;
+    }
+    else
+    {
+        INSERT_ELEM( p_item->pp_categories, p_item->i_categories, p_item->i_categories,
+                     p_cat );
+    }
+    vlc_mutex_unlock( &p_item->lock );
+
+
+    vlc_event_t event;
+    event.type = vlc_InputItemInfoChanged;
+    vlc_event_send( &p_item->event_manager, &event );
+}
+void input_item_MergeInfos( input_item_t *p_item, info_category_t *p_cat )
+{
+    vlc_mutex_lock( &p_item->lock );
+    info_category_t *p_old = InputItemFindCat( p_item, NULL, p_cat->psz_name );
+    if( p_old )
+    {
+        for( int i = 0; i < p_cat->i_infos; i++ )
+            info_category_ReplaceInfo( p_old, p_cat->pp_infos[i] );
+        TAB_CLEAN( p_cat->i_infos, p_cat->pp_infos );
+        info_category_Delete( p_cat );
+    }
+    else
+    {
+        INSERT_ELEM( p_item->pp_categories, p_item->i_categories, p_item->i_categories,
+                     p_cat );
+    }
+    vlc_mutex_unlock( &p_item->lock );
+
+
+    vlc_event_t event;
+    event.type = vlc_InputItemInfoChanged;
+    vlc_event_send( &p_item->event_manager, &event );
+}
 
 #define EPG_DEBUG
 void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_update )