diff --git a/ext/srt/gstsrtobject.c b/ext/srt/gstsrtobject.c index 86595eee10..164ca89b35 100644 --- a/ext/srt/gstsrtobject.c +++ b/ext/srt/gstsrtobject.c @@ -1212,24 +1212,23 @@ out: } void -gst_srt_object_wakeup (GstSRTObject * srtobject) +gst_srt_object_wakeup (GstSRTObject * srtobject, GCancellable * cancellable) { - GstSRTConnectionMode connection_mode = GST_SRT_CONNECTION_MODE_NONE; - GST_DEBUG_OBJECT (srtobject->element, "waking up SRT"); /* Removing all socket descriptors from the monitoring list * wakes up SRT's threads. We only have one to remove. */ srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock); - gst_structure_get_enum (srtobject->parameters, "mode", - GST_TYPE_SRT_CONNECTION_MODE, (gint *) & connection_mode); - - if (connection_mode == GST_SRT_CONNECTION_MODE_LISTENER) { - GST_OBJECT_LOCK (srtobject->element); - g_cond_signal (&srtobject->sock_cond); - GST_OBJECT_UNLOCK (srtobject->element); - } + /* connection is only waited for in listener mode, + * but there is no harm in raising signal in any case */ + GST_OBJECT_LOCK (srtobject->element); + /* however, a race might be harmful ... + * the cancellation is used as 'flushing' flag here, + * so make sure it is so detected by the intended part at proper time */ + g_cancellable_cancel (cancellable); + g_cond_signal (&srtobject->sock_cond); + GST_OBJECT_UNLOCK (srtobject->element); } static gboolean diff --git a/ext/srt/gstsrtobject.h b/ext/srt/gstsrtobject.h index c91c439eaa..86bc413c4d 100644 --- a/ext/srt/gstsrtobject.h +++ b/ext/srt/gstsrtobject.h @@ -118,7 +118,8 @@ gssize gst_srt_object_write (GstSRTObject * srtobject, GCancellable *cancellable, GError **err); -void gst_srt_object_wakeup (GstSRTObject * srtobject); +void gst_srt_object_wakeup (GstSRTObject * srtobject, + GCancellable *cancellable); GstStructure *gst_srt_object_get_stats (GstSRTObject * srtobject); diff --git a/ext/srt/gstsrtsink.c b/ext/srt/gstsrtsink.c index bd8159d268..4af2bb1a3b 100644 --- a/ext/srt/gstsrtsink.c +++ b/ext/srt/gstsrtsink.c @@ -223,8 +223,7 @@ gst_srt_sink_unlock (GstBaseSink * bsink) { GstSRTSink *self = GST_SRT_SINK (bsink); - g_cancellable_cancel (self->cancellable); - gst_srt_object_wakeup (self->srtobject); + gst_srt_object_wakeup (self->srtobject, self->cancellable); return TRUE; } diff --git a/ext/srt/gstsrtsrc.c b/ext/srt/gstsrtsrc.c index 73392b4c21..f929e3f013 100644 --- a/ext/srt/gstsrtsrc.c +++ b/ext/srt/gstsrtsrc.c @@ -218,8 +218,7 @@ gst_srt_src_unlock (GstBaseSrc * bsrc) { GstSRTSrc *self = GST_SRT_SRC (bsrc); - g_cancellable_cancel (self->cancellable); - gst_srt_object_wakeup (self->srtobject); + gst_srt_object_wakeup (self->srtobject, self->cancellable); return TRUE; }