[vlc-commits] playlist: move i_nb_played to playlist item, not the input item

Rémi Denis-Courmont git at videolan.org
Sat Aug 16 12:48:27 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 16 13:04:33 2014 +0300| [9e7dd0b49fe1d7858c344939072bbe9555f800c2] | committer: Rémi Denis-Courmont

playlist: move i_nb_played to playlist item, not the input item

This is accessed with the playlock lock anyway.

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

 include/vlc_input_item.h    |    1 -
 include/vlc_playlist.h      |    1 +
 modules/lua/libs/playlist.c |    2 +-
 src/input/item.c            |    1 -
 src/playlist/item.c         |    1 +
 src/playlist/thread.c       |    2 +-
 src/playlist/tree.c         |    4 ++--
 7 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index a701044..1bfb2f9 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -74,7 +74,6 @@ struct input_item_t
     es_format_t **es;                /**< Es formats */
 
     input_stats_t *p_stats;          /**< Statistics */
-    int           i_nb_played;       /**< Number of times played */
 
     vlc_meta_t *p_meta;
 
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 2c64a7c..384221b 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -138,6 +138,7 @@ struct playlist_item_t
     playlist_item_t      **pp_children; /**< Children nodes/items */
     playlist_item_t       *p_parent;    /**< Item parent */
     int                    i_children;  /**< Number of children, -1 if not a node */
+    unsigned               i_nb_played; /**< Times played */
 
     int                    i_id;        /**< Playlist item specific id */
     uint8_t                i_flags;     /**< Flags \see playlist_item_flags_e */
diff --git a/modules/lua/libs/playlist.c b/modules/lua/libs/playlist.c
index ab4faf1..8bcc8a7 100644
--- a/modules/lua/libs/playlist.c
+++ b/modules/lua/libs/playlist.c
@@ -233,7 +233,7 @@ static void push_playlist_item( lua_State *L, playlist_item_t *p_item )
         else
             lua_pushnumber( L, ((double)p_input->i_duration)*1e-6 );
         lua_setfield( L, -2, "duration" );
-        lua_pushinteger( L, p_input->i_nb_played );
+        lua_pushinteger( L, p_item->i_nb_played );
         lua_setfield( L, -2, "nb_played" );
         luaopen_input_item( L, p_input );
         /* TODO: add (optional) info categories, meta, options, es */
diff --git a/src/input/item.c b/src/input/item.c
index 4f0b053..40b854e 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -851,7 +851,6 @@ input_item_NewWithType( const char *psz_uri, const char *psz_name,
     TAB_INIT( p_input->i_categories, p_input->pp_categories );
     TAB_INIT( p_input->i_es, p_input->es );
     p_input->p_stats = NULL;
-    p_input->i_nb_played = 0;
     p_input->p_meta = NULL;
     TAB_INIT( p_input->i_epg, p_input->pp_epg );
 
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 9281481..eafc79e 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -237,6 +237,7 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
     p_item->p_parent = NULL;
     p_item->i_children = -1;
     p_item->pp_children = NULL;
+    p_item->i_nb_played = 0;
     p_item->i_flags = 0;
     p_item->p_playlist = p_playlist;
 
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 8130056..0e51f60 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -201,7 +201,7 @@ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
 
     msg_Dbg( p_playlist, "creating new input thread" );
 
-    p_input->i_nb_played++;
+    p_item->i_nb_played++;
     set_current_status_item( p_playlist, p_item );
 
     p_sys->status.i_status = PLAYLIST_RUNNING;
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index eca12b1..9fe3c24 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -323,7 +323,7 @@ playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
         {
             if( b_ena && p_next->i_flags & PLAYLIST_DBL_FLAG )
                 b_ena_ok = false;
-            if( b_unplayed && p_next->p_input->i_nb_played != 0 )
+            if( b_unplayed && p_next->i_nb_played != 0 )
                 b_unplayed_ok = false;
             if( b_ena_ok && b_unplayed_ok ) break;
         }
@@ -364,7 +364,7 @@ playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist,
         {
             if( b_ena && p_prev->i_flags & PLAYLIST_DBL_FLAG )
                 b_ena_ok = false;
-            if( b_unplayed && p_prev->p_input->i_nb_played != 0 )
+            if( b_unplayed && p_prev->i_nb_played != 0 )
                 b_unplayed_ok = false;
             if( b_ena_ok && b_unplayed_ok ) break;
         }



More information about the vlc-commits mailing list