[vlc-devel] [PATCH 1/5] vlc_input_item: add a define for the unknown duration
Steve Lhomme
robux4 at ycbcr.xyz
Sat Jun 23 09:26:13 CEST 2018
input_item_GetDuration() is used to read the value given here and should
return 0 (rather than VLC_TS_INVALID) when it's unknown (it's currently the
same value).
---
include/vlc_input_item.h | 8 +++++---
src/input/item.c | 2 ++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 7a4a9cb506e..62c1a5ce190 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -107,6 +107,8 @@ struct input_item_t
preparsing.*/
};
+#define INPUT_UNKNOWN_DURATION ((vlc_tick_t) -1)
+
enum input_item_type_e
{
ITEM_TYPE_UNKNOWN,
@@ -335,10 +337,10 @@ VLC_API input_item_t * input_item_NewExt( const char *psz_uri,
enum input_item_net_type i_net ) VLC_USED;
#define input_item_New( psz_uri, psz_name ) \
- input_item_NewExt( psz_uri, psz_name, VLC_TS_INVALID, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN )
+ input_item_NewExt( psz_uri, psz_name, INPUT_UNKNOWN_DURATION, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN )
#define input_item_NewCard( psz_uri, psz_name ) \
- input_item_NewExt( psz_uri, psz_name, VLC_TS_INVALID, ITEM_TYPE_CARD, ITEM_LOCAL )
+ input_item_NewExt( psz_uri, psz_name, INPUT_UNKNOWN_DURATION, ITEM_TYPE_CARD, ITEM_LOCAL )
#define input_item_NewDisc( psz_uri, psz_name, i_duration ) \
input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_DISC, ITEM_LOCAL )
@@ -347,7 +349,7 @@ VLC_API input_item_t * input_item_NewExt( const char *psz_uri,
input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_STREAM, ITEM_NET )
#define input_item_NewDirectory( psz_uri, psz_name, i_net ) \
- input_item_NewExt( psz_uri, psz_name, VLC_TS_INVALID, ITEM_TYPE_DIRECTORY, i_net )
+ input_item_NewExt( psz_uri, psz_name, INPUT_UNKNOWN_DURATION, ITEM_TYPE_DIRECTORY, i_net )
#define input_item_NewFile( psz_uri, psz_name, i_duration, i_net ) \
input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_FILE, i_net )
diff --git a/src/input/item.c b/src/input/item.c
index 6789f73caa5..4e52d9fdd06 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -403,6 +403,8 @@ vlc_tick_t input_item_GetDuration( input_item_t *p_i )
vlc_tick_t i_duration = p_i->i_duration;
vlc_mutex_unlock( &p_i->lock );
+ if (i_duration == INPUT_UNKNOWN_DURATION)
+ return 0;
return i_duration;
}
--
2.17.0
More information about the vlc-devel
mailing list