mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
srt: set cancellation in locked section
... to avoid race with wait which uses it with 'flushing' flag state semantics.
This commit is contained in:
parent
dbab2f9498
commit
dd3a25b473
4 changed files with 14 additions and 16 deletions
|
@ -1212,24 +1212,23 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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");
|
GST_DEBUG_OBJECT (srtobject->element, "waking up SRT");
|
||||||
|
|
||||||
/* Removing all socket descriptors from the monitoring list
|
/* Removing all socket descriptors from the monitoring list
|
||||||
* wakes up SRT's threads. We only have one to remove. */
|
* wakes up SRT's threads. We only have one to remove. */
|
||||||
srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock);
|
srt_epoll_remove_usock (srtobject->poll_id, srtobject->sock);
|
||||||
|
|
||||||
gst_structure_get_enum (srtobject->parameters, "mode",
|
/* connection is only waited for in listener mode,
|
||||||
GST_TYPE_SRT_CONNECTION_MODE, (gint *) & connection_mode);
|
* but there is no harm in raising signal in any case */
|
||||||
|
GST_OBJECT_LOCK (srtobject->element);
|
||||||
if (connection_mode == GST_SRT_CONNECTION_MODE_LISTENER) {
|
/* however, a race might be harmful ...
|
||||||
GST_OBJECT_LOCK (srtobject->element);
|
* the cancellation is used as 'flushing' flag here,
|
||||||
g_cond_signal (&srtobject->sock_cond);
|
* so make sure it is so detected by the intended part at proper time */
|
||||||
GST_OBJECT_UNLOCK (srtobject->element);
|
g_cancellable_cancel (cancellable);
|
||||||
}
|
g_cond_signal (&srtobject->sock_cond);
|
||||||
|
GST_OBJECT_UNLOCK (srtobject->element);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -118,7 +118,8 @@ gssize gst_srt_object_write (GstSRTObject * srtobject,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **err);
|
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);
|
GstStructure *gst_srt_object_get_stats (GstSRTObject * srtobject);
|
||||||
|
|
||||||
|
|
|
@ -223,8 +223,7 @@ gst_srt_sink_unlock (GstBaseSink * bsink)
|
||||||
{
|
{
|
||||||
GstSRTSink *self = GST_SRT_SINK (bsink);
|
GstSRTSink *self = GST_SRT_SINK (bsink);
|
||||||
|
|
||||||
g_cancellable_cancel (self->cancellable);
|
gst_srt_object_wakeup (self->srtobject, self->cancellable);
|
||||||
gst_srt_object_wakeup (self->srtobject);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,8 +218,7 @@ gst_srt_src_unlock (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
GstSRTSrc *self = GST_SRT_SRC (bsrc);
|
GstSRTSrc *self = GST_SRT_SRC (bsrc);
|
||||||
|
|
||||||
g_cancellable_cancel (self->cancellable);
|
gst_srt_object_wakeup (self->srtobject, self->cancellable);
|
||||||
gst_srt_object_wakeup (self->srtobject);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue