static UINT8 *video_buf;
static struct video_mbuf gb_buffers;
static struct video_mmap gb_buf;
-static struct video_audio audio;
+static struct video_audio audio, audio_saved;
static int gb_frame = 0;
static int v4l_init(URLContext *h)
/* unmute audio */
ioctl(video_fd, VIDIOCGAUDIO, &audio);
+ memcpy(&audio_saved, &audio, sizeof(audio));
audio.flags &= ~VIDEO_AUDIO_MUTE;
ioctl(video_fd, VIDIOCSAUDIO, &audio);
s->time_frame = gettime();
/* start to grab the first frame */
- gb_buf.frame = 1 - gb_frame;
+ gb_buf.frame = (gb_frame + 1) % gb_buffers.frames;
gb_buf.height = height;
gb_buf.width = width;
gb_buf.format = VIDEO_PALETTE_YUV420P;
perror("VIDIOCMCAPTURE");
return -EIO;
}
- gb_frame = 1 - gb_frame;
+ gb_frame = (gb_frame + 1) % gb_buffers.frames;
while (ioctl(s->fd, VIDIOCSYNC, &gb_frame) < 0 &&
(errno == EAGAIN || errno == EINTR));
{
VideoData *s = h->priv_data;
+ /* restore audio settings */
+ ioctl(s->fd, VIDIOCSAUDIO, &audio_saved);
+
close(s->fd);
free(s);
return 0;