playlist: move i_nb_played to playlist item, not the input item
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 16 Aug 2014 10:04:33 +0000 (13:04 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 16 Aug 2014 10:05:39 +0000 (13:05 +0300)
This is accessed with the playlock lock anyway.

include/vlc_input_item.h
include/vlc_playlist.h
modules/lua/libs/playlist.c
src/input/item.c
src/playlist/item.c
src/playlist/thread.c
src/playlist/tree.c

index a701044..1bfb2f9 100644 (file)
@@ -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;
 
index 2c64a7c..384221b 100644 (file)
@@ -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 */
index ab4faf1..8bcc8a7 100644 (file)
@@ -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 */
index 4f0b053..40b854e 100644 (file)
@@ -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 );
 
index 9281481..eafc79e 100644 (file)
@@ -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;
 
index 8130056..0e51f60 100644 (file)
@@ -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;
index eca12b1..9fe3c24 100644 (file)
@@ -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;
         }