summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <Jiri Olsa jolsa@redhat.com>2010-04-06 09:40:32 +0200
committerJiri Olsa <Jiri Olsa jolsa@redhat.com>2010-04-06 09:40:32 +0200
commit2db562a5587d7e5ca8ca0436c9678f8141734e04 (patch)
tree813b689388c3dafef4e81f21177c89d7fa7c5e93
parent7ba0df8974d8a7bba3949f38134eeb14de36ba0a (diff)
downloadtsnif-2db562a5587d7e5ca8ca0436c9678f8141734e04.tar.gz
tsnif-2db562a5587d7e5ca8ca0436c9678f8141734e04.tar.xz
tsnif-2db562a5587d7e5ca8ca0436c9678f8141734e04.zip
replay fix - stop on 'prev' command
-rw-r--r--src/tsnif-replay.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/tsnif-replay.c b/src/tsnif-replay.c
index a0ec61e..40db4da 100644
--- a/src/tsnif-replay.c
+++ b/src/tsnif-replay.c
@@ -97,6 +97,7 @@ static struct timeval get_timeout(struct timespec *ts_new,
enum {
ACTION_NEXT,
ACTION_PREV,
+ ACTION_PLAY,
ACTION_FIRST,
ACTION_TIMEOUT,
ACTION_STOP,
@@ -108,6 +109,7 @@ enum {
static int display_slave = 1;
static int display_master= 0;
+static int play = 1;
static int output(struct tsnif_storage_rec *rec)
{
@@ -150,6 +152,7 @@ static int get_action(struct timeval *tv)
}
switch(c) {
+ case 'P' : return ACTION_PLAY;
case 'p' : return ACTION_PREV;
case 'n' : return ACTION_NEXT;
case 'f' : return ACTION_FIRST;
@@ -175,30 +178,46 @@ static int process(void)
do {
struct timespec ts_prev;
- struct timeval tv;
-
- memset(&tv, 0x0, sizeof(tv));
+ struct timeval tv_def, *tv = NULL;
if (err != TSNIF_STORAGE_READ_EOF) {
+
output(&rec);
- ts_prev = rec.time;
+ if (play) {
+ tv = &tv_def;
+ memset(tv, 0x0, sizeof(*tv));
+ ts_prev = rec.time;
- err = tsnif_storage_read(&storage_handle,
- TSNIF_STORAGE_READ_NEXT, &rec);
- if (err < 0)
- break;
+ err = tsnif_storage_read(&storage_handle,
+ TSNIF_STORAGE_READ_NEXT, &rec);
+ if (err < 0)
+ break;
- tv = get_timeout(&rec.time, &ts_prev);
+ *tv = get_timeout(&rec.time, &ts_prev);
+ }
}
- action = get_action(&tv);
+ action = get_action(tv);
+
switch(action) {
+ case ACTION_PLAY:
+ play = !play;
+ break;
+
case ACTION_PREV:
err = tsnif_storage_read(&storage_handle,
TSNIF_STORAGE_READ_PREV, &rec);
if (err < 0)
return err;
+
+ /* we reached the first item, do not report
+ * XXX different code for first item ??? */
+ if (err == TSNIF_STORAGE_READ_EOF)
+ err = 0;
+
+ /* stop play mode when going back */
+ play = 0;
break;
case ACTION_SLAVE: