[vlc-devel] commit: Added input_item_ReplaceInfos() and input_item_MergeInfos. ( Laurent Aimar )

git version control git at videolan.org
Fri Feb 5 23:36:21 CET 2010


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Fri Feb  5 22:46:36 2010 +0100| [b14d7afaffb17b5aac49207b2ca12e9367f4aaf5] | committer: Laurent Aimar 

Added input_item_ReplaceInfos() and input_item_MergeInfos.

They will allow to minimize the number of events sent.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b14d7afaffb17b5aac49207b2ca12e9367f4aaf5
---

 include/vlc_input_item.h |    2 ++
 src/input/item.c         |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index e9940f6..70fda32 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -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.
diff --git a/src/input/item.c b/src/input/item.c
index 3ce82c6..e8e087d 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -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 )




More information about the vlc-devel mailing list