]> git.sesse.net Git - vlc/commitdiff
playlist: Recurse on ITEM_TYPE_NODE when calculating the duration
authorWieland Hoffmann <themineo@gmail.com>
Sat, 11 Jan 2014 14:10:16 +0000 (14:10 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 12 Jan 2014 17:28:01 +0000 (18:28 +0100)
When adding an item X whose underlying input_item_t's i_type is
ITEM_TYPE_NODE (like a folder), we need to call playlist_GetNodeDuration
on X again for the duration of X to be the sum of the durations of X's
children.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
src/playlist/item.c

index b27389a160df7a2edc798a65807b0a1fe2ec9e7d..1aa5d56d02628a6223ae09175d6bfb84bf8099f9 100644 (file)
@@ -733,7 +733,13 @@ mtime_t playlist_GetNodeDuration( playlist_item_t* node )
 
     if( node->i_children != -1 )
         for( int i = 0; i < node->i_children; i++ )
-            mt_duration += input_item_GetDuration( node->pp_children[i]->p_input );
+        {
+            input_item_t* p_input = node->pp_children[i]->p_input;
+            if ( p_input->i_type == ITEM_TYPE_NODE )
+                mt_duration += playlist_GetNodeDuration( node->pp_children[i] );
+            else
+                mt_duration += input_item_GetDuration( p_input );
+        }
 
     return mt_duration;
 }