shmsink: Error out if memory area is smaller than buffer

This commit is contained in:
Olivier Crête 2013-02-27 21:05:38 -05:00
parent 7a77b41d6a
commit 684811cddf
3 changed files with 23 additions and 0 deletions

View file

@ -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));

View file

@ -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;
}

View file

@ -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);