comparison stream/tvi_v4l2.c @ 37127:ca7e13830a05

Allow building of v4l2 without clock_gettime(). Add overly verbose message in case monotone timestamps are required by the kernel.
author iive
date Tue, 10 Jun 2014 16:39:04 +0000
parents 6db1f7a10803
children
comparison
equal deleted inserted replaced
37126:6db1f7a10803 37127:ca7e13830a05
493 } 493 }
494 } while (priv->standard.id != id); 494 } while (priv->standard.id != id);
495 return 0; 495 return 0;
496 } 496 }
497 497
498 #if HAVE_CLOCK_GETTIME
498 /* 499 /*
499 ** Gets current timestamp, using specified clock id. 500 ** Gets current timestamp, using specified clock id.
500 ** @return number of microseconds. 501 ** @return number of microseconds.
501 */ 502 */
502 static long long get_curr_timestamp(int clk_id) 503 static long long get_curr_timestamp(int clk_id)
503 { 504 {
504 struct timespec ts; 505 struct timespec ts;
505 clock_gettime(clk_id, &ts); 506 clock_gettime(clk_id, &ts);
506 return (long long)ts.tv_sec * 1000000 + ts.tv_nsec / 1000; 507 return (long long)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
507 } 508 }
509 #else
510 /*
511 ** Gets current timestamp, using system time.
512 ** @return number of microseconds.
513 */
514 static long long get_curr_timestamp(int clk_id)
515 {
516 struct timeval tv;
517 gettimeofday(&tv, NULL);
518 return (long long)tv.tv_sec * 1000000 + tv.tv_usec;
519 }
520 #endif
508 521
509 /***********************************************************************\ 522 /***********************************************************************\
510 * * 523 * *
511 * * 524 * *
512 * Interface to mplayer * 525 * Interface to mplayer *
1547 info.short_name, strerror(errno)); 1560 info.short_name, strerror(errno));
1548 priv->map[i].len = 0; 1561 priv->map[i].len = 0;
1549 return 0; 1562 return 0;
1550 } 1563 }
1551 priv->map[i].len = priv->map[i].buf.length; 1564 priv->map[i].len = priv->map[i].buf.length;
1565 #ifdef HAVE_CLOCK_GETTIME
1552 priv->clk_id = (priv->map[i].buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) 1566 priv->clk_id = (priv->map[i].buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC)
1553 ? CLOCK_MONOTONIC : CLOCK_REALTIME; 1567 ? CLOCK_MONOTONIC : CLOCK_REALTIME;
1568 #else
1569 if (priv->map[i].buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC)
1570 mp_msg(MSGT_TV, MSGL_WARN, "MPlayer compiled without clock_gettime() that is needed to handle monotone video timestamps from the kernel. Expect desync.\n");
1571 #endif
1554 /* count up to make sure this is correct everytime */ 1572 /* count up to make sure this is correct everytime */
1555 priv->mapcount++; 1573 priv->mapcount++;
1556 1574
1557 if (ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) { 1575 if (ioctl(priv->video_fd, VIDIOC_QBUF, &(priv->map[i].buf)) < 0) {
1558 mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n", 1576 mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl queue buffer failed: %s\n",