Adds pause to replay_setup.
Adds functions to toggle and get pause state.
Adds stdin keys read - looks for space for pause toggle.
Adds replay pause to replay render loop.
#include <math.h>
#include <unistd.h>
#include <sys/time.h>
+#include <stdbool.h>
#include "c.h"
#include "xalloc.h"
size_t nlogs;
struct replay_step step; /* current step */
+ bool pause;
FILE *timing_fp;
const char *timing_filename;
struct replay_setup *replay_new_setup(void)
{
- return xcalloc(1, sizeof(struct replay_setup));
+ struct replay_setup *ret;
+ ret = xcalloc(1, sizeof(struct replay_setup));
+ ret->pause = false;
+ return ret;
}
void replay_free_setup(struct replay_setup *stp)
return step->size == 0 && step->type == 0;
}
+bool replay_get_is_paused(struct replay_setup *setup)
+{
+ assert(setup);
+ return setup->pause;
+}
+
+void replay_toggle_pause(struct replay_setup *setup)
+{
+ assert(setup);
+ setup->pause = !setup->pause;
+}
static int read_multistream_step(struct replay_step *step, FILE *f, char type)
{
#ifndef UTIL_LINUX_SCRIPT_PLAYUTILS_H
#define UTIL_LINUX_SCRIPT_PLAYUTILS_H
+#include <stdbool.h>
+
#include "c.h"
#include "debug.h"
int replay_emit_step_data(struct replay_setup *stp, struct replay_step *step, int fd);
+bool replay_get_is_paused(struct replay_setup *setup);
+void replay_toggle_pause(struct replay_setup *setup);
+
#endif /* UTIL_LINUX_SCRIPT_PLAYUTILS_H */
#include <sys/time.h>
#include <termios.h>
#include <fcntl.h>
+#include <wchar.h>
+#include <stdbool.h>
#include "c.h"
#include "xalloc.h"
main(int argc, char *argv[])
{
static const struct timeval mindelay = { .tv_sec = 0, .tv_usec = 100 };
+ static const struct timeval inputDelay = { .tv_sec = 0, .tv_usec = 100000 };
struct timeval maxdelay;
int isterm;
int saved_flag;
struct termios saved;
+ wint_t c;
struct replay_setup *setup = NULL;
struct replay_step *step = NULL;
char streams[6] = {0}; /* IOSI - in, out, signal,info */
isterm = setterm(&saved, &saved_flag);
do {
+ c = fgetwc(stdin);
+ switch (c) {
+ case ' ':
+ replay_toggle_pause(setup);
+ break;
+ }
+
+ if (replay_get_is_paused(setup))
+ {
+ delay_for(&inputDelay);
+ continue;
+ }
+
rc = replay_get_next_step(setup, streams, &step);
if (rc)
break;