Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37600864
en ru br
ALT Linux repos
S:1.0.8-alt3

Group :: Terminals
RPM: ttyrec

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: 06_pause.diff
Download


Description: pause button (Implement speed == 0.0)
Author: Colin Watson <cjwatson@debian.org>
Bug-Debian: http://bugs.debian.org/457488
Reviewed-By: NIIBE Yutaka <gniibe@fsij.org>
Last-Update: 2010-04-27
    * ttyplay.c (ttywait): Implement a case where speed == 0.0.
    * ttyplay.c (ttynowait): Return 1.0 (was: 0).
    * ttyplay.c (ttyplay): Loop until speed != 0.0.
--- ttyrec-1.0.8.orig/ttyplay.c
+++ ttyrec-1.0.8/ttyplay.c
@@ -83,12 +83,16 @@
     static struct timeval drift = {0, 0};
     struct timeval start;
     struct timeval diff = timeval_diff(prev, cur);
+    struct timeval *diffp = &diff;
     fd_set readfs;
 
     gettimeofday(&start, NULL);
 
-    assert(speed != 0);
-    diff = timeval_diff(drift, timeval_div(diff, speed));
+    if (speed == 0)
+      diffp = NULL;
+    else
+      diff = timeval_diff(drift, timeval_div(diff, speed));
+
     if (diff.tv_sec < 0) {
 	diff.tv_sec = diff.tv_usec = 0;
     }
@@ -101,7 +105,7 @@
      * Save "diff" since select(2) may overwrite it to {0, 0}. 
      */
     struct timeval orig_diff = diff;
-    select(1, &readfs, NULL, NULL, &diff);
+    select(1, &readfs, NULL, NULL, diffp); /* skip if a user hits any key */
     diff = orig_diff;  /* Restore the original diff value. */
     if (FD_ISSET(0, &readfs)) { /* a user hits a character? */
         char c;
@@ -118,6 +122,9 @@
         case '1':
             speed = 1.0;
             break;
+        case '0':
+            speed = 0.0;
+            break;
         }
 	drift.tv_sec = drift.tv_usec = 0;
     } else {
@@ -136,7 +143,7 @@
 ttynowait (struct timeval prev, struct timeval cur, double speed)
 {
     /* do nothing */
-    return 0; /* Speed isn't important. */
+    return 1.0; /* Speed isn't important. */
 }
 
 int
@@ -202,7 +209,9 @@
 	}
 
 	if (!first_time) {
-	    speed = wait_func(prev, h.tv, speed);
+	    do {
+		speed = wait_func(prev, h.tv, speed);
+	    } while (speed == 0.0);
 	}
 	first_time = 0;
 
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin