summaryrefslogtreecommitdiff
path: root/sys/shm
diff options
context:
space:
mode:
authorGuillaume Emont <guijemont@igalia.com>2012-04-27 18:29:14 +0200
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2015-04-02 18:11:37 -0400
commit48880ea6c7dd0914f60b9b9e1dda34cfbcc5d188 (patch)
tree4f0abf0680ce544f9e81e2d63c2d2cc46a2124a0 /sys/shm
parent43d4d3c5ca4fa70547b9aba29e0a1eefcfe4c049 (diff)
downloadgstreamer-plugins-bad-48880ea6c7dd0914f60b9b9e1dda34cfbcc5d188.tar.gz
shmsink: add an shm-area-name property
The shm-area-property tells the name of the shm area used by the element. This is useful for cases where shmsink is not able to clean up (calling shm_unlink()), e.g. if it is in a sandbox. https://bugzilla.gnome.org/show_bug.cgi?id=675134
Diffstat (limited to 'sys/shm')
-rw-r--r--sys/shm/gstshmsrc.c19
-rw-r--r--sys/shm/shmpipe.c16
-rw-r--r--sys/shm/shmpipe.h1
3 files changed, 32 insertions, 4 deletions
diff --git a/sys/shm/gstshmsrc.c b/sys/shm/gstshmsrc.c
index 8af1f34d1..1e69af751 100644
--- a/sys/shm/gstshmsrc.c
+++ b/sys/shm/gstshmsrc.c
@@ -54,7 +54,8 @@ enum
{
PROP_0,
PROP_SOCKET_PATH,
- PROP_IS_LIVE
+ PROP_IS_LIVE,
+ PROP_SHM_AREA_NAME
};
struct GstShmBuffer
@@ -123,14 +124,20 @@ gst_shm_src_class_init (GstShmSrcClass * klass)
g_object_class_install_property (gobject_class, PROP_SOCKET_PATH,
g_param_spec_string ("socket-path",
"Path to the control socket",
- "The path to the control socket used to control the shared memory"
- " transport", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ "The path to the control socket used to control the shared memory",
+ NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_IS_LIVE,
g_param_spec_boolean ("is-live", "Is this a live source",
"True if the element cannot produce data in PAUSED", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_SHM_AREA_NAME,
+ g_param_spec_string ("shm-area-name",
+ "Name of the shared memory area",
+ "The name of the shared memory area used to get buffers",
+ NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&srctemplate));
@@ -205,6 +212,12 @@ gst_shm_src_get_property (GObject * object, guint prop_id,
case PROP_IS_LIVE:
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (object)));
break;
+ case PROP_SHM_AREA_NAME:
+ GST_OBJECT_LOCK (object);
+ if (self->pipe)
+ g_value_set_string (value, sp_get_shm_area_name (self->pipe->pipe));
+ GST_OBJECT_UNLOCK (object);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c
index 6bd9efc42..0d7bf26c3 100644
--- a/sys/shm/shmpipe.c
+++ b/sys/shm/shmpipe.c
@@ -90,6 +90,7 @@ struct _ShmArea
int id;
int use_count;
+ int is_writer;
int shm_fd;
@@ -286,6 +287,8 @@ sp_open_shm (char *path, int id, mode_t perms, size_t size)
area->shm_area_len = size;
+ area->is_writer = (path == NULL);
+
if (path)
flags = O_RDONLY;
@@ -320,6 +323,7 @@ sp_open_shm (char *path, int id, mode_t perms, size_t size)
prot = PROT_READ | PROT_WRITE;
} else {
+ area->shm_area_name = strdup (path);
prot = PROT_READ;
}
@@ -353,7 +357,8 @@ sp_close_shm (ShmArea * area)
close (area->shm_fd);
if (area->shm_area_name) {
- shm_unlink (area->shm_area_name);
+ if (area->is_writer)
+ shm_unlink (area->shm_area_name);
free (area->shm_area_name);
}
@@ -935,6 +940,15 @@ sp_get_fd (ShmPipe * self)
return self->main_socket;
}
+const gchar *
+sp_get_shm_area_name (ShmPipe * self)
+{
+ if (self->shm_area)
+ return self->shm_area->shm_area_name;
+
+ return NULL;
+}
+
int
sp_writer_get_client_fd (ShmClient * client)
{
diff --git a/sys/shm/shmpipe.h b/sys/shm/shmpipe.h
index 6d7562972..1f746ac4b 100644
--- a/sys/shm/shmpipe.h
+++ b/sys/shm/shmpipe.h
@@ -91,6 +91,7 @@ int sp_writer_setperms_shm (ShmPipe * self, mode_t perms);
int sp_writer_resize (ShmPipe * self, size_t size);
int sp_get_fd (ShmPipe * self);
+const char *sp_get_shm_area_name (ShmPipe *self);
int sp_writer_get_client_fd (ShmClient * client);
ShmBlock *sp_writer_alloc_block (ShmPipe * self, size_t size);