gboolean text_pad_blocked;
GstPad *text_srcpad_stream_synchronizer;
GstPad *text_sinkpad_stream_synchronizer;
+ gulong text_block_id;
+ guint32 pending_blocked_pads;
+
/* properties */
GstElement *audio_sink;
GstElement *video_sink;
return raw;
}
+static GstProbeReturn
+sinkpad_blocked_cb (GstPad * blockedpad, GstProbeType type, gpointer type_data,
+ gpointer user_data);
+
static void
-sinkpad_blocked_cb (GstPad * blockedpad, gboolean blocked, gpointer user_data)
+video_set_blocked (GstPlaySink * playsink, gboolean blocked)
+{
+ if (playsink->video_pad) {
+ GstPad *opad =
+ GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
+ (playsink->video_pad)));
+ if (blocked && playsink->video_block_id == 0) {
+ playsink->video_block_id =
+ gst_pad_add_probe (opad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
+ gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
+ } else if (!blocked && playsink->video_block_id) {
+ gst_pad_remove_probe (opad, playsink->video_block_id);
++ PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO_RAW);
++ PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO);
+ playsink->video_block_id = 0;
+ playsink->video_pad_blocked = FALSE;
+ }
+ gst_object_unref (opad);
+ }
+}
+
+static void
+audio_set_blocked (GstPlaySink * playsink, gboolean blocked)
+{
+ if (playsink->audio_pad) {
+ GstPad *opad =
+ GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
+ (playsink->audio_pad)));
+ if (blocked && playsink->audio_block_id == 0) {
+ playsink->audio_block_id =
+ gst_pad_add_probe (opad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
+ gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
+ } else if (!blocked && playsink->audio_block_id) {
+ gst_pad_remove_probe (opad, playsink->audio_block_id);
++ PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO_RAW);
++ PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO);
+ playsink->audio_block_id = 0;
+ playsink->audio_pad_blocked = FALSE;
+ }
+ gst_object_unref (opad);
+ }
+}
+
+static void
+text_set_blocked (GstPlaySink * playsink, gboolean blocked)
+{
+ if (playsink->text_pad) {
+ GstPad *opad =
+ GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
+ (playsink->text_pad)));
+ if (blocked && playsink->text_block_id == 0) {
+ playsink->text_block_id =
+ gst_pad_add_probe (opad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
+ gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
+ } else if (!blocked && playsink->text_block_id) {
+ gst_pad_remove_probe (opad, playsink->text_block_id);
++ PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_TEXT);
+ playsink->text_block_id = 0;
+ playsink->text_pad_blocked = FALSE;
+ }
+ gst_object_unref (opad);
+ }
+}
+
+static GstProbeReturn
+sinkpad_blocked_cb (GstPad * blockedpad, GstProbeType type, gpointer type_data,
+ gpointer user_data)
{
GstPlaySink *playsink = (GstPlaySink *) user_data;
GstPad *pad;
pad = GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (blockedpad)));
if (pad == playsink->video_pad) {
- playsink->video_pad_blocked = blocked;
- GST_DEBUG_OBJECT (pad, "Video pad blocked: %d", blocked);
- if (!blocked) {
- PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO_RAW);
- PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO);
- }
+ playsink->video_pad_blocked = TRUE;
+ GST_DEBUG_OBJECT (pad, "Video pad blocked");
} else if (pad == playsink->audio_pad) {
- playsink->audio_pad_blocked = blocked;
- GST_DEBUG_OBJECT (pad, "Audio pad blocked: %d", blocked);
- if (!blocked) {
- PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO_RAW);
- PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO);
- }
+ playsink->audio_pad_blocked = TRUE;
+ GST_DEBUG_OBJECT (pad, "Audio pad blocked");
} else if (pad == playsink->text_pad) {
- playsink->text_pad_blocked = blocked;
- GST_DEBUG_OBJECT (pad, "Text pad blocked: %d", blocked);
- if (!blocked)
- PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_TEXT);
- }
-
- if (!blocked) {
- gst_object_unref (pad);
- GST_PLAY_SINK_UNLOCK (playsink);
- return;
+ playsink->text_pad_blocked = TRUE;
+ GST_DEBUG_OBJECT (pad, "Text pad blocked");
}
- if ((!playsink->video_pad || playsink->video_pad_blocked) &&
- (!playsink->audio_pad || playsink->audio_pad_blocked) &&
- (!playsink->text_pad || playsink->text_pad_blocked)) {
+ /* We reconfigure when for ALL streams:
+ * * there isn't a pad
+ * * OR the pad is blocked
+ * * OR there are no pending blocks on that pad
+ */
+
+ if ((!playsink->video_pad || playsink->video_pad_blocked
+ || !PENDING_VIDEO_BLOCK (playsink)) && (!playsink->audio_pad
+ || playsink->audio_pad_blocked || !PENDING_AUDIO_BLOCK (playsink))
+ && (!playsink->text_pad || playsink->text_pad_blocked
+ || !PENDING_TEXT_BLOCK (playsink))) {
GST_DEBUG_OBJECT (playsink, "All pads blocked -- reconfiguring");
if (playsink->video_pad) {
GstPad *blockpad =
GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (res)));
- gst_pad_set_blocked_async_full (blockpad, TRUE, sinkpad_blocked_cb,
+ *block_id =
+ gst_pad_add_probe (blockpad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
+ PENDING_FLAG_SET (playsink, type);
gst_object_unref (blockpad);
}
if (!activate)