gst-libs/gst/play/gstplay.c: Fixing the way to get current position.
authorJulien Moutte <julien@moutte.net>
Tue, 27 Jan 2004 21:24:14 +0000 (21:24 +0000)
committerJulien Moutte <julien@moutte.net>
Tue, 27 Jan 2004 21:24:14 +0000 (21:24 +0000)
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.

ChangeLog
gst-libs/gst/play/gstplay.c
gst-libs/gst/play/play.c

index a5ea0c3c66a26326b88c05e78616b4c7aa0ae62d..dd05b4f8a3f4f2be340ab3c4207f92e66b0a8141 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
 2004-01-27  Benjamin Otte  <in7y118@public.uni-hamburg.de>
 
        * sys/oss/gstosssink.c: (gst_osssink_sink_query):
index 16b0f00998f3f2ef2615ceba8424993ca920bd62..d8658e49da62f0950937eaa008983663dcb5ed27 100644 (file)
@@ -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);
     }
   }
   
index 16b0f00998f3f2ef2615ceba8424993ca920bd62..d8658e49da62f0950937eaa008983663dcb5ed27 100644 (file)
@@ -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);
     }
   }