tools: gst-play: keep configured playback rate and trick mode when seeking
authorTim-Philipp Müller <tim@centricular.com>
Sun, 24 May 2015 17:58:21 +0000 (18:58 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 24 May 2015 17:58:51 +0000 (18:58 +0100)
Instead of resetting rate to 1.0

tools/gst-play.c

index 4e955d0..f2b8ad6 100644 (file)
@@ -91,6 +91,8 @@ static gboolean play_timeout (gpointer user_data);
 static void play_about_to_finish (GstElement * playbin, gpointer user_data);
 static void play_reset (GstPlay * play);
 static void play_set_relative_volume (GstPlay * play, gdouble volume_step);
+static gboolean play_do_seek (GstPlay * play, gint64 pos, gdouble rate,
+    GstPlayTrickMode mode);
 
 /* *INDENT-OFF* */
 static void gst_play_printf (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
@@ -694,9 +696,8 @@ relative_seek (GstPlay * play, gdouble percent)
   } else {
     if (pos < 0)
       pos = 0;
-    if (!gst_element_seek_simple (play->playbin, GST_FORMAT_TIME,
-            GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, pos))
-      goto seek_failed;
+
+    play_do_seek (play, pos, play->rate, play->trick_mode);
   }
 
   return;
@@ -711,10 +712,6 @@ static gboolean
 play_set_rate_and_trick_mode (GstPlay * play, gdouble rate,
     GstPlayTrickMode mode)
 {
-  GstSeekFlags seek_flags;
-  GstQuery *query;
-  GstEvent *seek;
-  gboolean seekable = FALSE;
   gint64 pos = -1;
 
   g_return_val_if_fail (rate != 0, FALSE);
@@ -722,6 +719,17 @@ play_set_rate_and_trick_mode (GstPlay * play, gdouble rate,
   if (!gst_element_query_position (play->playbin, GST_FORMAT_TIME, &pos))
     return FALSE;
 
+  return play_do_seek (play, pos, rate, mode);
+}
+
+static gboolean
+play_do_seek (GstPlay * play, gint64 pos, gdouble rate, GstPlayTrickMode mode)
+{
+  GstSeekFlags seek_flags;
+  GstQuery *query;
+  GstEvent *seek;
+  gboolean seekable = FALSE;
+
   query = gst_query_new_seeking (GST_FORMAT_TIME);
   if (!gst_element_query (play->playbin, query)) {
     gst_query_unref (query);