mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
camerabin2: protect image location list with mutex
Rename the image taglists' mutex into image capture mutex and use it also for the image capture list to prevent concurrent access from different threads (application and capture threads).
This commit is contained in:
parent
27e01e02a4
commit
c7db5db632
2 changed files with 13 additions and 10 deletions
|
@ -401,8 +401,10 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
|
|||
}
|
||||
} else {
|
||||
/* store the next capture buffer filename */
|
||||
g_mutex_lock (camerabin->image_capture_mutex);
|
||||
camerabin->image_location_list =
|
||||
g_slist_append (camerabin->image_location_list, g_strdup (location));
|
||||
g_mutex_unlock (camerabin->image_capture_mutex);
|
||||
}
|
||||
|
||||
if (camerabin->post_previews) {
|
||||
|
@ -433,11 +435,11 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
|
|||
if (camerabin->mode == MODE_IMAGE) {
|
||||
/* Store image tags in a list and push them later, this prevents
|
||||
start_capture() from blocking in pad_push_event call */
|
||||
g_mutex_lock (camerabin->image_tags_mutex);
|
||||
g_mutex_lock (camerabin->image_capture_mutex);
|
||||
camerabin->image_tags_list =
|
||||
g_slist_append (camerabin->image_tags_list,
|
||||
taglist ? gst_tag_list_copy (taglist) : NULL);
|
||||
g_mutex_unlock (camerabin->image_tags_mutex);
|
||||
g_mutex_unlock (camerabin->image_capture_mutex);
|
||||
} else if (taglist) {
|
||||
GstPad *active_pad;
|
||||
|
||||
|
@ -532,7 +534,7 @@ gst_camera_bin_dispose (GObject * object)
|
|||
|
||||
g_free (camerabin->location);
|
||||
g_mutex_free (camerabin->preview_list_mutex);
|
||||
g_mutex_free (camerabin->image_tags_mutex);
|
||||
g_mutex_free (camerabin->image_capture_mutex);
|
||||
|
||||
if (camerabin->src_capture_notify_id)
|
||||
g_signal_handler_disconnect (camerabin->src,
|
||||
|
@ -889,7 +891,7 @@ gst_camera_bin_init (GstCameraBin2 * camera)
|
|||
camera->max_zoom = MAX_ZOOM;
|
||||
camera->flags = DEFAULT_FLAGS;
|
||||
camera->preview_list_mutex = g_mutex_new ();
|
||||
camera->image_tags_mutex = g_mutex_new ();
|
||||
camera->image_capture_mutex = g_mutex_new ();
|
||||
|
||||
/* capsfilters are created here as we proxy their caps properties and
|
||||
* this way we avoid having to store the caps while on NULL state to
|
||||
|
@ -1273,14 +1275,14 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
|
|||
GstPad *peer;
|
||||
GstTagList *tags;
|
||||
|
||||
g_mutex_lock (camerabin->image_capture_mutex);
|
||||
|
||||
/* Push pending image tags */
|
||||
g_mutex_lock (camerabin->image_tags_mutex);
|
||||
if (camerabin->image_tags_list) {
|
||||
tags = camerabin->image_tags_list->data;
|
||||
camerabin->image_tags_list =
|
||||
g_slist_delete_link (camerabin->image_tags_list,
|
||||
camerabin->image_tags_list);
|
||||
g_mutex_unlock (camerabin->image_tags_mutex);
|
||||
GST_DEBUG_OBJECT (camerabin, "Pushing tags from application: %"
|
||||
GST_PTR_FORMAT, tags);
|
||||
if (tags) {
|
||||
|
@ -1289,7 +1291,6 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
|
|||
gst_object_unref (peer);
|
||||
}
|
||||
} else {
|
||||
g_mutex_unlock (camerabin->image_tags_mutex);
|
||||
GST_DEBUG_OBJECT (camerabin, "No tags from application to send");
|
||||
}
|
||||
|
||||
|
@ -1303,8 +1304,10 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
|
|||
location);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (camerabin, "No filename location change to send");
|
||||
g_mutex_unlock (camerabin->image_capture_mutex);
|
||||
return ret;
|
||||
}
|
||||
g_mutex_unlock (camerabin->image_capture_mutex);
|
||||
|
||||
if (location) {
|
||||
evt = gst_camera_bin_new_event_file_location (location);
|
||||
|
@ -1808,16 +1811,16 @@ gst_camera_bin_change_state (GstElement * element, GstStateChange trans)
|
|||
gst_tag_setter_reset_tags (GST_TAG_SETTER (camera));
|
||||
GST_CAMERA_BIN2_RESET_PROCESSING_COUNTER (camera);
|
||||
|
||||
g_mutex_lock (camera->image_capture_mutex);
|
||||
g_slist_foreach (camera->image_location_list, (GFunc) g_free, NULL);
|
||||
g_slist_free (camera->image_location_list);
|
||||
camera->image_location_list = NULL;
|
||||
|
||||
g_mutex_lock (camera->image_tags_mutex);
|
||||
g_slist_foreach (camera->image_tags_list,
|
||||
(GFunc) _gst_tag_list_free_maybe, NULL);
|
||||
g_slist_free (camera->image_tags_list);
|
||||
camera->image_tags_list = NULL;
|
||||
g_mutex_unlock (camera->image_tags_mutex);
|
||||
g_mutex_unlock (camera->image_capture_mutex);
|
||||
|
||||
g_mutex_lock (camera->preview_list_mutex);
|
||||
g_slist_foreach (camera->preview_location_list, (GFunc) g_free, NULL);
|
||||
|
|
|
@ -89,12 +89,12 @@ struct _GstCameraBin2
|
|||
/* Index of the auto incrementing file index for captures */
|
||||
gint capture_index;
|
||||
|
||||
GMutex *image_capture_mutex;
|
||||
/* stores list of image locations to be pushed to the image sink
|
||||
* as file location change notifications, they are pushed before
|
||||
* each buffer capture */
|
||||
GSList *image_location_list;
|
||||
/* Store also tags and push them before each captured image */
|
||||
GMutex *image_tags_mutex;
|
||||
GSList *image_tags_list;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue