summaryrefslogtreecommitdiff
path: root/gst/base
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2005-09-07 10:06:56 +0000
committerAndy Wingo <wingo@pobox.com>2005-09-07 10:06:56 +0000
commitc477a458d7c50f45f55469b94af945cf7b83cf52 (patch)
tree9202824eb84f97bea1a51963b4bb8f5440d92637 /gst/base
parent9f96921e901ad95a33cdbed8851a60e0c640f2d5 (diff)
gst/base/gstbasesink.c (gst_base_sink_activate_pull): Fix a race condition whereby the pad's task function is entered...
Original commit message from CVS: 2005-09-07 Andy Wingo <wingo@pobox.com> * gst/base/gstbasesink.c (gst_base_sink_activate_pull): Fix a race condition whereby the pad's task function is entered before the pad_mode variable was set.
Diffstat (limited to 'gst/base')
-rw-r--r--gst/base/gstbasesink.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gst/base/gstbasesink.c b/gst/base/gstbasesink.c
index b8964c8013..d3048cb3e0 100644
--- a/gst/base/gstbasesink.c
+++ b/gst/base/gstbasesink.c
@@ -1232,21 +1232,28 @@ gst_base_sink_activate_pull (GstPad * pad, gboolean active)
if (G_UNLIKELY (peer == NULL)) {
g_warning ("Trying to activate pad in pull mode, but no peer");
result = FALSE;
+ basesink->pad_mode = GST_ACTIVATE_NONE;
} else {
if (gst_pad_activate_pull (peer, TRUE)) {
basesink->have_newsegment = TRUE;
basesink->segment_start = basesink->segment_stop = 0;
+
+ /* set the pad mode before starting the task so that it's in the
+ correct state for the new thread... */
+ basesink->pad_mode = GST_ACTIVATE_PULL;
result =
gst_pad_start_task (pad, (GstTaskFunction) gst_base_sink_loop,
pad);
+ /* but if starting the thread fails, set it back */
+ if (!result)
+ basesink->pad_mode = GST_ACTIVATE_NONE;
} else {
GST_DEBUG_OBJECT (pad, "Failed to activate peer in pull mode");
result = FALSE;
+ basesink->pad_mode = GST_ACTIVATE_NONE;
}
gst_object_unref (peer);
}
-
- basesink->pad_mode = result ? GST_ACTIVATE_PULL : GST_ACTIVATE_NONE;
}
} else {
if (G_UNLIKELY (basesink->pad_mode != GST_ACTIVATE_PULL)) {