diff options
author | 2002-06-24 16:37:18 +0000 | |
---|---|---|
committer | 2002-06-24 16:37:18 +0000 | |
commit | d402d04e4af39bbc77f2aff3b21fa3060f815753 (patch) | |
tree | cfbf52d9f1035af0376697aec4bd2664257841b4 /libmpdemux/tvi_v4l.c | |
parent | a1a61e895a67e4974d330d14fcb4d924cbec3aa7 (diff) |
Paul Ortyl's patch - tv4l timestamps (not so precise :()
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6554 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/tvi_v4l.c')
-rw-r--r-- | libmpdemux/tvi_v4l.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/libmpdemux/tvi_v4l.c b/libmpdemux/tvi_v4l.c index 79ea4f5da4..67a1f70346 100644 --- a/libmpdemux/tvi_v4l.c +++ b/libmpdemux/tvi_v4l.c @@ -19,6 +19,7 @@ #include <signal.h> #include <sys/ioctl.h> #include <sys/types.h> +#include <sys/time.h> #include <linux/videodev.h> #include <linux/soundcard.h> #include <unistd.h> @@ -75,6 +76,9 @@ typedef struct { int audio_samplesize[MAX_AUDIO_CHANNELS]; int audio_samplerate[MAX_AUDIO_CHANNELS]; int audio_blocksize; + + /* other */ + double starttime; } priv_t; #include "tvi_def.h" @@ -524,6 +528,12 @@ static int start(priv_t *priv) } #endif + { + struct timeval curtime; + gettimeofday(&curtime, NULL); + priv->starttime=curtime.tv_sec + curtime.tv_usec*.000001; + } + return(1); } @@ -541,8 +551,6 @@ static int control(priv_t *priv, int cmd, void *arg) return(TVI_CONTROL_FALSE); } case TVI_CONTROL_IS_AUDIO: - return(TVI_CONTROL_FALSE); -/* also disable audio for as it's not working! */ if (priv->channels[priv->act_channel].flags & VIDEO_VC_AUDIO) { return(TVI_CONTROL_TRUE); @@ -821,6 +829,8 @@ static int control(priv_t *priv, int cmd, void *arg) static double grab_video_frame(priv_t *priv, char *buffer, int len) { + struct timeval curtime; + double timestamp; int frame = priv->queue % priv->nbuf; int nextframe = (priv->queue+1) % priv->nbuf; @@ -841,6 +851,9 @@ static double grab_video_frame(priv_t *priv, char *buffer, int len) priv->queue++; + gettimeofday(&curtime, NULL); + timestamp=curtime.tv_sec + curtime.tv_usec*.000001; + mp_dbg(MSGT_TV, MSGL_DBG3, "mmap: %p + offset: %d => %p\n", priv->mmap, priv->mbuf.offsets[frame], priv->mmap+priv->mbuf.offsets[frame]); @@ -851,7 +864,7 @@ static double grab_video_frame(priv_t *priv, char *buffer, int len) /* copy the actual frame */ memcpy(buffer, priv->mmap+priv->mbuf.offsets[frame], len); - return(0); + return(timestamp-priv->starttime); } static int get_video_framesize(priv_t *priv) @@ -862,13 +875,13 @@ static int get_video_framesize(priv_t *priv) static double grab_audio_frame(priv_t *priv, char *buffer, int len) { int in_len = 0; -// int max_tries = 128; + int max_tries = 2; mp_dbg(MSGT_TV, MSGL_DBG2, "grab_audio_frame(priv=%p, buffer=%p, len=%d)\n", priv, buffer, len); -// while (--max_tries > 0) - for (;;) + while (--max_tries > 0) +// for (;;) { in_len = read(priv->audio_fd, buffer, len); // printf("in_len: %d\n", in_len); @@ -882,7 +895,6 @@ static double grab_audio_frame(priv_t *priv, char *buffer, int len) break; } } -// printf("tries: %d\n", 128-max_tries); return 0; //(in_len); // FIXME! } |