[vlc-devel] [RFC PATCH] vlc_config: add macro denoting the maximum timestamp
Filip Roséen
filip at atch.se
Sun Oct 16 21:18:30 CEST 2016
This macro can be used to create a timestamp as far away in the future
as possible. Former implementations used INT64_MAX directly, meaning
that if we in the future decide to change the type of "mtime_t", we
would have to change every usage of INT64_MAX for the related
variables.
These changes simply provides a macro that everyone can use, as well
as replacing former usage of INT64_MAX with VLC_TS_MAX.
--
Disclaimer: There might be usages of INT64_MAX that I did not find when I went
out to search for usages related to this patch.
---
include/vlc_config.h | 1 +
modules/access/rtp/session.c | 2 +-
modules/demux/mp4/mp4.c | 6 +++---
src/input/clock.c | 2 +-
src/input/decoder.c | 8 ++++----
src/misc/picture_fifo.c | 2 +-
src/video_output/video_output.c | 4 ++--
src/video_output/vout_subpictures.c | 2 +-
8 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/include/vlc_config.h b/include/vlc_config.h
index 50b4887..f798eca 100644
--- a/include/vlc_config.h
+++ b/include/vlc_config.h
@@ -42,6 +42,7 @@
* XXX the numerical value is 0 because of historical reason and will change.*/
#define VLC_TS_INVALID INT64_C(0)
#define VLC_TS_0 INT64_C(1)
+#define VLC_TS_MAX INT64_MAX
#define CLOCK_FREQ INT64_C(1000000)
diff --git a/modules/access/rtp/session.c b/modules/access/rtp/session.c
index f514b63..99e7dc9 100644
--- a/modules/access/rtp/session.c
+++ b/modules/access/rtp/session.c
@@ -396,7 +396,7 @@ bool rtp_dequeue (demux_t *demux, const rtp_session_t *session,
mtime_t now = mdate ();
bool pending = false;
- *deadlinep = INT64_MAX;
+ *deadlinep = VLC_TS_MAX;
for (unsigned i = 0, max = session->srcc; i < max; i++)
{
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index e559e42..cca57b0 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1079,7 +1079,7 @@ static int Demux( demux_t *p_demux )
/* Find next track matching contiguous data */
mp4_track_t *tk = NULL;
uint64_t i_candidate_pos = UINT64_MAX;
- mtime_t i_candidate_dts = INT64_MAX;
+ mtime_t i_candidate_dts = VLC_TS_MAX;
for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
{
mp4_track_t *tk_tmp = &p_sys->track[i_track];
@@ -1191,7 +1191,7 @@ static int Demux( demux_t *p_demux )
end:
if ( b_data_sent )
{
- p_sys->i_pcr = INT64_MAX;
+ p_sys->i_pcr = VLC_TS_MAX;
for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
{
mp4_track_t *tk = &p_sys->track[i_track];
@@ -5152,7 +5152,7 @@ static int DemuxAsLeaf( demux_t *p_demux )
/* Get current time */
mtime_t i_lowest_dts = VLC_TS_INVALID;
- mtime_t i_lowest_time = INT64_MAX;
+ mtime_t i_lowest_time = VLC_TS_MAX;
for( unsigned int i_track = 0; i_track < p_sys->i_tracks; i_track++ )
{
const mp4_track_t *p_track = &p_sys->track[i_track];
diff --git a/src/input/clock.c b/src/input/clock.c
index e1cc0fc..adc503c 100644
--- a/src/input/clock.c
+++ b/src/input/clock.c
@@ -448,7 +448,7 @@ int input_clock_ConvertTS( vlc_object_t *p_object, input_clock_t *cl,
vlc_mutex_unlock( &cl->lock );
/* Check ts validity */
- if (i_ts_bound != INT64_MAX && *pi_ts0 > VLC_TS_INVALID) {
+ if (i_ts_bound != VLC_TS_MAX && *pi_ts0 > VLC_TS_INVALID) {
if (*pi_ts0 >= mdate() + i_ts_delay + i_ts_buffering + i_ts_bound) {
msg_Err(p_object,
"Timestamp conversion failed (delay %"PRId64", buffering "
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 2fbadb0..cd4da41 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -573,7 +573,7 @@ static mtime_t DecoderGetDisplayDate( decoder_t *p_dec, mtime_t i_ts )
if( !p_owner->p_clock || i_ts <= VLC_TS_INVALID )
return i_ts;
- if( input_clock_ConvertTS( VLC_OBJECT(p_dec), p_owner->p_clock, NULL, &i_ts, NULL, INT64_MAX ) ) {
+ if( input_clock_ConvertTS( VLC_OBJECT(p_dec), p_owner->p_clock, NULL, &i_ts, NULL, VLC_TS_MAX ) ) {
msg_Err(p_dec, "Could not get display date for timestamp %"PRId64"", i_ts);
return VLC_TS_INVALID;
}
@@ -729,7 +729,7 @@ static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
*pi_ts0 += i_es_delay;
if( pi_ts1 && *pi_ts1 > VLC_TS_INVALID )
*pi_ts1 += i_es_delay;
- if( i_ts_bound != INT64_MAX )
+ if( i_ts_bound != VLC_TS_MAX )
i_ts_bound += i_es_delay;
if( input_clock_ConvertTS( VLC_OBJECT(p_dec), p_clock, &i_rate, pi_ts0, pi_ts1, i_ts_bound ) ) {
if( pi_ts1 != NULL )
@@ -775,7 +775,7 @@ static int DecoderPlaySout( decoder_t *p_dec, block_t *p_sout_block )
DecoderWaitUnblock( p_dec );
DecoderFixTs( p_dec, &p_sout_block->i_dts, &p_sout_block->i_pts,
- &p_sout_block->i_length, NULL, INT64_MAX );
+ &p_sout_block->i_length, NULL, VLC_TS_MAX );
vlc_mutex_unlock( &p_owner->lock );
@@ -1325,7 +1325,7 @@ static void DecoderPlaySpu( decoder_t *p_dec, subpicture_t *p_subpic )
DecoderWaitUnblock( p_dec );
DecoderFixTs( p_dec, &p_subpic->i_start, &p_subpic->i_stop, NULL,
- NULL, INT64_MAX );
+ NULL, VLC_TS_MAX );
vlc_mutex_unlock( &p_owner->lock );
if( p_subpic->i_start <= VLC_TS_INVALID
diff --git a/src/misc/picture_fifo.c b/src/misc/picture_fifo.c
index 5e99992..12df3da 100644
--- a/src/misc/picture_fifo.c
+++ b/src/misc/picture_fifo.c
@@ -141,7 +141,7 @@ void picture_fifo_OffsetDate(picture_fifo_t *fifo, mtime_t delta)
}
void picture_fifo_Delete(picture_fifo_t *fifo)
{
- picture_fifo_Flush(fifo, INT64_MAX, true);
+ picture_fifo_Flush(fifo, VLC_TS_MAX, true);
vlc_mutex_destroy(&fifo->lock);
free(fifo);
}
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 7994bec..923bd3b 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1172,7 +1172,7 @@ static void ThreadFlush(vout_thread_t *vout, bool below, mtime_t date)
static void ThreadReset(vout_thread_t *vout)
{
- ThreadFlush(vout, true, INT64_MAX);
+ ThreadFlush(vout, true, VLC_TS_MAX);
if (vout->p->decoder_pool) {
unsigned count, leaks;
@@ -1374,7 +1374,7 @@ static void ThreadStop(vout_thread_t *vout, vout_display_state_t *state)
/* Destroy translation tables */
if (vout->p->display.vd) {
if (vout->p->decoder_pool) {
- ThreadFlush(vout, true, INT64_MAX);
+ ThreadFlush(vout, true, VLC_TS_MAX);
vout_EndWrapper(vout);
}
vout_CloseWrapper(vout, state);
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index cd423cb..4a33852 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -614,7 +614,7 @@ static void SpuSelectSubpictures(spu_t *spu,
if (start_date < sys->last_sort_date)
start_date = sys->last_sort_date;
if (start_date <= 0)
- start_date = INT64_MAX;
+ start_date = VLC_TS_MAX;
/* Select pictures to be displayed */
for (int index = 0; index < available_count; index++) {
--
2.10.0
More information about the vlc-devel
mailing list