From 99f1f4510a2784b1b1e4317c615f6d538a3454b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommi=20My=C3=B6h=C3=A4nen?= Date: Tue, 25 Aug 2009 09:35:07 +0300 Subject: [PATCH] camerabin: don't send multiple EOS events to video pipeline --- gst/camerabin/gstcamerabin.c | 20 ++++++++++++++------ gst/camerabin/gstcamerabin.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 6363a077ad..6d02850389 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -1646,11 +1646,17 @@ gst_camerabin_send_video_eos (GstCameraBin * camera) g_return_if_fail (camera != NULL); - /* Send eos event to video bin */ - GST_INFO_OBJECT (camera, "sending eos to videobin"); - videopad = gst_element_get_static_pad (camera->vidbin, "sink"); - gst_pad_send_event (videopad, gst_event_new_eos ()); - gst_object_unref (videopad); + if (!camera->eos_handled) { + /* Send eos event to video bin */ + GST_INFO_OBJECT (camera, "sending eos to videobin"); + videopad = gst_element_get_static_pad (camera->vidbin, "sink"); + gst_pad_send_event (videopad, gst_event_new_eos ()); + gst_object_unref (videopad); + camera->eos_handled = TRUE; + } + else { + GST_INFO_OBJECT (camera, "dropping duplicate EOS"); + } } /* @@ -1796,7 +1802,7 @@ gst_camerabin_have_vid_buffer (GstPad * pad, GstBuffer * buffer, gboolean ret = TRUE; GST_LOG ("got video buffer %p with size %d", buffer, GST_BUFFER_SIZE (buffer)); - if (camera->stop_requested) { + if (G_UNLIKELY (camera->stop_requested)) { gst_camerabin_send_video_eos (camera); ret = FALSE; /* Drop buffer */ } @@ -1951,6 +1957,7 @@ gst_camerabin_reset_to_view_finder (GstCameraBin * camera) /* Reset counters and flags */ camera->stop_requested = FALSE; camera->paused = FALSE; + camera->eos_handled = FALSE; /* Enable view finder mode in v4l2camsrc */ if (camera->src_vid_src && @@ -2687,6 +2694,7 @@ gst_camerabin_init (GstCameraBin * camera, GstCameraBinClass * gclass) camera->paused = FALSE; camera->capturing = FALSE; camera->night_mode = FALSE; + camera->eos_handled = FALSE; camera->width = DEFAULT_WIDTH; camera->height = DEFAULT_HEIGHT; diff --git a/gst/camerabin/gstcamerabin.h b/gst/camerabin/gstcamerabin.h index cfbb21bee2..7a656fba26 100644 --- a/gst/camerabin/gstcamerabin.h +++ b/gst/camerabin/gstcamerabin.h @@ -94,6 +94,7 @@ struct _GstCameraBin GMutex *capture_mutex; GCond *cond; gboolean capturing; + gboolean eos_handled; /* pad names for output and input selectors */ GstPad *pad_src_view;