linux-v4l2: Make frame counter local.

This replaces the var in the source struct that was used to print out
the number of captured frames with a local one.
master
fryshorts 2014-10-25 16:48:21 +02:00 committed by jp9000
parent 45583a759a
commit 1945804624
1 changed files with 6 additions and 8 deletions

View File

@ -71,9 +71,6 @@ struct v4l2_data {
int height; int height;
int linesize; int linesize;
struct v4l2_buffer_data buffers; struct v4l2_buffer_data buffers;
/* statistics */
uint64_t frames;
}; };
/* forward declarations */ /* forward declarations */
@ -139,6 +136,7 @@ static void *v4l2_thread(void *vptr)
int r; int r;
fd_set fds; fd_set fds;
uint8_t *start; uint8_t *start;
uint64_t frames;
uint64_t first_ts; uint64_t first_ts;
struct timeval tv; struct timeval tv;
struct v4l2_buffer buf; struct v4l2_buffer buf;
@ -148,8 +146,8 @@ static void *v4l2_thread(void *vptr)
if (v4l2_start_capture(data->dev, &data->buffers) < 0) if (v4l2_start_capture(data->dev, &data->buffers) < 0)
goto exit; goto exit;
first_ts = 0; frames = 0;
data->frames = 0; first_ts = 0;
v4l2_prep_obs_frame(data, &out, plane_offsets); v4l2_prep_obs_frame(data, &out, plane_offsets);
while (os_event_try(data->event) == EAGAIN) { while (os_event_try(data->event) == EAGAIN) {
@ -182,7 +180,7 @@ static void *v4l2_thread(void *vptr)
out.timestamp = data->sys_timing ? out.timestamp = data->sys_timing ?
os_gettime_ns() : timeval2ns(buf.timestamp); os_gettime_ns() : timeval2ns(buf.timestamp);
if (!data->frames) if (!frames)
first_ts = out.timestamp; first_ts = out.timestamp;
out.timestamp -= first_ts; out.timestamp -= first_ts;
@ -197,10 +195,10 @@ static void *v4l2_thread(void *vptr)
break; break;
} }
data->frames++; frames++;
} }
blog(LOG_INFO, "Stopped capture after %"PRIu64" frames", data->frames); blog(LOG_INFO, "Stopped capture after %"PRIu64" frames", frames);
exit: exit:
v4l2_stop_capture(data->dev); v4l2_stop_capture(data->dev);