summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst
diff options
context:
space:
mode:
authorJulien Moutte <julien@moutte.net>2004-01-27 21:24:14 +0000
committerJulien Moutte <julien@moutte.net>2004-01-27 21:24:14 +0000
commita7db4b61414aa0f59d001198e66bb421de0a0876 (patch)
tree96e1e85ae2ac8a08afda9d41dc68265cba0b1012 /gst-libs/gst
parent5a6674f100dba020a2ccc4fa8bbdca314e4b73ea (diff)
downloadgst-plugins-bad-a7db4b61414aa0f59d001198e66bb421de0a0876.tar.gz
gst-plugins-bad-a7db4b61414aa0f59d001198e66bb421de0a0876.tar.bz2
gst-plugins-bad-a7db4b61414aa0f59d001198e66bb421de0a0876.zip
gst-libs/gst/play/gstplay.c: Fixing the way to get current position.
Original commit message from CVS: 2004-01-27 Julien MOUTTE <julien@moutte.net> * gst-libs/gst/play/gstplay.c: (gst_play_tick_callback), (gst_play_seek_to_time): Fixing the way to get current position.
Diffstat (limited to 'gst-libs/gst')
-rw-r--r--gst-libs/gst/play/gstplay.c34
-rw-r--r--gst-libs/gst/play/play.c34
2 files changed, 46 insertions, 22 deletions
diff --git a/gst-libs/gst/play/gstplay.c b/gst-libs/gst/play/gstplay.c
index 16b0f009..d8658e49 100644
--- a/gst-libs/gst/play/gstplay.c
+++ b/gst-libs/gst/play/gstplay.c
@@ -311,8 +311,9 @@ gst_play_have_video_size (GstElement *element, gint width,
static gboolean
gst_play_tick_callback (GstPlay *play)
{
- GstElement* audio_sink_element;
- GstClockTime time;
+ GstFormat format = GST_FORMAT_TIME;
+ gboolean q = FALSE;
+ GstElement *audio_sink_element = NULL;
g_return_val_if_fail (play != NULL, FALSE);
@@ -323,11 +324,18 @@ gst_play_tick_callback (GstPlay *play)
audio_sink_element = g_hash_table_lookup (play->priv->elements,
"audio_sink_element");
- time = gst_element_get_time (audio_sink_element);
- play->priv->time_nanos = GST_CLOCK_TIME_IS_VALID (time) ? time : 0;
- g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
+ if (!GST_IS_ELEMENT (audio_sink_element)) {
+ play->priv->tick_id = 0;
+ return FALSE;
+ }
+
+ q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
+ &(play->priv->time_nanos));
+
+ if (q)
+ g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
+ 0,play->priv->time_nanos);
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING)
return TRUE;
@@ -643,11 +651,15 @@ gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
}
if (s) {
- GstClockTime time;
- time = gst_element_get_time (audio_sink_element);
- play->priv->time_nanos = GST_CLOCK_TIME_IS_VALID (time) ? time : 0;
- g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
+ GstFormat format = GST_FORMAT_TIME;
+ gboolean q = FALSE;
+
+ q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
+ &(play->priv->time_nanos));
+
+ if (q)
+ g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
+ 0,play->priv->time_nanos);
}
}
diff --git a/gst-libs/gst/play/play.c b/gst-libs/gst/play/play.c
index 16b0f009..d8658e49 100644
--- a/gst-libs/gst/play/play.c
+++ b/gst-libs/gst/play/play.c
@@ -311,8 +311,9 @@ gst_play_have_video_size (GstElement *element, gint width,
static gboolean
gst_play_tick_callback (GstPlay *play)
{
- GstElement* audio_sink_element;
- GstClockTime time;
+ GstFormat format = GST_FORMAT_TIME;
+ gboolean q = FALSE;
+ GstElement *audio_sink_element = NULL;
g_return_val_if_fail (play != NULL, FALSE);
@@ -323,11 +324,18 @@ gst_play_tick_callback (GstPlay *play)
audio_sink_element = g_hash_table_lookup (play->priv->elements,
"audio_sink_element");
- time = gst_element_get_time (audio_sink_element);
- play->priv->time_nanos = GST_CLOCK_TIME_IS_VALID (time) ? time : 0;
- g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
+ if (!GST_IS_ELEMENT (audio_sink_element)) {
+ play->priv->tick_id = 0;
+ return FALSE;
+ }
+
+ q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
+ &(play->priv->time_nanos));
+
+ if (q)
+ g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
+ 0,play->priv->time_nanos);
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING)
return TRUE;
@@ -643,11 +651,15 @@ gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
}
if (s) {
- GstClockTime time;
- time = gst_element_get_time (audio_sink_element);
- play->priv->time_nanos = GST_CLOCK_TIME_IS_VALID (time) ? time : 0;
- g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
+ GstFormat format = GST_FORMAT_TIME;
+ gboolean q = FALSE;
+
+ q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
+ &(play->priv->time_nanos));
+
+ if (q)
+ g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
+ 0,play->priv->time_nanos);
}
}