diff --git a/gst/playback/gstplaysink.c b/gst/playback/gstplaysink.c index e23f572485..7484079c54 100644 --- a/gst/playback/gstplaysink.c +++ b/gst/playback/gstplaysink.c @@ -134,6 +134,7 @@ struct _GstPlaySink gboolean mute; gchar *font_desc; /* font description */ guint connection_speed; /* connection speed in bits/sec (0 = unknown) */ + gint count; }; struct _GstPlaySinkClass @@ -1603,6 +1604,7 @@ gst_play_sink_request_pad (GstPlaySink * playsink, GstPlaySinkType type) GstPad *res = NULL; gboolean created = FALSE; gboolean raw = FALSE; + gboolean activate = TRUE; GST_DEBUG_OBJECT (playsink, "request pad type %d", type); @@ -1658,6 +1660,19 @@ gst_play_sink_request_pad (GstPlaySink * playsink, GstPlaySinkType type) } res = playsink->text_pad; break; + case GST_PLAY_SINK_TYPE_FLUSHING: + { + gchar *padname; + + /* we need a unique padname for the flushing pad. */ + padname = g_strdup_printf ("flushing_%d", playsink->count); + res = gst_ghost_pad_new_no_target (padname, GST_PAD_SINK); + g_free (padname); + playsink->count++; + activate = FALSE; + created = TRUE; + break; + } default: res = NULL; break; @@ -1665,8 +1680,12 @@ gst_play_sink_request_pad (GstPlaySink * playsink, GstPlaySinkType type) GST_PLAY_SINK_UNLOCK (playsink); if (created && res) { + /* we have to add the pad when it's active or we get an error when the + * element is 'running' */ gst_pad_set_active (res, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (playsink), res); + if (!activate) + gst_pad_set_active (res, activate); } return res; @@ -1686,6 +1705,9 @@ gst_play_sink_release_pad (GstPlaySink * playsink, GstPad * pad) res = &playsink->audio_pad; } else if (pad == playsink->text_pad) { res = &playsink->text_pad; + } else { + /* try to release the given pad anyway, these could be the FLUSHING pads. */ + res = &pad; } GST_PLAY_SINK_UNLOCK (playsink); diff --git a/gst/playback/gstplaysink.h b/gst/playback/gstplaysink.h index 5bdda290bd..50585441c6 100644 --- a/gst/playback/gstplaysink.h +++ b/gst/playback/gstplaysink.h @@ -45,6 +45,7 @@ G_BEGIN_DECLS * @GST_PLAY_SINK_TYPE_VIDEO_RAW: a raw video pad * @GST_PLAY_SINK_TYPE_TEXT: a raw text pad * @GST_PLAY_SINK_TYPE_LAST: the last type + * @GST_PLAY_SINK_TYPE_FLUSHING: a flushing pad, used when shutting down * * Types of pads that can be requested from the sinks. */ @@ -54,7 +55,8 @@ typedef enum { GST_PLAY_SINK_TYPE_VIDEO = 2, GST_PLAY_SINK_TYPE_VIDEO_RAW = 3, GST_PLAY_SINK_TYPE_TEXT = 4, - GST_PLAY_SINK_TYPE_LAST = 5 + GST_PLAY_SINK_TYPE_LAST = 5, + GST_PLAY_SINK_TYPE_FLUSHING = 6 } GstPlaySinkType; typedef struct _GstPlaySink GstPlaySink;