diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2017-12-19 17:35:39 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2017-12-19 17:41:43 -0500 |
commit | e19e02db930d4992e43a46152f555af038dd2f72 (patch) | |
tree | a20adc0e92c52778b35daa7347042e5617a61ea8 | |
parent | 536cb125773f36ecc46815e72ffa7ae2bba783d7 (diff) |
shmsink: Block in preroll_wait on unlock
The correct behaviour of anything stuck in the ->render() function
between ->unlock() and ->unlock_stop() is to call
gst_base_sink_wait_preroll() and only return an error if this returns an
error, otherwise, it must continue where it left off!
https://bugzilla.gnome.org/show_bug.cgi?id=774950
-rw-r--r-- | sys/shm/gstshmsink.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/sys/shm/gstshmsink.c b/sys/shm/gstshmsink.c index c67cc50d6..5c68997f1 100644 --- a/sys/shm/gstshmsink.c +++ b/sys/shm/gstshmsink.c @@ -666,18 +666,31 @@ gst_shm_sink_render (GstBaseSink * bsink, GstBuffer * buf) GstFlowReturn ret = GST_FLOW_OK; GstMemory *memory = NULL; GstBuffer *sendbuf = NULL; + gsize written_bytes; GST_OBJECT_LOCK (self); while (self->wait_for_connection && !self->clients) { g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self)); - if (self->unlock) - goto flushing; + if (self->unlock) { + GST_OBJECT_UNLOCK (self); + ret = gst_base_sink_wait_preroll (bsink); + if (ret == GST_FLOW_OK) + GST_OBJECT_LOCK (self); + else + return ret; + } } while (!gst_shm_sink_can_render (self, GST_BUFFER_TIMESTAMP (buf))) { g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self)); - if (self->unlock) - goto flushing; + if (self->unlock) { + GST_OBJECT_UNLOCK (self); + ret = gst_base_sink_wait_preroll (bsink); + if (ret == GST_FLOW_OK) + GST_OBJECT_LOCK (self); + else + return ret; + } } @@ -709,16 +722,27 @@ gst_shm_sink_render (GstBaseSink * bsink, GstBuffer * buf) gst_shm_sink_allocator_alloc_locked (self->allocator, gst_buffer_get_size (buf), &self->params)) == NULL) { g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self)); - if (self->unlock) - goto flushing; + if (self->unlock) { + GST_OBJECT_UNLOCK (self); + ret = gst_base_sink_wait_preroll (bsink); + if (ret == GST_FLOW_OK) + GST_OBJECT_LOCK (self); + else + return ret; + } } while (self->wait_for_connection && !self->clients) { g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self)); if (self->unlock) { GST_OBJECT_UNLOCK (self); - gst_memory_unref (memory); - return GST_FLOW_FLUSHING; + ret = gst_base_sink_wait_preroll (bsink); + if (ret == GST_FLOW_OK) { + GST_OBJECT_LOCK (self); + } else { + gst_memory_unref (memory); + return ret; + } } } @@ -731,7 +755,7 @@ gst_shm_sink_render (GstBaseSink * bsink, GstBuffer * buf) GST_DEBUG_OBJECT (self, "Copying %" G_GSIZE_FORMAT " bytes into map of size %" G_GSIZE_FORMAT " bytes.", gst_buffer_get_size (buf), map.size); - gsize written_bytes = gst_buffer_extract (buf, 0, map.data, map.size); + written_bytes = gst_buffer_extract (buf, 0, map.data, map.size); GST_DEBUG_OBJECT (self, "Copied %" G_GSIZE_FORMAT " bytes.", written_bytes); gst_memory_unmap (memory, &map); @@ -776,10 +800,6 @@ gst_shm_sink_render (GstBaseSink * bsink, GstBuffer * buf) return ret; -flushing: - GST_OBJECT_UNLOCK (self); - return GST_FLOW_FLUSHING; - error: GST_OBJECT_UNLOCK (self); return GST_FLOW_ERROR; |