summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-07-24 10:15:21 +0100
committerTim-Philipp Müller <tim@centricular.com>2015-07-24 10:15:21 +0100
commit2b0e71f4de1bfea0e4af470df243509e3bc8e56e (patch)
tree23ff3f7fe32c403158085f78b3b54bd6eac83a57 /tools
parentf9e6d38bf926332698c3f7f763135193452d035f (diff)
tools: gst-play: seek at least in steps of a second
In case of very short files we might end up seeking in steps of a fraction of a second, which is silly and gives the impression that seeking doesn't actually work. Make minimum seek step a second instead.
Diffstat (limited to 'tools')
-rw-r--r--tools/gst-play.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/gst-play.c b/tools/gst-play.c
index 9b9fe0687..bbcde1107 100644
--- a/tools/gst-play.c
+++ b/tools/gst-play.c
@@ -708,7 +708,7 @@ relative_seek (GstPlay * play, gdouble percent)
{
GstQuery *query;
gboolean seekable = FALSE;
- gint64 dur = -1, pos = -1;
+ gint64 dur = -1, pos = -1, step;
g_return_if_fail (percent >= -1.0 && percent <= 1.0);
@@ -727,7 +727,11 @@ relative_seek (GstPlay * play, gdouble percent)
if (!seekable || dur <= 0)
goto seek_failed;
- pos = pos + dur * percent;
+ step = dur * percent;
+ if (ABS (step) < GST_SECOND)
+ step = (percent < 0) ? -GST_SECOND : GST_SECOND;
+
+ pos = pos + step;
if (pos > dur) {
if (!play_next (play)) {
g_print ("\n%s\n", _("Reached end of play list."));