[vlc-devel] commit: playlist: only install input item event callbacks on items under category root ( Jakob Leben )

git version control git at videolan.org
Sun Jan 31 17:29:03 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Sun Jan 31 12:30:53 2010 +0100| [22b2b54f1fae6b33583e588b5afc167ffdd99e11] | committer: Jakob Leben 

playlist: only install input item event callbacks on items under category root

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

 include/vlc_playlist.h           |    1 +
 src/playlist/item.c              |   19 +++++++++++--------
 src/playlist/playlist_internal.h |    3 ++-
 src/playlist/tree.c              |    2 +-
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index bcd645f..26ed795 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -153,6 +153,7 @@ struct playlist_item_t
     int                    i_id;        /**< Playlist item specific id */
     uint8_t                i_flags;     /**< Flags */
     playlist_t            *p_playlist;  /**< Parent playlist */
+    bool                   b_input_item_observer;
 };
 
 #define PLAYLIST_SAVE_FLAG      0x0001    /**< Must it be saved */
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 9faed0d..0dc9f10 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -171,7 +171,7 @@ static void uninstall_input_item_observer( playlist_item_t * p_item )
  * Playlist item creation
  *****************************************************************************/
 playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
-                                              input_item_t *p_input )
+                                              input_item_t *p_input, bool install_observer )
 {
     playlist_item_t* p_item = malloc( sizeof( playlist_item_t ) );
     if( !p_item )
@@ -189,8 +189,10 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
     p_item->pp_children = NULL;
     p_item->i_flags = 0;
     p_item->p_playlist = p_playlist;
+    p_item->b_input_item_observer = install_observer;
 
-    install_input_item_observer( p_item );
+    if( install_observer )
+        install_input_item_observer( p_item );
 
     return p_item;
 }
@@ -218,7 +220,8 @@ int playlist_ItemRelease( playlist_item_t *p_item )
      * Most of the modules does that.
      *
      * Who wants to add proper memory management? */
-    uninstall_input_item_observer( p_item );
+    if( p_item->b_input_item_observer )
+        uninstall_input_item_observer( p_item );
     ARRAY_APPEND( pl_priv(p_playlist)->items_to_delete, p_item);
     return VLC_SUCCESS;
 }
@@ -423,14 +426,14 @@ int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
     PL_LOCK_IF( !b_locked );
 
     /* Add to ONELEVEL */
-    p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );
+    p_item_one = playlist_ItemNewFromInput( p_playlist, p_input, false );
     if( p_item_one == NULL ) return VLC_ENOMEM;
     AddItem( p_playlist, p_item_one,
              b_playlist ? p_playlist->p_local_onelevel :
                           p_playlist->p_ml_onelevel , i_mode, i_pos );
 
     /* Add to CATEGORY */
-    p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
+    p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input, true );
     if( p_item_cat == NULL ) return VLC_ENOMEM;
     AddItem( p_playlist, p_item_cat,
              b_playlist ? p_playlist->p_local_category :
@@ -475,13 +478,13 @@ int playlist_BothAddInput( playlist_t *p_playlist,
     PL_LOCK_IF( !b_locked );
 
     /* Add to category */
-    p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
+    p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input, true );
     if( p_item_cat == NULL ) return VLC_ENOMEM;
     AddItem( p_playlist, p_item_cat, p_direct_parent, i_mode, i_pos );
 
     /* Add to onelevel */
     /** \todo make a faster case for ml import */
-    p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );
+    p_item_one = playlist_ItemNewFromInput( p_playlist, p_input, false );
     if( p_item_one == NULL ) return VLC_ENOMEM;
 
     p_up = p_direct_parent;
@@ -536,7 +539,7 @@ playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
         return NULL;
     PL_LOCK_IF( !b_locked );
 
-    p_item = playlist_ItemNewFromInput( p_playlist, p_input );
+    p_item = playlist_ItemNewFromInput( p_playlist, p_input, true );
     if( p_item == NULL ) return NULL;
     AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );
 
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 7e07a80..6a46b49 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -109,7 +109,8 @@ void pl_Deactivate (libvlc_int_t *);
 
 /* */
 playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
-                                              input_item_t *p_input );
+                                            input_item_t *p_input,
+                                            bool install_observer );
 
 /* Engine */
 playlist_item_t * get_current_status_item( playlist_t * p_playlist);
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index 9937d0d..2ab2bac 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -69,7 +69,7 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
         p_new_input = input_item_NewWithType( VLC_OBJECT(p_playlist), NULL,
                                         psz_name, 0, NULL, 0, -1, ITEM_TYPE_NODE );
     p_item = playlist_ItemNewFromInput( p_playlist,
-                                        p_input ? p_input : p_new_input );
+                                        p_input ? p_input : p_new_input, p_input == NULL );
     if( p_new_input )
         vlc_gc_decref( p_new_input );
 




More information about the vlc-devel mailing list