mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-02 14:36:41 +00:00
Port to 0.9 and re-enable efence plugin.
Original commit message from CVS: * configure.ac: * gst/debug/Makefile.am: * gst/debug/efence.c: (gst_efence_class_init), (gst_efence_init), (gst_efence_chain), (gst_efence_buffer_alloc), (plugin_init), (gst_fenced_buffer_finalize), (gst_fenced_buffer_copy), (gst_fenced_buffer_alloc), (gst_fenced_buffer_class_init), (gst_fenced_buffer_init), (gst_fenced_buffer_get_type): Port to 0.9 and re-enable efence plugin.
This commit is contained in:
parent
d57d03f01b
commit
69f4aa6377
4 changed files with 139 additions and 97 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2005-09-07 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
|
* configure.ac:
|
||||||
|
* gst/debug/Makefile.am:
|
||||||
|
* gst/debug/efence.c: (gst_efence_class_init), (gst_efence_init),
|
||||||
|
(gst_efence_chain), (gst_efence_buffer_alloc), (plugin_init),
|
||||||
|
(gst_fenced_buffer_finalize), (gst_fenced_buffer_copy),
|
||||||
|
(gst_fenced_buffer_alloc), (gst_fenced_buffer_class_init),
|
||||||
|
(gst_fenced_buffer_init), (gst_fenced_buffer_get_type):
|
||||||
|
Port to 0.9 and re-enable efence plugin.
|
||||||
|
|
||||||
2005-09-06 Tim-Philipp Müller <tim at centricular dot net>
|
2005-09-06 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* ext/flac/gstflacdec.c: (flac_caps_factory), (raw_caps_factory),
|
* ext/flac/gstflacdec.c: (flac_caps_factory), (raw_caps_factory),
|
||||||
|
|
|
@ -269,6 +269,7 @@ GST_PLUGINS_ALL="\
|
||||||
alpha \
|
alpha \
|
||||||
autodetect \
|
autodetect \
|
||||||
avi \
|
avi \
|
||||||
|
debug \
|
||||||
effectv \
|
effectv \
|
||||||
fdsrc \
|
fdsrc \
|
||||||
goom \
|
goom \
|
||||||
|
@ -566,6 +567,7 @@ gst/Makefile
|
||||||
gst/alpha/Makefile
|
gst/alpha/Makefile
|
||||||
gst/autodetect/Makefile
|
gst/autodetect/Makefile
|
||||||
gst/avi/Makefile
|
gst/avi/Makefile
|
||||||
|
gst/debug/Makefile
|
||||||
gst/effectv/Makefile
|
gst/effectv/Makefile
|
||||||
gst/fdsrc/Makefile
|
gst/fdsrc/Makefile
|
||||||
gst/goom/Makefile
|
gst/goom/Makefile
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
plugin_LTLIBRARIES = libgstefence.la libgstnavigationtest.la libgstdebug.la
|
plugin_LTLIBRARIES = libgstefence.la # libgstnavigationtest.la libgstdebug.la
|
||||||
|
|
||||||
noinst_HEADERS = efence.h gstnavigationtest.h gstnavseek.h tests.h
|
noinst_HEADERS = efence.h gstnavigationtest.h gstnavseek.h tests.h
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_STATIC (gst_efence_debug);
|
||||||
|
#define GST_CAT_DEFAULT gst_efence_debug
|
||||||
|
|
||||||
static GstElementDetails plugin_details = {
|
static GstElementDetails plugin_details = {
|
||||||
"Electric Fence",
|
"Electric Fence",
|
||||||
"Testing",
|
"Testing",
|
||||||
|
@ -84,7 +87,7 @@ static void gst_efence_set_property (GObject * object, guint prop_id,
|
||||||
static void gst_efence_get_property (GObject * object, guint prop_id,
|
static void gst_efence_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static void gst_efence_chain (GstPad * pad, GstData * _data);
|
static GstFlowReturn gst_efence_chain (GstPad * pad, GstBuffer * buf);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
|
||||||
|
@ -96,14 +99,18 @@ struct _GstFencedBuffer
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
};
|
};
|
||||||
|
|
||||||
void gst_fenced_buffer_default_free (GstData * data);
|
GType gst_fenced_buffer_get_type (void);
|
||||||
GstData *gst_fenced_buffer_default_copy (const GstData * data);
|
static void gst_fenced_buffer_finalize (GstFencedBuffer * buf);
|
||||||
|
static GstFencedBuffer *gst_fenced_buffer_copy (const GstBuffer * buffer);
|
||||||
void *gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
|
void *gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
|
||||||
gboolean fence_top);
|
gboolean fence_top);
|
||||||
static GstBuffer *gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
|
static GstFlowReturn gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
|
||||||
guint size);
|
guint size, GstCaps * caps, GstBuffer ** buf);
|
||||||
|
|
||||||
GstBuffer *gst_fenced_buffer_new (void);
|
#define GST_TYPE_FENCED_BUFFER (gst_fenced_buffer_get_type())
|
||||||
|
|
||||||
|
#define GST_IS_FENCED_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FENCED_BUFFER))
|
||||||
|
#define GST_FENCED_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FENCED_BUFFER, GstFencedBuffer))
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_gst_efence_get_type (void)
|
gst_gst_efence_get_type (void)
|
||||||
|
@ -153,12 +160,12 @@ gst_efence_class_init (GstEFenceClass * klass)
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
|
gobject_class->set_property = gst_efence_set_property;
|
||||||
|
gobject_class->get_property = gst_efence_get_property;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, ARG_FENCE_TOP,
|
g_object_class_install_property (gobject_class, ARG_FENCE_TOP,
|
||||||
g_param_spec_boolean ("fence_top", "Fence Top",
|
g_param_spec_boolean ("fence_top", "Fence Top",
|
||||||
"Align buffers with top of fenced region", TRUE, G_PARAM_READWRITE));
|
"Align buffers with top of fenced region", TRUE, G_PARAM_READWRITE));
|
||||||
|
|
||||||
gobject_class->set_property = gst_efence_set_property;
|
|
||||||
gobject_class->get_property = gst_efence_get_property;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize the new element
|
/* initialize the new element
|
||||||
|
@ -173,12 +180,12 @@ gst_efence_init (GstEFence * filter)
|
||||||
gst_pad_new_from_template (gst_static_pad_template_get
|
gst_pad_new_from_template (gst_static_pad_template_get
|
||||||
(&gst_efence_sink_factory), "sink");
|
(&gst_efence_sink_factory), "sink");
|
||||||
gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps);
|
gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps);
|
||||||
gst_pad_set_link_function (filter->sinkpad, gst_pad_proxy_pad_link);
|
gst_pad_set_setcaps_function (filter->sinkpad, gst_pad_proxy_setcaps);
|
||||||
filter->srcpad =
|
filter->srcpad =
|
||||||
gst_pad_new_from_template (gst_static_pad_template_get
|
gst_pad_new_from_template (gst_static_pad_template_get
|
||||||
(&gst_efence_src_factory), "src");
|
(&gst_efence_src_factory), "src");
|
||||||
gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps);
|
gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps);
|
||||||
gst_pad_set_link_function (filter->srcpad, gst_pad_proxy_pad_link);
|
gst_pad_set_setcaps_function (filter->srcpad, gst_pad_proxy_setcaps);
|
||||||
|
|
||||||
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
||||||
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
||||||
|
@ -192,61 +199,61 @@ gst_efence_init (GstEFence * filter)
|
||||||
* this function does the actual processing
|
* this function does the actual processing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static GstFlowReturn
|
||||||
gst_efence_chain (GstPad * pad, GstData * _data)
|
gst_efence_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer = GST_BUFFER (_data);
|
|
||||||
GstEFence *efence;
|
GstEFence *efence;
|
||||||
GstBuffer *copy;
|
GstBuffer *copy;
|
||||||
void *ptr;
|
|
||||||
|
|
||||||
GST_DEBUG ("gst_efence_chain");
|
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
||||||
|
g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
|
||||||
g_return_if_fail (GST_IS_PAD (pad));
|
|
||||||
g_return_if_fail (buffer != NULL);
|
|
||||||
|
|
||||||
efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
||||||
g_return_if_fail (GST_IS_EFENCE (efence));
|
g_return_val_if_fail (GST_IS_EFENCE (efence), GST_FLOW_ERROR);
|
||||||
|
|
||||||
if (GST_DATA_FREE_FUNC (_data) == gst_fenced_buffer_default_free) {
|
if (GST_IS_FENCED_BUFFER (buffer)) {
|
||||||
gst_pad_push (efence->srcpad, _data);
|
GST_DEBUG_OBJECT (efence, "Passing on existing fenced buffer with caps %"
|
||||||
return;
|
GST_PTR_FORMAT, GST_BUFFER_CAPS (buffer));
|
||||||
|
return gst_pad_push (efence->srcpad, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy = gst_fenced_buffer_new ();
|
copy = (GstBuffer *) gst_fenced_buffer_copy (buffer);
|
||||||
|
|
||||||
ptr = gst_fenced_buffer_alloc (copy, GST_BUFFER_SIZE (buffer),
|
|
||||||
efence->fence_top);
|
|
||||||
memcpy (ptr, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
|
|
||||||
|
|
||||||
GST_BUFFER_DATA (copy) = ptr;
|
|
||||||
GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer);
|
|
||||||
GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer);
|
|
||||||
GST_BUFFER_TIMESTAMP (copy) = GST_BUFFER_TIMESTAMP (buffer);
|
|
||||||
GST_BUFFER_DURATION (copy) = GST_BUFFER_DURATION (buffer);
|
|
||||||
GST_BUFFER_OFFSET (copy) = GST_BUFFER_OFFSET (buffer);
|
|
||||||
GST_BUFFER_FREE_DATA_FUNC (copy) = NULL;
|
|
||||||
GST_BUFFER_PRIVATE (copy) = NULL;
|
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
gst_pad_push (efence->srcpad, GST_DATA (copy));
|
GST_DEBUG_OBJECT (efence, "Pushing newly fenced buffer with caps %"
|
||||||
|
GST_PTR_FORMAT, GST_BUFFER_CAPS (buffer));
|
||||||
|
|
||||||
|
return gst_pad_push (efence->srcpad, copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static GstFlowReturn
|
||||||
gst_efence_buffer_alloc (GstPad * pad, guint64 offset, guint size)
|
gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
|
||||||
|
guint size, GstCaps * caps, GstBuffer ** buf)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstEFence *efence;
|
GstEFence *efence;
|
||||||
|
|
||||||
|
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
|
||||||
|
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
||||||
|
|
||||||
efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
||||||
|
|
||||||
buffer = gst_fenced_buffer_new ();
|
buffer = (GstBuffer *) gst_mini_object_new (GST_TYPE_FENCED_BUFFER);
|
||||||
|
|
||||||
GST_BUFFER_DATA (buffer) = gst_fenced_buffer_alloc (buffer, size,
|
GST_BUFFER_DATA (buffer) = gst_fenced_buffer_alloc (buffer, size,
|
||||||
efence->fence_top);
|
efence->fence_top);
|
||||||
GST_BUFFER_SIZE (buffer) = size;
|
GST_BUFFER_SIZE (buffer) = size;
|
||||||
|
GST_BUFFER_OFFSET (buffer) = offset;
|
||||||
|
|
||||||
return buffer;
|
if (caps)
|
||||||
|
gst_buffer_set_caps (buffer, caps);
|
||||||
|
|
||||||
|
*buf = buffer;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (efence, "Allocated buffer of size %u, caps: % "
|
||||||
|
GST_PTR_FORMAT, GST_BUFFER_SIZE (buffer), GST_BUFFER_CAPS (buffer));
|
||||||
|
|
||||||
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -298,6 +305,9 @@ plugin_init (GstPlugin * plugin)
|
||||||
if (!gst_element_register (plugin, "efence", GST_RANK_NONE, GST_TYPE_EFENCE))
|
if (!gst_element_register (plugin, "efence", GST_RANK_NONE, GST_TYPE_EFENCE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_efence_debug, "efence", 0,
|
||||||
|
"Debug output from the efence element");
|
||||||
|
|
||||||
/* plugin initialisation succeeded */
|
/* plugin initialisation succeeded */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -312,88 +322,60 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
"\"Electric Fence\".",
|
"\"Electric Fence\".",
|
||||||
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
|
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
|
||||||
|
|
||||||
GstBuffer *gst_fenced_buffer_new (void)
|
static void gst_fenced_buffer_finalize (GstFencedBuffer * buffer)
|
||||||
{
|
|
||||||
GstBuffer *newbuf;
|
|
||||||
|
|
||||||
newbuf = (GstBuffer *) g_new0 (GstFencedBuffer, 1);
|
|
||||||
|
|
||||||
gst_data_init (GST_DATA (newbuf), _gst_buffer_type, 0,
|
|
||||||
gst_fenced_buffer_default_free, gst_fenced_buffer_default_copy);
|
|
||||||
|
|
||||||
GST_BUFFER_DATA (newbuf) = NULL;
|
|
||||||
GST_BUFFER_SIZE (newbuf) = 0;
|
|
||||||
GST_BUFFER_MAXSIZE (newbuf) = GST_BUFFER_MAXSIZE_NONE;
|
|
||||||
GST_BUFFER_TIMESTAMP (newbuf) = GST_CLOCK_TIME_NONE;
|
|
||||||
GST_BUFFER_DURATION (newbuf) = GST_CLOCK_TIME_NONE;
|
|
||||||
GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET_NONE;
|
|
||||||
GST_BUFFER_FREE_DATA_FUNC (newbuf) = NULL;
|
|
||||||
GST_BUFFER_PRIVATE (newbuf) = NULL;
|
|
||||||
|
|
||||||
GST_DEBUG ("new buffer=%p", newbuf);
|
|
||||||
|
|
||||||
return newbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_fenced_buffer_default_free (GstData * data)
|
|
||||||
{
|
{
|
||||||
GstFencedBuffer *fenced_buffer;
|
GstFencedBuffer *fenced_buffer;
|
||||||
GstBuffer *buffer = GST_BUFFER (data);
|
|
||||||
|
|
||||||
GST_DEBUG ("free buffer=%p", data);
|
GST_DEBUG ("free buffer=%p", buffer);
|
||||||
|
|
||||||
g_return_if_fail (data != NULL);
|
fenced_buffer = GST_FENCED_BUFFER (buffer);
|
||||||
|
|
||||||
fenced_buffer = (GstFencedBuffer *) data;
|
|
||||||
|
|
||||||
/* free our data */
|
/* free our data */
|
||||||
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_DONTFREE) &&
|
if (GST_BUFFER_DATA (buffer)) {
|
||||||
GST_BUFFER_DATA (buffer)) {
|
|
||||||
GST_DEBUG ("free region %p %d", fenced_buffer->region,
|
GST_DEBUG ("free region %p %d", fenced_buffer->region,
|
||||||
fenced_buffer->length);
|
fenced_buffer->length);
|
||||||
munmap (fenced_buffer->region, fenced_buffer->length);
|
munmap (fenced_buffer->region, fenced_buffer->length);
|
||||||
} else {
|
}
|
||||||
GST_DEBUG ("not freeing region %p %d %p", fenced_buffer->region,
|
|
||||||
GST_BUFFER_FLAGS (buffer), GST_BUFFER_DATA (buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set to safe values */
|
static GstFencedBuffer *
|
||||||
GST_BUFFER_DATA (buffer) = NULL;
|
gst_fenced_buffer_copy (const GstBuffer * buffer)
|
||||||
GST_BUFFER_SIZE (buffer) = 0;
|
|
||||||
|
|
||||||
g_free (buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
GstData *
|
|
||||||
gst_fenced_buffer_default_copy (const GstData * data)
|
|
||||||
{
|
{
|
||||||
GstBuffer *buffer = GST_BUFFER (data);
|
GstBuffer *copy;
|
||||||
GstData *copy;
|
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
guint mask;
|
||||||
|
|
||||||
g_return_val_if_fail (buffer != NULL, NULL);
|
g_return_val_if_fail (buffer != NULL, NULL);
|
||||||
|
|
||||||
/* create a fresh new buffer */
|
/* create a fresh new buffer */
|
||||||
copy = (GstData *) g_new0 (GstFencedBuffer, 1);
|
copy = (GstBuffer *) gst_mini_object_new (GST_TYPE_FENCED_BUFFER);
|
||||||
|
|
||||||
gst_data_init (copy, _gst_buffer_type, 0,
|
|
||||||
gst_fenced_buffer_default_free, gst_fenced_buffer_default_copy);
|
|
||||||
|
|
||||||
/* we simply copy everything from our parent */
|
/* we simply copy everything from our parent */
|
||||||
ptr = gst_fenced_buffer_alloc (GST_BUFFER (copy),
|
ptr = gst_fenced_buffer_alloc (GST_BUFFER (copy),
|
||||||
GST_BUFFER_SIZE (buffer), TRUE);
|
GST_BUFFER_SIZE (buffer), TRUE);
|
||||||
memcpy (ptr, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
|
memcpy (ptr, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
|
||||||
|
|
||||||
|
/* copy relevant flags */
|
||||||
|
mask = GST_BUFFER_FLAG_PREROLL | GST_BUFFER_FLAG_IN_CAPS |
|
||||||
|
GST_BUFFER_FLAG_DELTA_UNIT;
|
||||||
|
GST_MINI_OBJECT (copy)->flags |= GST_MINI_OBJECT (buffer)->flags & mask;
|
||||||
|
|
||||||
GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer);
|
GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer);
|
||||||
GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer);
|
|
||||||
GST_BUFFER_TIMESTAMP (copy) = GST_BUFFER_TIMESTAMP (buffer);
|
GST_BUFFER_TIMESTAMP (copy) = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_BUFFER_DURATION (copy) = GST_BUFFER_DURATION (buffer);
|
GST_BUFFER_DURATION (copy) = GST_BUFFER_DURATION (buffer);
|
||||||
GST_BUFFER_OFFSET (copy) = GST_BUFFER_OFFSET (buffer);
|
GST_BUFFER_OFFSET (copy) = GST_BUFFER_OFFSET (buffer);
|
||||||
GST_BUFFER_FREE_DATA_FUNC (copy) = NULL;
|
GST_BUFFER_OFFSET_END (copy) = GST_BUFFER_OFFSET_END (buffer);
|
||||||
GST_BUFFER_PRIVATE (copy) = NULL;
|
|
||||||
|
|
||||||
return copy;
|
if (GST_BUFFER_CAPS (buffer))
|
||||||
|
GST_BUFFER_CAPS (copy) = gst_caps_ref (GST_BUFFER_CAPS (buffer));
|
||||||
|
else
|
||||||
|
GST_BUFFER_CAPS (copy) = NULL;
|
||||||
|
|
||||||
|
GST_DEBUG ("Copied buffer %p with ts %" GST_TIME_FORMAT
|
||||||
|
", caps: % " GST_PTR_FORMAT, buffer, GST_BUFFER_TIMESTAMP (copy),
|
||||||
|
GST_BUFFER_CAPS (copy));
|
||||||
|
|
||||||
|
return GST_FENCED_BUFFER (copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@ -416,6 +398,7 @@ gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
|
||||||
page_size = getpagesize ();
|
page_size = getpagesize ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Allocate a complete page, and one on either side */
|
||||||
alloc_size = ((length - 1) & ~(page_size - 1)) + page_size;
|
alloc_size = ((length - 1) & ~(page_size - 1)) + page_size;
|
||||||
alloc_size += 2 * page_size;
|
alloc_size += 2 * page_size;
|
||||||
|
|
||||||
|
@ -425,12 +408,19 @@ gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
|
||||||
g_warning ("mmap failed");
|
g_warning ("mmap failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
munmap (region, page_size);
|
munmap (region, page_size);
|
||||||
munmap (region + alloc_size - page_size, page_size);
|
munmap (region + alloc_size - page_size, page_size);
|
||||||
|
|
||||||
|
fenced_buffer->region = region + page_size;
|
||||||
|
fenced_buffer->length = alloc_size - page_size;
|
||||||
|
#else
|
||||||
|
mprotect (region, page_size, PROT_NONE);
|
||||||
|
mprotect (region + alloc_size - page_size, page_size, PROT_NONE);
|
||||||
|
|
||||||
fenced_buffer->region = region;
|
fenced_buffer->region = region;
|
||||||
fenced_buffer->length = alloc_size;
|
fenced_buffer->length = alloc_size;
|
||||||
|
#endif
|
||||||
|
|
||||||
GST_DEBUG ("new region %p %d", fenced_buffer->region, fenced_buffer->length);
|
GST_DEBUG ("new region %p %d", fenced_buffer->region, fenced_buffer->length);
|
||||||
|
|
||||||
|
@ -445,3 +435,42 @@ gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
|
||||||
return region + page_size;
|
return region + page_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_fenced_buffer_class_init (gpointer g_class, gpointer class_data)
|
||||||
|
{
|
||||||
|
GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
|
||||||
|
|
||||||
|
mini_object_class->finalize =
|
||||||
|
(GstMiniObjectFinalizeFunction) gst_fenced_buffer_finalize;
|
||||||
|
mini_object_class->copy = (GstMiniObjectCopyFunction) gst_fenced_buffer_copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_fenced_buffer_init (GTypeInstance * instance, gpointer g_class)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_fenced_buffer_get_type (void)
|
||||||
|
{
|
||||||
|
static GType fenced_buf_type = 0;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!fenced_buf_type)) {
|
||||||
|
static const GTypeInfo fenced_buf_info = {
|
||||||
|
sizeof (GstBufferClass),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(GClassInitFunc) gst_fenced_buffer_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (GstFencedBuffer),
|
||||||
|
0,
|
||||||
|
(GInstanceInitFunc) gst_fenced_buffer_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
fenced_buf_type = g_type_register_static (GST_TYPE_BUFFER,
|
||||||
|
"GstFencedBuffer", &fenced_buf_info, 0);
|
||||||
|
}
|
||||||
|
return fenced_buf_type;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue