Mercurial > mplayer.hg
changeset 7803:172ee2b4612f
Stop grabbing from v4l when paused by Jindrich Makovicka
author | alex |
---|---|
date | Sat, 19 Oct 2002 20:03:40 +0000 |
parents | 037982e833a7 |
children | 3735b7f5904c |
files | libmpdemux/tvi_v4l.c |
diffstat | 1 files changed, 17 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/tvi_v4l.c Sat Oct 19 19:54:59 2002 +0000 +++ b/libmpdemux/tvi_v4l.c Sat Oct 19 20:03:40 2002 +0000 @@ -1169,10 +1169,7 @@ int fsize = priv->bytesperline * priv->height; int i; int first = 1; - - int dropped = 0; - double dropped_time = 0.0; - double drop_delta = 0.0; + int framecount; /* start the capture process */ if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[0]) == -1) @@ -1186,9 +1183,16 @@ prev_interval = 0.0; prev_skew = 0.0; - for (;!priv->shutdown;) + for (framecount = 0; !priv->shutdown;) { - for (i = 0; i < priv->nbuf && !priv->shutdown; i++) { + for (i = 0; i < priv->nbuf && !priv->shutdown; i++, framecount++) { + + if (priv->immediate_mode) { + while ((priv->video_tail+1) % priv->video_buffer_size == priv->video_head) { + usleep(10000); + } + } + frame = i; nextframe = (i+1)%priv->nbuf; @@ -1215,7 +1219,11 @@ interval = 0.0; first = 0; } else { - interval = curtime.tv_sec + curtime.tv_usec*.000001 - priv->starttime; + if (!priv->immediate_mode) { + interval = curtime.tv_sec + curtime.tv_usec*.000001 - priv->starttime; + } else { + interval = (double)framecount/priv->fps; + } if (!priv->immediate_mode && ( (interval - prev_interval < 1.0/priv->fps*0.85) @@ -1246,29 +1254,16 @@ prev_interval = interval; if ((priv->video_tail+1) % priv->video_buffer_size == priv->video_head) { - if (!priv->immediate_mode) { mp_msg(MSGT_TV, MSGL_ERR, "\nvideo buffer full - dropping frame\n"); - } else { - if (!dropped) { - dropped = 1; - dropped_time = interval - skew; - } } } else { if (priv->immediate_mode) { - if (dropped) { - drop_delta += interval - skew - dropped_time; - dropped = 0; - } + priv->video_timebuffer[priv->video_tail] = interval; + } else { // compensate for audio skew // negative skew => there are more audio samples, increase interval // positive skew => less samples, shorten the interval - - // for TV, we pretend that dropped frames never existed - // without this, mplayer gets confused after pressing pause - priv->video_timebuffer[priv->video_tail] = interval - skew - drop_delta; - } else { priv->video_timebuffer[priv->video_tail] = interval - skew; }