linux-v4l2: Make timestamp offset local.

This replaces the var in the source struct that are handling the
timestamp offset with a local one in the capture thread.
This change is mostly to make the code more readable.
master
fryshorts 2014-10-25 16:41:31 +02:00 committed by jp9000
parent c0f6733b58
commit 45583a759a
1 changed files with 6 additions and 10 deletions

View File

@ -59,8 +59,6 @@ struct v4l2_data {
int resolution;
int framerate;
bool sys_timing;
bool started;
uint64_t start_ts;
/* internal data */
obs_source_t *source;
@ -141,6 +139,7 @@ static void *v4l2_thread(void *vptr)
int r;
fd_set fds;
uint8_t *start;
uint64_t first_ts;
struct timeval tv;
struct v4l2_buffer buf;
struct obs_source_frame out;
@ -149,8 +148,8 @@ static void *v4l2_thread(void *vptr)
if (v4l2_start_capture(data->dev, &data->buffers) < 0)
goto exit;
first_ts = 0;
data->frames = 0;
v4l2_prep_obs_frame(data, &out, plane_offsets);
while (os_event_try(data->event) == EAGAIN) {
@ -183,11 +182,10 @@ static void *v4l2_thread(void *vptr)
out.timestamp = data->sys_timing ?
os_gettime_ns() : timeval2ns(buf.timestamp);
if (!data->started) {
data->start_ts = out.timestamp;
data->started = true;
}
out.timestamp -= data->start_ts;
if (!data->frames)
first_ts = out.timestamp;
out.timestamp -= first_ts;
start = (uint8_t *) data->buffers.info[buf.index].start;
for (uint_fast32_t i = 0; i < MAX_AV_PLANES; ++i)
@ -650,8 +648,6 @@ static void v4l2_init(struct v4l2_data *data)
{
int fps_num, fps_denom;
data->started = false;
blog(LOG_INFO, "Start capture from %s", data->device_id);
data->dev = v4l2_open(data->device_id, O_RDWR | O_NONBLOCK);
if (data->dev == -1) {