mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
camerabin2: Improve idle property usage
Use resource warning messages to notify camerabin2 that a capture as aborted or couldn't be started, making it decrement the processing counter and making the idle property more reliable.
This commit is contained in:
parent
6913db30f8
commit
aa7b962891
3 changed files with 32 additions and 10 deletions
|
@ -252,6 +252,9 @@ gst_base_camera_src_start_capture (GstBaseCameraSrc * src)
|
|||
if (src->capturing) {
|
||||
GST_WARNING_OBJECT (src, "Capturing already ongoing");
|
||||
g_mutex_unlock (src->capturing_mutex);
|
||||
|
||||
/* post a warning to notify camerabin2 that the capture failed */
|
||||
GST_ELEMENT_WARNING (src, RESOURCE, BUSY, (NULL), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -691,7 +691,8 @@ gst_image_capture_bin_post_image_done (GstCameraBin * camera,
|
|||
static void
|
||||
gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
|
||||
{
|
||||
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
|
||||
switch (GST_MESSAGE_TYPE (message)) {
|
||||
case GST_MESSAGE_ELEMENT:{
|
||||
const GstStructure *structure = gst_message_get_structure (message);
|
||||
const gchar *filename;
|
||||
|
||||
|
@ -704,6 +705,21 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GST_MESSAGE_WARNING:{
|
||||
GError *err = NULL;
|
||||
gchar *debug = NULL;
|
||||
|
||||
gst_message_parse_warning (message, &err, &debug);
|
||||
if (err->domain == GST_RESOURCE_ERROR) {
|
||||
/* some capturing failed */
|
||||
GST_CAMERA_BIN_PROCESSING_DEC (GST_CAMERA_BIN_CAST (bin));
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (message)
|
||||
GST_BIN_CLASS (parent_class)->handle_message (bin, message);
|
||||
}
|
||||
|
||||
|
|
|
@ -1059,6 +1059,8 @@ GST_START_TEST (test_idle_property)
|
|||
|
||||
/* emit a second start-capture that should be ignored */
|
||||
g_signal_emit_by_name (camera, "start-capture", NULL);
|
||||
g_object_get (camera, "idle", &idle, NULL);
|
||||
fail_unless (!idle);
|
||||
|
||||
/* Record for one seconds */
|
||||
g_timeout_add_seconds (VIDEO_DURATION, (GSourceFunc) g_main_loop_quit,
|
||||
|
@ -1069,6 +1071,7 @@ GST_START_TEST (test_idle_property)
|
|||
|
||||
check_preview_image ();
|
||||
|
||||
g_usleep (3 * G_USEC_PER_SEC);
|
||||
g_object_get (camera, "idle", &idle, NULL);
|
||||
fail_unless (idle);
|
||||
|
||||
|
|
Loading…
Reference in a new issue