]> Devoid-pointer.net GitWeb - KLGD_FF_plugin.git/commitdiff
Skip effect that are to be processed later in the processing loop
authorMichal Malý <madcatxster@devoid-pointer.net>
Sun, 16 Aug 2015 10:56:18 +0000 (12:56 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sun, 16 Aug 2015 10:56:18 +0000 (12:56 +0200)
klgd_ff_plugin.c
klgd_ff_plugin_p.h

index 001d62b95baa85dbb3fb64ac7fc9c4a9198e8776..8404f2768139f64ee92d748ae4cdc0747b069998 100644 (file)
@@ -43,8 +43,6 @@ inline static bool ffpl_handle_timing(const struct klgd_plugin_private *priv, co
                case FF_INERTIA:
                case FF_SPRING:
                        return true;
-               default:
-                       return false;
                }
        }
 
@@ -536,6 +534,7 @@ static void ffpl_calculate_trip_times(struct ffpl_effect *eff, const unsigned lo
 
        eff->start_at = now + msecs_to_jiffies(ueff->replay.delay);
        eff->updated_at = eff->start_at;
+       eff->touch_at = eff->start_at;
 
        if (ueff->replay.delay)
                printk(KERN_NOTICE "KLGDFF: Delayed effect will be started at %lu, now: %lu\n", eff->start_at, now);
@@ -700,6 +699,11 @@ static int ffpl_handle_combinable_effects(struct klgd_plugin_private *priv, stru
                int ret;
                struct ffpl_effect *eff = &priv->effects[idx];
 
+               if (time_before(now, eff->touch_at)) {
+                       printk(KERN_NOTICE "KLGDFF: Combinable effect is to be processed at a later time, skipping\n");
+                       continue;
+               }
+
                if (eff->replace) {
                        /* Uncombinable effect is about to be replaced by a combinable one */
                        if (ffpl_process_memless(priv, &eff->latest)) {
@@ -1002,6 +1006,12 @@ static int ffpl_get_commands(struct klgd_plugin *self, struct klgd_command_strea
                struct ffpl_effect *eff = &priv->effects[idx];
 
                printk(KERN_NOTICE "KLGDFF: Processing effect %lu\n", idx);
+
+               if (time_before(now, eff->touch_at)) {
+                       printk(KERN_NOTICE "KLGDFF: Next change of the effect is schededuled for the future\n");
+                       continue;
+               }
+
                ret = ffpl_handle_state_change(priv, *s, eff, now);
                /* TODO: Do something useful with the return code */
                if (ret) {
@@ -1045,7 +1055,7 @@ static bool ffpl_get_update_time(struct klgd_plugin *self, const unsigned long n
                        eff->change = FFPL_TO_START;
                        break;
                case FFPL_TRIG_STOP:
-                       /* Small processing delays might cause us to miss the precise stop point */
+                       /* Small processing delays might make us to miss the precise stop point */
                        current_t = time_before(eff->stop_at, now) ? now : eff->stop_at;
                        eff->change = FFPL_TO_STOP;
                        eff->repeat--;
@@ -1058,6 +1068,8 @@ static bool ffpl_get_update_time(struct klgd_plugin *self, const unsigned long n
                        continue;
                }
 
+               eff->touch_at = current_t;
+
                if (!events++) {
                        printk(KERN_NOTICE "KLGDFF: First event\n");
                        *t = current_t;
index 25f8dd76c7a5bb4c3e430480f8ff745b3045b270..60dac459fda6f24287e68e6fc612e6716e7b896e 100644 (file)
@@ -41,6 +41,7 @@ struct ffpl_effect {
        unsigned long start_at;         /* Time when to start the effect - in jiffies */
        unsigned long stop_at;          /* Time when to stop the effect - in jiffies */
        unsigned long updated_at;       /* Time when the effect was recalculated last time - in jiffies */
+       unsigned long touch_at;         /* Time of the next modification of the effect - in jiffies */
        u16 playback_time;              /* Used internally by effect processor to calculate periods */
        bool recalculate;               /* Effect shall be recalculated in the respective processing loop */
 };