mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
ximage: do not allocate extra alignment slack for shared memory
A previous patch increased allocations by 15 bytes in order to ensure 16 byte alignment for g_malloc blocks. However, shared memory is already block aligned, and this extra 15 bytes is not needed. Since shared memory limits are low compared to RAM, we remove this waste. https://bugzilla.gnome.org/show_bug.cgi?id=727236
This commit is contained in:
parent
cca103296d
commit
3fd184da78
1 changed files with 4 additions and 1 deletions
|
@ -213,7 +213,7 @@ ximage_memory_alloc (GstXImageBufferPool * xpool)
|
||||||
int (*handler) (Display *, XErrorEvent *);
|
int (*handler) (Display *, XErrorEvent *);
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
GstXContext *xcontext;
|
GstXContext *xcontext;
|
||||||
gint width, height, align = 15, offset;
|
gint width, height, align, offset;
|
||||||
GstXImageMemory *mem;
|
GstXImageMemory *mem;
|
||||||
|
|
||||||
ximagesink = xpool->sink;
|
ximagesink = xpool->sink;
|
||||||
|
@ -276,6 +276,7 @@ ximage_memory_alloc (GstXImageBufferPool * xpool)
|
||||||
mem->size, width, mem->ximage->bytes_per_line);
|
mem->size, width, mem->ximage->bytes_per_line);
|
||||||
|
|
||||||
/* get shared memory */
|
/* get shared memory */
|
||||||
|
align = 0;
|
||||||
mem->SHMInfo.shmid =
|
mem->SHMInfo.shmid =
|
||||||
shmget (IPC_PRIVATE, mem->size + align, IPC_CREAT | 0777);
|
shmget (IPC_PRIVATE, mem->size + align, IPC_CREAT | 0777);
|
||||||
if (mem->SHMInfo.shmid == -1)
|
if (mem->SHMInfo.shmid == -1)
|
||||||
|
@ -330,6 +331,8 @@ ximage_memory_alloc (GstXImageBufferPool * xpool)
|
||||||
allocsize =
|
allocsize =
|
||||||
GST_ROUND_UP_4 (mem->ximage->bytes_per_line) * mem->ximage->height;
|
GST_ROUND_UP_4 (mem->ximage->bytes_per_line) * mem->ximage->height;
|
||||||
|
|
||||||
|
/* we want 16 byte aligned memory, g_malloc may only give 8 */
|
||||||
|
align = 15;
|
||||||
mem->ximage->data = g_malloc (allocsize + align);
|
mem->ximage->data = g_malloc (allocsize + align);
|
||||||
GST_LOG_OBJECT (ximagesink,
|
GST_LOG_OBJECT (ximagesink,
|
||||||
"non-XShm image size is %" G_GSIZE_FORMAT " (alloced: %u), width %d, "
|
"non-XShm image size is %" G_GSIZE_FORMAT " (alloced: %u), width %d, "
|
||||||
|
|
Loading…
Reference in a new issue