mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
shmsink: Error out if memory area is smaller than buffer
This commit is contained in:
parent
7a77b41d6a
commit
684811cddf
3 changed files with 23 additions and 0 deletions
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue