diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-02-10 16:46:50 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-02-10 16:46:50 +0100 |
commit | 1119f6ee4103990ccc55d521be08bdce10737c8e (patch) | |
tree | d2b9a31d43d6a1f832951a9c984127e27622211a /gst/camerabin/gstcamerabin.c | |
parent | 9fcfa6046d0e8e8ec89c32d7091b747088265d70 (diff) | |
parent | 1cbd755a2cd45531076c7b19ef194b77d5575cb0 (diff) | |
download | gstreamer-plugins-bad-1119f6ee4103990ccc55d521be08bdce10737c8e.tar.gz |
Merge branch 'master' into 0.11
Conflicts:
ext/chromaprint/gstchromaprint.c
ext/mpeg2enc/Makefile.am
ext/voaacenc/gstvoaacenc.c
gst/dvbsuboverlay/gstdvbsuboverlay.c
gst/mpegtsdemux/mpegtsbase.c
gst/sdp/gstsdpdemux.c
gst/videoparsers/gsth264parse.c
sys/d3dvideosink/d3dvideosink.c
tests/examples/camerabin/gst-camera-perf.c
tests/examples/camerabin/gst-camerabin-test.c
tests/examples/camerabin2/gst-camerabin2-test.c
tests/examples/mxf/mxfdemux-structure.c
tests/examples/scaletempo/demo-main.c
Diffstat (limited to 'gst/camerabin/gstcamerabin.c')
-rw-r--r-- | gst/camerabin/gstcamerabin.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 39cd2b91b..1a3e2a0f3 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -151,11 +151,16 @@ # include <config.h> #endif +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include <string.h> #include <stdlib.h> #include <gst/gst.h> #include <gst/tag/tag.h> +#include <gst/glib-compat-private.h> /* FIXME: include #include <gst/gst-i18n-plugin.h> and use _(" ") */ #include "gstcamerabin.h" @@ -210,9 +215,10 @@ static guint camerabin_signals[LAST_SIGNAL]; #define DEFAULT_FLAGS GST_CAMERABIN_FLAG_SOURCE_RESIZE | \ GST_CAMERABIN_FLAG_VIEWFINDER_SCALE | \ - GST_CAMERABIN_FLAG_AUDIO_CONVERSION | \ + GST_CAMERABIN_FLAG_VIEWFINDER_COLOR_CONVERSION | \ GST_CAMERABIN_FLAG_IMAGE_COLOR_CONVERSION | \ - GST_CAMERABIN_FLAG_VIDEO_COLOR_CONVERSION + GST_CAMERABIN_FLAG_VIDEO_COLOR_CONVERSION | \ + GST_CAMERABIN_FLAG_AUDIO_CONVERSION /* Using "bilinear" as default zoom method */ #define CAMERABIN_DEFAULT_ZOOM_METHOD 1 @@ -236,25 +242,37 @@ static guint camerabin_signals[LAST_SIGNAL]; GST_DEBUG_OBJECT ((c), "Processing counter incremented to: %d", \ (c)->processing_counter); \ if ((c)->processing_counter == 1) \ - g_object_notify (G_OBJECT (c), "idle"); \ + g_object_notify (G_OBJECT (c), "idle"); #define CAMERABIN_PROCESSING_DEC_UNLOCKED(c) \ (c)->processing_counter -= 1; \ GST_DEBUG_OBJECT ((c), "Processing counter decremented to: %d", \ (c)->processing_counter); \ g_assert ((c)->processing_counter >= 0); \ - if ((c)->processing_counter == 0) \ - g_object_notify (G_OBJECT (c), "idle"); \ + if ((c)->processing_counter == 0) { \ + g_cond_signal ((c)->idle_cond); \ + g_object_notify (G_OBJECT (c), "idle"); \ + } #define CAMERABIN_PROCESSING_INC(c) \ g_mutex_lock ((c)->capture_mutex); \ CAMERABIN_PROCESSING_INC_UNLOCKED ((c)); \ - g_mutex_unlock ((c)->capture_mutex); \ + g_mutex_unlock ((c)->capture_mutex); #define CAMERABIN_PROCESSING_DEC(c) \ g_mutex_lock ((c)->capture_mutex); \ CAMERABIN_PROCESSING_DEC_UNLOCKED ((c)); \ - g_mutex_unlock ((c)->capture_mutex); \ + g_mutex_unlock ((c)->capture_mutex); + +#define CAMERABIN_PROCESSING_WAIT_IDLE(c) \ + g_mutex_lock ((c)->capture_mutex); \ + if ((c)->processing_counter > 0) { \ + GST_DEBUG_OBJECT ((c), "Waiting for processing operations to finish %d", \ + (c)->processing_counter); \ + g_cond_wait ((c)->idle_cond, (c)->capture_mutex); \ + GST_DEBUG_OBJECT ((c), "Processing operations finished"); \ + } \ + g_mutex_unlock ((c)->capture_mutex); /* * static helper functions declaration @@ -933,6 +951,10 @@ camerabin_dispose_elements (GstCameraBin * camera) g_cond_free (camera->cond); camera->cond = NULL; } + if (camera->idle_cond) { + g_cond_free (camera->idle_cond); + camera->idle_cond = NULL; + } if (camera->filename) { g_string_free (camera->filename, TRUE); camera->filename = NULL; @@ -1607,6 +1629,9 @@ reset_video_capture_caps (GstCameraBin * camera) /* Interrupt ongoing capture */ gst_camerabin_do_stop (camera); + /* prevent image captures from being lost */ + CAMERABIN_PROCESSING_WAIT_IDLE (camera); + gst_element_get_state (GST_ELEMENT (camera), &state, &pending, 0); if (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING) { GST_INFO_OBJECT (camera, @@ -3348,6 +3373,7 @@ gst_camerabin_init (GstCameraBin * camera, GstCameraBinClass * gclass) /* concurrency control */ camera->capture_mutex = g_mutex_new (); camera->cond = g_cond_new (); + camera->idle_cond = g_cond_new (); camera->processing_counter = 0; /* pad names for output and input selectors */ @@ -3923,8 +3949,10 @@ gst_camerabin_change_state (GstElement * element, GstStateChange transition) } /* reset processing counter */ - GST_DEBUG_OBJECT (camera, "Reset processing counter to 0"); + GST_DEBUG_OBJECT (camera, "Reset processing counter from %d to 0", + camera->processing_counter); camera->processing_counter = 0; + g_cond_signal (camera->idle_cond); g_object_notify (G_OBJECT (camera), "idle"); g_mutex_unlock (camera->capture_mutex); |