diff --git a/src/Qt/VideoCacheThread.cpp b/src/Qt/VideoCacheThread.cpp index 9c0aa9aa..a7336b07 100644 --- a/src/Qt/VideoCacheThread.cpp +++ b/src/Qt/VideoCacheThread.cpp @@ -28,7 +28,6 @@ namespace openshot , speed(0) , last_speed(1) , last_dir(1) // assume forward (+1) on first launch - , is_playing(false) , userSeeked(false) , requested_display_frame(1) , current_display_frame(1) @@ -46,18 +45,6 @@ namespace openshot { } - // Play the video - void VideoCacheThread::Play() - { - is_playing = true; - } - - // Stop the video - void VideoCacheThread::Stop() - { - is_playing = false; - } - // Is cache ready for playback (pre-roll) bool VideoCacheThread::isReady() { @@ -108,6 +95,13 @@ namespace openshot { if (start_preroll) { userSeeked = true; + + if (!reader->GetCache()->Contains(new_position)) + { + // If user initiated seek, and current frame not found ( + Timeline* timeline = static_cast(reader); + timeline->ClearAllCache(); + } } requested_display_frame = new_position; } @@ -218,7 +212,7 @@ namespace openshot CacheBase* cache = reader ? reader->GetCache() : nullptr; // If caching disabled or no reader, sleep briefly - if (!settings->ENABLE_PLAYBACK_CACHING || !cache || !is_playing) { + if (!settings->ENABLE_PLAYBACK_CACHING || !cache) { std::this_thread::sleep_for(double_micro_sec(50000)); continue; } diff --git a/src/Qt/VideoCacheThread.h b/src/Qt/VideoCacheThread.h index bfc0c490..1fd6decd 100644 --- a/src/Qt/VideoCacheThread.h +++ b/src/Qt/VideoCacheThread.h @@ -40,11 +40,11 @@ namespace openshot /// @return True if at least min_frames_ahead frames have been cached. bool isReady(); - /// Set is_playing = true, so run() will begin caching/playback. - void Play(); + /// Play method is unimplemented + void Play() {}; - /// Set is_playing = false, effectively pausing playback (caching still runs). - void Stop(); + /// Stop method is unimplemented + void Stop() {}; /** * @brief Set playback speed/direction. Positive = forward, negative = rewind, zero = pause. @@ -162,8 +162,6 @@ namespace openshot int speed; ///< Current playback speed (0=paused, >0 forward, <0 backward). int last_speed; ///< Last non-zero speed (for tracking). int last_dir; ///< Last direction sign (+1 forward, –1 backward). - - bool is_playing; ///< True if playback is “running” (affects thread loop, not caching). bool userSeeked; ///< True if Seek(..., true) was called (forces a cache reset). int64_t requested_display_frame; ///< Frame index the user requested.