examples/seeking/seek.c: Updated seek example.

Original commit message from CVS:
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(do_seek), (seek_cb), (stop_seek):
Updated seek example.

* gst/playback/gstdecodebin.c: (remove_element_chain), (unlinked):
* gst/playback/gstplaybasebin.c: (queue_threshold_reached),
(queue_out_of_data), (gen_preroll_element), (new_decoded_pad):
* gst/playback/gstplaybin.c: (add_sink):
* gst/playback/gststreaminfo.c: (gst_stream_info_dispose),
(gst_stream_info_set_mute):
Some refcount leak fixes.
This commit is contained in:
Wim Taymans 2005-07-18 10:53:03 +00:00
parent c84a6b964f
commit cfdcc450ca
7 changed files with 80 additions and 34 deletions

View file

@ -1,3 +1,18 @@
2005-07-18 Wim Taymans <wim@fluendo.com>
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(do_seek), (seek_cb), (stop_seek):
Updated seek example.
* gst/playback/gstdecodebin.c: (remove_element_chain), (unlinked):
* gst/playback/gstplaybasebin.c: (queue_threshold_reached),
(queue_out_of_data), (gen_preroll_element), (new_decoded_pad):
* gst/playback/gstplaybin.c: (add_sink):
* gst/playback/gststreaminfo.c: (gst_stream_info_dispose),
(gst_stream_info_set_mute):
Some refcount leak fixes.
2005-07-16 Wim Taymans <wim@fluendo.com> 2005-07-16 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstbaseaudiosink.c: * gst-libs/gst/audio/gstbaseaudiosink.c:

View file

@ -1005,7 +1005,9 @@ do_seek (GtkWidget * widget)
static void static void
seek_cb (GtkWidget * widget) seek_cb (GtkWidget * widget)
{ {
#ifdef SCRUB #ifndef SCRUB
GTimeVal timeval;
#else
/* If the timer hasn't expired yet, then the pipeline is running */ /* If the timer hasn't expired yet, then the pipeline is running */
if (seek_timeout_id != 0) { if (seek_timeout_id != 0) {
gst_element_set_state (pipeline, GST_STATE_PAUSED); gst_element_set_state (pipeline, GST_STATE_PAUSED);
@ -1014,6 +1016,12 @@ seek_cb (GtkWidget * widget)
do_seek (widget); do_seek (widget);
#ifndef SCRUB
/* wait for preroll */
GST_TIME_TO_TIMEVAL (50 * GST_MSECOND, timeval);
gst_element_get_state (pipeline, NULL, NULL, &timeval);
#endif
#ifdef SCRUB #ifdef SCRUB
gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_PLAYING);
@ -1047,8 +1055,9 @@ stop_seek (GtkWidget * widget, gpointer user_data)
gtk_timeout_remove (seek_timeout_id); gtk_timeout_remove (seek_timeout_id);
seek_timeout_id = 0; seek_timeout_id = 0;
/* Still scrubbing, so the pipeline is already playing */ /* Still scrubbing, so the pipeline is already playing */
} else } else {
gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
update_id = update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);

View file

@ -741,10 +741,11 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer));
{ {
GstElement *parent = gst_pad_get_parent (peer); GstObject *parent = gst_pad_get_parent (peer);
if (parent) { if (parent) {
if (parent != GST_ELEMENT (decode_bin)) { if (GST_IS_ELEMENT (parent)) {
if (parent != GST_OBJECT (decode_bin)) {
GST_DEBUG_OBJECT (decode_bin, "dead end pad %s:%s", GST_DEBUG_OBJECT (decode_bin, "dead end pad %s:%s",
GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_PAD_NAME (peer));
} else { } else {
@ -752,6 +753,7 @@ remove_element_chain (GstDecodeBin * decode_bin, GstPad * pad)
GST_ELEMENT_NAME (elem), GST_DEBUG_PAD_NAME (pad)); GST_ELEMENT_NAME (elem), GST_DEBUG_PAD_NAME (pad));
remove_element_chain (decode_bin, peer); remove_element_chain (decode_bin, peer);
} }
}
gst_object_unref (parent); gst_object_unref (parent);
} }
} }
@ -834,8 +836,8 @@ unlinked (GstPad * pad, GstPad * peerpad, GstDecodeBin * decode_bin)
/* inactivate pad */ /* inactivate pad */
gst_pad_set_active (pad, GST_ACTIVATE_NONE); gst_pad_set_active (pad, GST_ACTIVATE_NONE);
element = gst_pad_get_parent (pad); element = gst_pad_get_parent_element (pad);
peer = gst_pad_get_parent (peerpad); peer = gst_pad_get_parent_element (peerpad);
if (!is_our_kid (peer, decode_bin)) if (!is_our_kid (peer, decode_bin))
goto exit; goto exit;

