mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
gst/base/gsttypefindhelper.c: The memory returned by gst_type_find_peek() needs to stay valid until the end of a type...
Original commit message from CVS: * gst/base/gsttypefindhelper.c: (helper_find_peek), (gst_type_find_helper): The memory returned by gst_type_find_peek() needs to stay valid until the end of a typefind function, and typefind functions may keep results from different offsets around, so we can't just unref the buffer from the previous _peek(), but have to save all buffers returned by _peek() until typefinding is done and only free them then.
This commit is contained in:
parent
8e8a415095
commit
ba8a8319fd
3 changed files with 28 additions and 20 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2005-08-10 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* gst/base/gsttypefindhelper.c: (helper_find_peek),
|
||||||
|
(gst_type_find_helper):
|
||||||
|
The memory returned by gst_type_find_peek() needs to
|
||||||
|
stay valid until the end of a typefind function, and
|
||||||
|
typefind functions may keep results from different
|
||||||
|
offsets around, so we can't just unref the buffer from
|
||||||
|
the previous _peek(), but have to save all buffers
|
||||||
|
returned by _peek() until typefinding is done and only
|
||||||
|
free them then.
|
||||||
|
|
||||||
2005-08-09 Tim-Philipp Müller <tim at centricular dot net>
|
2005-08-09 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* docs/gst/gstreamer-sections.txt:
|
* docs/gst/gstreamer-sections.txt:
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct
|
||||||
guint best_probability;
|
guint best_probability;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
guint64 size;
|
guint64 size;
|
||||||
GstBuffer *buffer;
|
GList *buffers;
|
||||||
}
|
}
|
||||||
GstTypeFindHelper;
|
GstTypeFindHelper;
|
||||||
|
|
||||||
|
@ -63,18 +63,15 @@ helper_find_peek (gpointer data, gint64 offset, guint size)
|
||||||
offset += find->size;
|
offset += find->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: is it worth checking our list of buffers for
|
||||||
|
* a match before pulling a new buffer via _getrange()? */
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
ret = GST_PAD_GETRANGEFUNC (src) (src, offset, size, &buffer);
|
ret = GST_PAD_GETRANGEFUNC (src) (src, offset, size, &buffer);
|
||||||
|
|
||||||
if (find->buffer) {
|
|
||||||
gst_buffer_unref (find->buffer);
|
|
||||||
find->buffer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
find->buffer = buffer;
|
find->buffers = g_list_prepend (find->buffers, buffer);
|
||||||
|
|
||||||
return GST_BUFFER_DATA (buffer);
|
return GST_BUFFER_DATA (buffer);
|
||||||
|
|
||||||
|
@ -112,7 +109,7 @@ gst_type_find_helper (GstPad * src, guint64 size)
|
||||||
find.best_probability = 0;
|
find.best_probability = 0;
|
||||||
find.caps = NULL;
|
find.caps = NULL;
|
||||||
find.size = size;
|
find.size = size;
|
||||||
find.buffer = NULL;
|
find.buffers = NULL;
|
||||||
gst_find.data = &find;
|
gst_find.data = &find;
|
||||||
gst_find.peek = helper_find_peek;
|
gst_find.peek = helper_find_peek;
|
||||||
gst_find.suggest = helper_find_suggest;
|
gst_find.suggest = helper_find_suggest;
|
||||||
|
@ -130,8 +127,9 @@ gst_type_find_helper (GstPad * src, guint64 size)
|
||||||
if (find.best_probability > 0)
|
if (find.best_probability > 0)
|
||||||
result = find.caps;
|
result = find.caps;
|
||||||
|
|
||||||
if (find.buffer)
|
for (walk = find.buffers; walk; walk = walk->next)
|
||||||
gst_buffer_unref (find.buffer);
|
gst_buffer_unref (GST_BUFFER (walk->data));
|
||||||
|
g_list_free (find.buffers);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct
|
||||||
guint best_probability;
|
guint best_probability;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
guint64 size;
|
guint64 size;
|
||||||
GstBuffer *buffer;
|
GList *buffers;
|
||||||
}
|
}
|
||||||
GstTypeFindHelper;
|
GstTypeFindHelper;
|
||||||
|
|
||||||
|
@ -63,18 +63,15 @@ helper_find_peek (gpointer data, gint64 offset, guint size)
|
||||||
offset += find->size;
|
offset += find->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: is it worth checking our list of buffers for
|
||||||
|
* a match before pulling a new buffer via _getrange()? */
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
ret = GST_PAD_GETRANGEFUNC (src) (src, offset, size, &buffer);
|
ret = GST_PAD_GETRANGEFUNC (src) (src, offset, size, &buffer);
|
||||||
|
|
||||||
if (find->buffer) {
|
|
||||||
gst_buffer_unref (find->buffer);
|
|
||||||
find->buffer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
find->buffer = buffer;
|
find->buffers = g_list_prepend (find->buffers, buffer);
|
||||||
|
|
||||||
return GST_BUFFER_DATA (buffer);
|
return GST_BUFFER_DATA (buffer);
|
||||||
|
|
||||||
|
@ -112,7 +109,7 @@ gst_type_find_helper (GstPad * src, guint64 size)
|
||||||
find.best_probability = 0;
|
find.best_probability = 0;
|
||||||
find.caps = NULL;
|
find.caps = NULL;
|
||||||
find.size = size;
|
find.size = size;
|
||||||
find.buffer = NULL;
|
find.buffers = NULL;
|
||||||
gst_find.data = &find;
|
gst_find.data = &find;
|
||||||
gst_find.peek = helper_find_peek;
|
gst_find.peek = helper_find_peek;
|
||||||
gst_find.suggest = helper_find_suggest;
|
gst_find.suggest = helper_find_suggest;
|
||||||
|
@ -130,8 +127,9 @@ gst_type_find_helper (GstPad * src, guint64 size)
|
||||||
if (find.best_probability > 0)
|
if (find.best_probability > 0)
|
||||||
result = find.caps;
|
result = find.caps;
|
||||||
|
|
||||||
if (find.buffer)
|
for (walk = find.buffers; walk; walk = walk->next)
|
||||||
gst_buffer_unref (find.buffer);
|
gst_buffer_unref (GST_BUFFER (walk->data));
|
||||||
|
g_list_free (find.buffers);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue