dnl have to change too much elsewhere
AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
-dnl configure the desired buffer alignment
-AC_ARG_WITH([buffer-alignment],
- AS_HELP_STRING([--with-buffer-alignment],[8,N,malloc,pagesize (default is 32)]),
+dnl configure the desired memory alignment
+AC_ARG_WITH([memory-alignment],
+ AS_HELP_STRING([--with-memory-alignment],[8,N,malloc,pagesize (default is 32)]),
[
if test "x$withval" = "xyes"
then
- AC_DEFINE(BUFFER_ALIGNMENT, 32, [Buffer alignment to use])
+ AC_DEFINE(MEMORY_ALIGNMENT, 32, [Memory alignment to use])
else
case "${withval}" in
- malloc) AC_DEFINE(BUFFER_ALIGNMENT_MALLOC, 1, [Buffer alignment by malloc default]) ;;
- pagesize) AC_DEFINE(BUFFER_ALIGNMENT_PAGESIZE, 1, [Buffer alignment by pagesize]) ;;
- *) AC_DEFINE_UNQUOTED(BUFFER_ALIGNMENT, ${withval}, [Buffer alignment to use]) ;;
+ malloc) AC_DEFINE(MEMORY_ALIGNMENT_MALLOC, 1, [Memory alignment by malloc default]) ;;
+ pagesize) AC_DEFINE(MEMORY_ALIGNMENT_PAGESIZE, 1, [Memory alignment by pagesize]) ;;
+ *) AC_DEFINE_UNQUOTED(MEMORY_ALIGNMENT, ${withval}, [Memory alignment to use]) ;;
esac
fi
], [
- AC_DEFINE(BUFFER_ALIGNMENT_MALLOC, 1, [Buffer alignment by malloc default])
+ AC_DEFINE(MEMORY_ALIGNMENT_MALLOC, 1, [Memory alignment by malloc default])
]
)
-e 's/.* HAVE_WIN32$/#define HAVE_WIN32 1/' \
-e 's/.* HAVE_WINSOCK2_H$/#define HAVE_WINSOCK2_H 1/' \
-e 's/.* HOST_CPU$/#define HOST_CPU "i686"/' \
- -e 's/.* BUFFER_ALIGNMENT_MALLOC/#define BUFFER_ALIGNMENT_MALLOC 1/' \
+ -e 's/.* MEMORY_ALIGNMENT_MALLOC/#define MEMORY_ALIGNMENT_MALLOC 1/' \
-e 's/.* LIBDIR$/#ifdef _DEBUG\n# define LIBDIR PREFIX "\\\\debug\\\\lib"\n#else\n# define LIBDIR PREFIX "\\\\lib"\n#endif/' \
-e 's/.* LOCALEDIR$/#define LOCALEDIR PREFIX "\\\\share\\\\locale"/' \
-e 's/.* PACKAGE$/#define PACKAGE "gstreamer"/' \
GST_BUFFER_MEM_LEN (buffer) = len + 1;
}
-#if 0
-/* buffer alignment in bytes - 1
- * an alignment of 7 would be the same as malloc() guarantees
- */
-#ifdef HAVE_POSIX_MEMALIGN
-#if defined(BUFFER_ALIGNMENT_MALLOC)
-static size_t _gst_buffer_data_alignment = 7;
-#elif defined(BUFFER_ALIGNMENT_PAGESIZE)
-static size_t _gst_buffer_data_alignment = 0;
-#elif defined(BUFFER_ALIGNMENT)
-static size_t _gst_buffer_data_alignment = BUFFER_ALIGNMENT - 1;
-#else
-#error "No buffer alignment configured"
-#endif
-#endif /* HAVE_POSIX_MEMALIGN */
-#endif
-
void
_gst_buffer_initialize (void)
{
if (G_LIKELY (_gst_buffer_type == 0)) {
_gst_buffer_type = gst_mini_object_register ("GstBuffer");
-#if 0
-#ifdef HAVE_GETPAGESIZE
-#ifdef BUFFER_ALIGNMENT_PAGESIZE
- _gst_buffer_data_alignment = getpagesize () - 1;
-#endif
-#endif
-#endif
}
}
#include "gstmemory.h"
+/* buffer alignment in bytes - 1
+ * an alignment of 7 would be the same as malloc() guarantees
+ */
+#ifdef HAVE_POSIX_MEMALIGN
+#if defined(MEMORY_ALIGNMENT_MALLOC)
+static size_t _gst_memory_alignment = 7;
+#elif defined(MEMORY_ALIGNMENT_PAGESIZE)
+static size_t _gst_memory_alignment = 0;
+#elif defined(MEMORY_ALIGNMENT)
+static size_t _gst_memory_alignment = MEMORY_ALIGNMENT - 1;
+#else
+#error "No memory alignment configured"
+#endif
+#endif /* HAVE_POSIX_MEMALIGN */
+
struct _GstMemoryAllocator
{
GQuark name;
gsize aoffset, slice_size;
guint8 *data;
+ /* ensure configured alignment */
+ align |= _gst_memory_alignment;
/* allocate more to compensate for alignment */
maxsize += align;
/* alloc header and data in one block */
allocators = g_hash_table_new (g_str_hash, g_str_equal);
+#ifdef HAVE_GETPAGESIZE
+#ifdef MEMORY_ALIGNMENT_PAGESIZE
+ _gst_memory_alignment = getpagesize () - 1;
+#endif
+#endif
+
_default_mem_impl =
gst_memory_allocator_register ("GstMemoryDefault", &_mem_info);