View file

@ -499,7 +499,7 @@ queue_threshold_reached (GstElement * queue, GstPlayBaseBin * play_base_bin)
g_object_set_data (G_OBJECT (queue), "probe", NULL); g_object_set_data (G_OBJECT (queue), "probe", NULL);
gst_pad_remove_buffer_probe (sinkpad, G_CALLBACK (check_queue), queue); gst_pad_remove_buffer_probe (sinkpad, G_CALLBACK (check_queue), queue);
g_object_unref (G_OBJECT (sinkpad)); gst_object_unref (sinkpad);
} }
} }
@ -524,7 +524,7 @@ queue_out_of_data (GstElement * queue, GstPlayBaseBin * play_base_bin)
GST_DEBUG_OBJECT (play_base_bin, GST_DEBUG_OBJECT (play_base_bin,
"Re-attaching buffering probe to pad %s:%s", "Re-attaching buffering probe to pad %s:%s",
GST_DEBUG_PAD_NAME (sinkpad), sinkpad); GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
g_object_unref (G_OBJECT (sinkpad)); gst_object_unref (sinkpad);
fill_buffer (play_base_bin, 0); fill_buffer (play_base_bin, 0);
} }
@ -596,7 +596,7 @@ gen_preroll_element (GstPlayBaseBin * play_base_bin,
gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (check_queue), preroll); gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (check_queue), preroll);
GST_DEBUG_OBJECT (play_base_bin, "Attaching probe to pad %s:%s (%p)", GST_DEBUG_OBJECT (play_base_bin, "Attaching probe to pad %s:%s (%p)",
GST_DEBUG_PAD_NAME (sinkpad), sinkpad); GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
g_object_unref (G_OBJECT (sinkpad)); gst_object_unref (sinkpad);
g_object_set_data (G_OBJECT (preroll), "pbb", play_base_bin); g_object_set_data (G_OBJECT (preroll), "pbb", play_base_bin);
g_object_set_data (G_OBJECT (preroll), "probe", (gpointer) 0x1); g_object_set_data (G_OBJECT (preroll), "probe", (gpointer) 0x1);
@ -956,7 +956,7 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last,
/* keep a ref to the signal id so that we can disconnect the signal callback */ /* keep a ref to the signal id so that we can disconnect the signal callback */
g_object_set_data (G_OBJECT (sinkpad), "unlinked_id", GINT_TO_POINTER (sig)); g_object_set_data (G_OBJECT (sinkpad), "unlinked_id", GINT_TO_POINTER (sig));
gst_pad_link (pad, sinkpad); gst_pad_link (pad, sinkpad);
g_object_unref (G_OBJECT (sinkpad)); gst_object_unref (sinkpad);
/* add the stream to the list */ /* add the stream to the list */
gst_caps_unref (caps); gst_caps_unref (caps);

View file

@ -717,7 +717,7 @@ add_sink (GstPlayBin * play_bin, GstElement * sink, GstPad * srcpad)
{ {
GstPad *sinkpad; GstPad *sinkpad;
GstPadLinkReturn res; GstPadLinkReturn res;
GstElement *parent; GstObject *parent;
gst_bin_add (GST_BIN (play_bin), sink); gst_bin_add (GST_BIN (play_bin), sink);
@ -726,10 +726,15 @@ add_sink (GstPlayBin * play_bin, GstElement * sink, GstPad * srcpad)
res = gst_pad_link (srcpad, sinkpad); res = gst_pad_link (srcpad, sinkpad);
gst_object_unref (sinkpad); gst_object_unref (sinkpad);
/* this is only for debugging */
parent = gst_pad_get_parent (srcpad); parent = gst_pad_get_parent (srcpad);
if (parent) {
if (GST_IS_ELEMENT (parent)) {
GST_DEBUG ("Adding sink with state %d (parent: %d, peer: %d)\n", GST_DEBUG ("Adding sink with state %d (parent: %d, peer: %d)\n",
GST_STATE (sink), GST_STATE (play_bin), GST_STATE (parent)); GST_STATE (sink), GST_STATE (play_bin), GST_STATE (parent));
}
gst_object_unref (parent); gst_object_unref (parent);
}
/* try to link the pad of the sink to the stream */ /* try to link the pad of the sink to the stream */
if (res < 0) { if (res < 0) {

View file

@ -234,14 +234,16 @@ gst_stream_info_dispose (GObject * object)
stream_info = GST_STREAM_INFO (object); stream_info = GST_STREAM_INFO (object);
if (stream_info->object) { if (stream_info->object) {
GstElement *parent; GstObject *parent;
parent = gst_pad_get_parent ((GstPad *) parent = gst_pad_get_parent ((GstPad *)
GST_PAD_CAST (stream_info->object)); GST_PAD_CAST (stream_info->object));
if (parent != NULL) { if (parent != NULL) {
if (GST_IS_ELEMENT (parent)) {
g_signal_handlers_disconnect_by_func (parent, g_signal_handlers_disconnect_by_func (parent,
G_CALLBACK (stream_info_change_state), stream_info); G_CALLBACK (stream_info_change_state), stream_info);
g_object_unref (G_OBJECT (parent)); }
gst_object_unref (parent);
} }
gst_object_unref (stream_info->object); gst_object_unref (stream_info->object);
@ -291,7 +293,7 @@ gst_stream_info_set_mute (GstStreamInfo * stream_info, gboolean mute)
} }
if (mute != stream_info->mute) { if (mute != stream_info->mute) {
GstElement *element; GstObject *element;
stream_info->mute = mute; stream_info->mute = mute;
//gst_pad_set_active_recursive ((GstPad *) //gst_pad_set_active_recursive ((GstPad *)
@ -300,6 +302,8 @@ gst_stream_info_set_mute (GstStreamInfo * stream_info, gboolean mute)
element = gst_pad_get_parent ((GstPad *) element = gst_pad_get_parent ((GstPad *)
GST_PAD_CAST (stream_info->object)); GST_PAD_CAST (stream_info->object));
if (element) {
if (GST_IS_ELEMENT (element)) {
if (mute) { if (mute) {
g_signal_connect (element, "state-change", g_signal_connect (element, "state-change",
G_CALLBACK (stream_info_change_state), stream_info); G_CALLBACK (stream_info_change_state), stream_info);
@ -307,7 +311,9 @@ gst_stream_info_set_mute (GstStreamInfo * stream_info, gboolean mute)
g_signal_handlers_disconnect_by_func (element, g_signal_handlers_disconnect_by_func (element,
G_CALLBACK (stream_info_change_state), stream_info); G_CALLBACK (stream_info_change_state), stream_info);
} }
g_object_unref (G_OBJECT (element)); }
gst_object_unref (element);
}
} }
return TRUE; return TRUE;
} }

View file

@ -1005,7 +1005,9 @@ do_seek (GtkWidget * widget)
static void static void
seek_cb (GtkWidget * widget) seek_cb (GtkWidget * widget)
{ {
#ifdef SCRUB #ifndef SCRUB
GTimeVal timeval;
#else
/* If the timer hasn't expired yet, then the pipeline is running */ /* If the timer hasn't expired yet, then the pipeline is running */
if (seek_timeout_id != 0) { if (seek_timeout_id != 0) {
gst_element_set_state (pipeline, GST_STATE_PAUSED); gst_element_set_state (pipeline, GST_STATE_PAUSED);
@ -1014,6 +1016,12 @@ seek_cb (GtkWidget * widget)
do_seek (widget); do_seek (widget);
#ifndef SCRUB
/* wait for preroll */
GST_TIME_TO_TIMEVAL (50 * GST_MSECOND, timeval);
gst_element_get_state (pipeline, NULL, NULL, &timeval);
#endif
#ifdef SCRUB #ifdef SCRUB
gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_PLAYING);
@ -1047,8 +1055,9 @@ stop_seek (GtkWidget * widget, gpointer user_data)
gtk_timeout_remove (seek_timeout_id); gtk_timeout_remove (seek_timeout_id);
seek_timeout_id = 0; seek_timeout_id = 0;
/* Still scrubbing, so the pipeline is already playing */ /* Still scrubbing, so the pipeline is already playing */
} else } else {
gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
update_id = update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);