]> git.sesse.net Git - nageru/commitdiff
Only bother going into an ease if there is an actual speed change.
authorSteinar H. Gunderson <steinar+nageru@gunderson.no>
Sat, 14 Mar 2020 23:47:47 +0000 (00:47 +0100)
committerSteinar H. Gunderson <steinar+nageru@gunderson.no>
Sun, 15 Mar 2020 13:05:40 +0000 (14:05 +0100)
futatabi/player.cpp

index 982091d88595f32ee20c512f561c624c95bcac35..c5581b40a9a6f9462380cac98ac1243b496ff2b1 100644 (file)
@@ -154,6 +154,10 @@ public:
 
        void change_master_speed(double new_master_speed, Instant now);
 
+       float in_master_speed(float speed) const {
+               return (!in_easing && fabs(master_speed - speed) < 1e-6);
+       }
+
        // Instead of changing the speed instantly, change it over the course of
        // about 200 ms. This is a simple linear ramp; I tried various forms of
        // Bézier curves for more elegant/dramatic changing, but it seemed linear
@@ -334,7 +338,7 @@ void Player::play_playlist_once()
                        next_frame_start = instant.wallclock_time;
 
                        float new_master_speed = change_master_speed.exchange(0.0f / 0.0f);
-                       if (!std::isnan(new_master_speed)) {
+                       if (!std::isnan(new_master_speed) && !timeline.in_master_speed(new_master_speed)) {
                                timeline.start_easing(new_master_speed, instant);
                        }