[vlc-devel] [PATCH 04/40] playlist: fix playlist_GetNodeDuration()
RĂ©mi Denis-Courmont
remi at remlab.net
Sun May 14 17:45:34 CEST 2017
- If duration is unknown (-1), treat it as zero for the sum. The error
of one microsecond per item was usually negligible. But it was
catastrophic if the total length was actually zero: we would return a
negative total.
- Do not special case input item node type. Other item types can have
children, e.g. directories.
- Remove redundant negative test.
(This does not fix the unlikely signed integer overflow if the total
length exceeds INT64_MAX.)
---
src/playlist/item.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 6f090f2899..00153fa284 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -702,19 +702,14 @@ void playlist_SendAddNotify( playlist_t *p_playlist, playlist_item_t *item )
*/
mtime_t playlist_GetNodeDuration( playlist_item_t* node )
{
- mtime_t mt_duration = 0;
+ mtime_t duration = input_item_GetDuration( node->p_input );
+ if( duration == -1 )
+ duration = 0;
- if( node->i_children != -1 )
- for( int i = 0; i < node->i_children; i++ )
- {
- 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 );
- }
+ for( int i = 0; i < node->i_children; i++ )
+ duration += playlist_GetNodeDuration( node->pp_children[i] );
- return mt_duration;
+ return duration;
}
/***************************************************************************
--
2.11.0
More information about the vlc-devel
mailing list