mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:06:17 +00:00
matroskamux: Fix constantly growing used uid list
Moves the used uid list to the class to avoid having it grow forever. https://bugzilla.gnome.org/show_bug.cgi?id=723269
This commit is contained in:
parent
480ae10884
commit
46bc1677a4
2 changed files with 20 additions and 15 deletions
|
@ -196,9 +196,6 @@ static GstStaticPadTemplate subtitlesink_templ =
|
||||||
"application/x-subtitle-unknown")
|
"application/x-subtitle-unknown")
|
||||||
);
|
);
|
||||||
|
|
||||||
static GArray *used_uids;
|
|
||||||
G_LOCK_DEFINE_STATIC (used_uids);
|
|
||||||
|
|
||||||
static gpointer parent_class; /* NULL */
|
static gpointer parent_class; /* NULL */
|
||||||
|
|
||||||
/* Matroska muxer destructor */
|
/* Matroska muxer destructor */
|
||||||
|
@ -233,7 +230,7 @@ static void gst_matroska_mux_get_property (GObject * object,
|
||||||
static void gst_matroska_mux_reset (GstElement * element);
|
static void gst_matroska_mux_reset (GstElement * element);
|
||||||
|
|
||||||
/* uid generation */
|
/* uid generation */
|
||||||
static guint64 gst_matroska_mux_create_uid ();
|
static guint64 gst_matroska_mux_create_uid (GstMatroskaMux * mux);
|
||||||
|
|
||||||
static gboolean theora_streamheader_to_codecdata (const GValue * streamheader,
|
static gboolean theora_streamheader_to_codecdata (const GValue * streamheader,
|
||||||
GstMatroskaTrackContext * context);
|
GstMatroskaTrackContext * context);
|
||||||
|
@ -477,6 +474,9 @@ gst_matroska_mux_init (GstMatroskaMux * mux, gpointer g_class)
|
||||||
mux->num_t_streams = 0;
|
mux->num_t_streams = 0;
|
||||||
mux->num_v_streams = 0;
|
mux->num_v_streams = 0;
|
||||||
|
|
||||||
|
/* create used uid list */
|
||||||
|
mux->used_uids = g_array_sized_new (FALSE, FALSE, sizeof (guint64), 10);
|
||||||
|
|
||||||
/* initialize remaining variables */
|
/* initialize remaining variables */
|
||||||
gst_matroska_mux_reset (GST_ELEMENT (mux));
|
gst_matroska_mux_reset (GST_ELEMENT (mux));
|
||||||
}
|
}
|
||||||
|
@ -500,41 +500,38 @@ gst_matroska_mux_finalize (GObject * object)
|
||||||
if (mux->writing_app)
|
if (mux->writing_app)
|
||||||
g_free (mux->writing_app);
|
g_free (mux->writing_app);
|
||||||
|
|
||||||
|
g_array_free (mux->used_uids, TRUE);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_matroska_mux_create_uid:
|
* gst_matroska_mux_create_uid:
|
||||||
|
* @mux: #GstMatroskaMux to generate UID for.
|
||||||
*
|
*
|
||||||
* Generate new unused track UID.
|
* Generate new unused track UID.
|
||||||
*
|
*
|
||||||
* Returns: New track UID.
|
* Returns: New track UID.
|
||||||
*/
|
*/
|
||||||
static guint64
|
static guint64
|
||||||
gst_matroska_mux_create_uid (void)
|
gst_matroska_mux_create_uid (GstMatroskaMux * mux)
|
||||||
{
|
{
|
||||||
guint64 uid = 0;
|
guint64 uid = 0;
|
||||||
|
|
||||||
G_LOCK (used_uids);
|
|
||||||
|
|
||||||
if (!used_uids)
|
|
||||||
used_uids = g_array_sized_new (FALSE, FALSE, sizeof (guint64), 10);
|
|
||||||
|
|
||||||
while (!uid) {
|
while (!uid) {
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
uid = (((guint64) g_random_int ()) << 32) | g_random_int ();
|
uid = (((guint64) g_random_int ()) << 32) | g_random_int ();
|
||||||
for (i = 0; i < used_uids->len; i++) {
|
for (i = 0; i < mux->used_uids->len; i++) {
|
||||||
if (g_array_index (used_uids, guint64, i) == uid) {
|
if (g_array_index (mux->used_uids, guint64, i) == uid) {
|
||||||
uid = 0;
|
uid = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_array_append_val (used_uids, uid);
|
g_array_append_val (mux->used_uids, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_UNLOCK (used_uids);
|
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,6 +673,11 @@ gst_matroska_mux_reset (GstElement * element)
|
||||||
gst_toc_setter_reset (GST_TOC_SETTER (mux));
|
gst_toc_setter_reset (GST_TOC_SETTER (mux));
|
||||||
|
|
||||||
mux->chapters_pos = 0;
|
mux->chapters_pos = 0;
|
||||||
|
|
||||||
|
/* clear used uids */
|
||||||
|
if (mux->used_uids->len > 0) {
|
||||||
|
g_array_remove_range (mux->used_uids, 0, mux->used_uids->len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2303,7 +2305,7 @@ gst_matroska_mux_track_header (GstMatroskaMux * mux,
|
||||||
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_TRACKTYPE, context->type);
|
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_TRACKTYPE, context->type);
|
||||||
|
|
||||||
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_TRACKUID,
|
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_TRACKUID,
|
||||||
gst_matroska_mux_create_uid ());
|
gst_matroska_mux_create_uid (mux));
|
||||||
if (context->default_duration) {
|
if (context->default_duration) {
|
||||||
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_TRACKDEFAULTDURATION,
|
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_TRACKDEFAULTDURATION,
|
||||||
context->default_duration);
|
context->default_duration);
|
||||||
|
|
|
@ -132,6 +132,9 @@ typedef struct _GstMatroskaMux {
|
||||||
|
|
||||||
/* Flag to ease handling of WebM specifics */
|
/* Flag to ease handling of WebM specifics */
|
||||||
gboolean is_webm;
|
gboolean is_webm;
|
||||||
|
|
||||||
|
/* used uids */
|
||||||
|
GArray *used_uids;
|
||||||
} GstMatroskaMux;
|
} GstMatroskaMux;
|
||||||
|
|
||||||
typedef struct _GstMatroskaMuxClass {
|
typedef struct _GstMatroskaMuxClass {
|
||||||
|
|
Loading…
Reference in a new issue