diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2018-01-11 11:11:22 +0100 |
---|---|---|
committer | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2018-01-11 12:57:33 +0100 |
commit | 9a78b471c09ef2d0bbd9a0f55650a1727911c0cf (patch) | |
tree | bf4beae14cfb57354ee3c138a6639e60ad26416e | |
parent | afaac7d9c03b3a82c8a5d3be01123de363216dde (diff) | |
download | gst-plugins-camera-n4-9a78b471c09ef2d0bbd9a0f55650a1727911c0cf.tar.gz gst-plugins-camera-n4-9a78b471c09ef2d0bbd9a0f55650a1727911c0cf.tar.bz2 gst-plugins-camera-n4-9a78b471c09ef2d0bbd9a0f55650a1727911c0cf.zip |
Make the code more explicit in gst_camerasrc_capture_stop()
This doesn't introduce any functional changes, we just simplify the code
and make it more explicit by removing local variables.
Change-Id: I331624f59c4fa2723b1de28db3b9b28d8dac18a8
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
-rw-r--r-- | camerasrc/src/gstcamerasrc.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/camerasrc/src/gstcamerasrc.c b/camerasrc/src/gstcamerasrc.c index a6c8df4..fdac3b7 100644 --- a/camerasrc/src/gstcamerasrc.c +++ b/camerasrc/src/gstcamerasrc.c @@ -916,10 +916,6 @@ static gboolean gst_camerasrc_capture_stop(GstCameraSrc *camerasrc) GST_DEBUG_OBJECT(camerasrc, "ENTERED"); if (camerasrc->mode == VIDEO_IN_MODE_CAPTURE) { - /* To guarantee buffers are valid before finishing */ - GMutex *lock_mutex = NULL; - int keeping_buffer_num = 0; - /* keep current stream for preview */ if (strcmp(camerasrc->format_name, "ITLV") == 0 && camerasrc->cap_fourcc == GST_MAKE_FOURCC('I','T','L','V')) { @@ -927,13 +923,10 @@ static gboolean gst_camerasrc_capture_stop(GstCameraSrc *camerasrc) return TRUE; } - lock_mutex = &camerasrc->buffer_lock; - - keeping_buffer_num = _DEFAULT_KEEPING_BUFFER; - - g_mutex_lock(lock_mutex); + /* To guarantee buffers are valid before finishing */ + g_mutex_lock(&camerasrc->buffer_lock); - while (camerasrc->num_live_buffers > keeping_buffer_num) { + while (camerasrc->num_live_buffers > _DEFAULT_KEEPING_BUFFER) { gint64 end_time; GST_INFO_OBJECT(camerasrc, "Wait until all live buffers are relased. (Tot=%d, Live=%d)", @@ -941,7 +934,7 @@ static gboolean gst_camerasrc_capture_stop(GstCameraSrc *camerasrc) end_time = g_get_monotonic_time () + _PREVIEW_BUFFER_WAIT_TIMEOUT; - if (!g_cond_wait_until(&camerasrc->buffer_cond, lock_mutex, end_time)) { + if (!g_cond_wait_until(&camerasrc->buffer_cond, &camerasrc->buffer_lock, end_time)) { GST_ERROR_OBJECT(camerasrc, "Buffer wait timeout[%d usec].(Live=%d) Skip waiting...", _PREVIEW_BUFFER_WAIT_TIMEOUT, camerasrc->num_live_buffers); break; @@ -952,7 +945,7 @@ static gboolean gst_camerasrc_capture_stop(GstCameraSrc *camerasrc) GST_INFO_OBJECT(camerasrc, "Waiting free buffer finished. (Live=%d)", camerasrc->num_live_buffers); - g_mutex_unlock(lock_mutex); + g_mutex_unlock(&camerasrc->buffer_lock); #ifdef _SPEED_UP_RAW_CAPTURE if (camerasrc->cap_stream_diff) { |