mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
seqnum: Never return a seqnum of 0, reset GST_SEQNUM_INVALID
Various plugins use the value of '0' as an invalid seqnum value (qtdemux for matching duplicated seek events, for example). Make that behaviour explicit, create a GST_SEQNUM_INVALID value, and ensure gst_util_seqnum_next never returns it.
This commit is contained in:
parent
250d3e7284
commit
6adb6b478f
2 changed files with 13 additions and 3 deletions
|
@ -770,15 +770,23 @@ gst_util_uint64_scale_int_ceil (guint64 val, gint num, gint denom)
|
||||||
* on a segment-done message to be the same as that of the last seek event, to
|
* on a segment-done message to be the same as that of the last seek event, to
|
||||||
* indicate that event and the message correspond to the same segment.
|
* indicate that event and the message correspond to the same segment.
|
||||||
*
|
*
|
||||||
|
* This function never returns GST_SEQNUM_INVALID (which is 0).
|
||||||
|
*
|
||||||
* Returns: A constantly incrementing 32-bit unsigned integer, which might
|
* Returns: A constantly incrementing 32-bit unsigned integer, which might
|
||||||
* overflow back to 0 at some point. Use gst_util_seqnum_compare() to make sure
|
* overflow at some point. Use gst_util_seqnum_compare() to make sure
|
||||||
* you handle wraparound correctly.
|
* you handle wraparound correctly.
|
||||||
*/
|
*/
|
||||||
guint32
|
guint32
|
||||||
gst_util_seqnum_next (void)
|
gst_util_seqnum_next (void)
|
||||||
{
|
{
|
||||||
static gint counter = 0;
|
static gint counter = 1;
|
||||||
return g_atomic_int_add (&counter, 1);
|
gint ret = g_atomic_int_add (&counter, 1);
|
||||||
|
|
||||||
|
/* Make sure we don't return 0 */
|
||||||
|
if (G_UNLIKELY (ret == GST_SEQNUM_INVALID))
|
||||||
|
ret = g_atomic_int_add (&counter, 1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -96,6 +96,8 @@ guint64 gst_util_uint64_scale_int_round (guint64 val, gint num, gint den
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
guint64 gst_util_uint64_scale_int_ceil (guint64 val, gint num, gint denom);
|
guint64 gst_util_uint64_scale_int_ceil (guint64 val, gint num, gint denom);
|
||||||
|
|
||||||
|
#define GST_SEQNUM_INVALID (0)
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
guint32 gst_util_seqnum_next (void);
|
guint32 gst_util_seqnum_next (void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue