[vlc-commits] playlist: Recurse on ITEM_TYPE_NODE when calculating the duration

Wieland Hoffmann git at videolan.org
Sun Jan 19 00:49:28 CET 2014


vlc/vlc-2.1 | branch: master | Wieland Hoffmann <themineo at gmail.com> | Sat Jan 11 14:10:16 2014 +0000| [6ed4796b47ea3d7a83acca0c039fde4eb8f55d4d] | committer: Jean-Baptiste Kempf

playlist: Recurse on ITEM_TYPE_NODE when calculating the duration

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 at videolan.org>
(cherry picked from commit 8eae542ad94652396035ee70920ca2ab107033ed)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 src/playlist/item.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/playlist/item.c b/src/playlist/item.c
index e902063..c6113b1 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -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;
 }



More information about the vlc-commits mailing list