From 36d23b5dc2a6a73d9e270bfc0090bbeed5144409 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Mon, 8 Jan 2024 19:25:29 +0100 Subject: [PATCH] Bugfix seek media player --- src/MediaPlayer.cpp | 20 +++++++++----------- src/Settings.h | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/MediaPlayer.cpp b/src/MediaPlayer.cpp index 6868e3d..e09d184 100644 --- a/src/MediaPlayer.cpp +++ b/src/MediaPlayer.cpp @@ -1335,25 +1335,23 @@ void MediaPlayer::execute_seek_command(GstClockTime target, bool force) if ( pipeline_ == nullptr || !media_.seekable ) return; + // ignore request to current position + if ( ABS_DIFF(target, position_) < timeline_.step()) + return; + // seek position : default to target GstClockTime seek_pos = target; - // no target given - if (target == GST_CLOCK_TIME_NONE) - // create seek event with current position (rate changed ?) - seek_pos = position_; - // target is given but useless - else if ( ABS_DIFF(target, position_) < timeline_.step()) { - // ignore request - return; - } - // seek with flush (always) int seek_flags = GST_SEEK_FLAG_FLUSH; - if ( desired_state_ == GST_STATE_PLAYING ) + // no target given + if (target == GST_CLOCK_TIME_NONE) { + // create seek event with current position (rate changed ?) + seek_pos = position_; // seek with KEY mode if playing seek_flags |= GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_SNAP_AFTER; + } else // seek with accurate timing if paused seek_flags |= GST_SEEK_FLAG_ACCURATE; diff --git a/src/Settings.h b/src/Settings.h index f80da6d..42c55b8 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -212,7 +212,7 @@ struct SourceConfig SourceConfig() { new_type = 0; ratio = 3; - res = 1; + res = 6; capture_naming = 0; inspector_zoom = 8.f; }