Skip to content

Commit ca98225

Browse files
committed
fakenect: replay index in an endless loop
When the last line has been handled then the index gets closed and any 'prev' state is reset so that the next call to freenect_process_events will re-open the index and start again from the first frame. Since the Kinect camera doesn't normally spontaneously stop this seems like a more natural behaviour. Signed-off-by: Robert Bragg <robert@impossible.com>
1 parent cc563b5 commit ca98225

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

fakenect/fakenect.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ static void open_index()
157157
free(index_path);
158158
}
159159

160+
static void close_index()
161+
{
162+
fclose(index_fp);
163+
index_fp = NULL;
164+
record_prev_time = 0;
165+
playback_prev_time = 0;
166+
}
167+
160168
static char *skip_line(char *str)
161169
{
162170
char *out = strchr(str, '\n');
@@ -211,8 +219,10 @@ int freenect_process_events(freenect_context *ctx)
211219
double record_cur_time;
212220
unsigned int timestamp, data_size;
213221
char *data = NULL;
214-
if (parse_line(&type, &record_cur_time, &timestamp, &data_size, &data))
215-
return -1;
222+
if (parse_line(&type, &record_cur_time, &timestamp, &data_size, &data)) {
223+
close_index();
224+
return 0;
225+
}
216226
// Sleep an amount that compensates for the original and current delays
217227
// playback_ is w.r.t. the current time
218228
// record_ is w.r.t. the original time period during the recording

0 commit comments

Comments
 (0)