summaryrefslogtreecommitdiff
path: root/sys/shm
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2013-02-27 21:05:38 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2013-02-27 21:05:38 -0500
commit684811cddf60f43df14b2fd7a64207f5566b9a32 (patch)
tree152c39bbc42ff8990b6f1b8608c12f9a9e4110ed /sys/shm
parent7a77b41d6a86e98ed60716ece907602ec530ac9c (diff)
downloadgstreamer-plugins-bad-684811cddf60f43df14b2fd7a64207f5566b9a32.tar.gz
shmsink: Error out if memory area is smaller than buffer
Diffstat (limited to 'sys/shm')
-rw-r--r--sys/shm/gstshmsink.c13
-rw-r--r--sys/shm/shmpipe.c9
-rw-r--r--sys/shm/shmpipe.h1
3 files changed, 23 insertions, 0 deletions
diff --git a/sys/shm/gstshmsink.c b/sys/shm/gstshmsink.c
index 6228a55ac..e48785d81 100644
--- a/sys/shm/gstshmsink.c
+++ b/sys/shm/gstshmsink.c
@@ -424,6 +424,19 @@ gst_shm_sink_render (GstBaseSink * bsink, GstBuffer * buf)
if (rv == -1) {
ShmBlock *block = NULL;
gchar *shmbuf = NULL;
+
+ if (gst_buffer_get_size (buf) > sp_writer_get_max_buf_size (self->pipe)) {
+ gsize area_size = sp_writer_get_max_buf_size (self->pipe);
+
+ GST_OBJECT_UNLOCK (self);
+ GST_ELEMENT_ERROR (self, RESOURCE, NO_SPACE_LEFT,
+ ("Shared memory area is too small"),
+ ("Shared memory area of size %" G_GSIZE_FORMAT " is smaller than"
+ "buffer of size %" G_GSIZE_FORMAT, area_size,
+ gst_buffer_get_size (buf)));
+ return GST_FLOW_ERROR;
+ }
+
while ((block = sp_writer_alloc_block (self->pipe,
gst_buffer_get_size (buf))) == NULL) {
g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self));
diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c
index 348dc4012..676453b37 100644
--- a/sys/shm/shmpipe.c
+++ b/sys/shm/shmpipe.c
@@ -946,3 +946,12 @@ sp_writer_buf_get_tag (ShmBuffer * buffer)
{
return buffer->tag;
}
+
+size_t
+sp_writer_get_max_buf_size (ShmPipe * self)
+{
+ if (self->shm_area == NULL)
+ return 0;
+
+ return self->shm_area->shm_area_len;
+}
diff --git a/sys/shm/shmpipe.h b/sys/shm/shmpipe.h
index eef8877d1..ecac432a6 100644
--- a/sys/shm/shmpipe.h
+++ b/sys/shm/shmpipe.h
@@ -95,6 +95,7 @@ void sp_writer_free_block (ShmBlock *block);
int sp_writer_send_buf (ShmPipe * self, char *buf, size_t size, uint64_t tag);
char *sp_writer_block_get_buf (ShmBlock *block);
ShmPipe *sp_writer_block_get_pipe (ShmBlock *block);
+size_t sp_writer_get_max_buf_size (ShmPipe * self);
ShmClient * sp_writer_accept_client (ShmPipe * self);
void sp_writer_close_client (ShmPipe *self, ShmClient * client);