mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-09-19 21:06:42 +00:00
restore audio settings - use all the frame buffers provided by the driver
Originally committed as revision 127 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
813cae4bc4
commit
5a56c87c10
10
libav/grab.c
10
libav/grab.c
@ -42,7 +42,7 @@ static struct video_capability video_cap;
|
|||||||
static UINT8 *video_buf;
|
static UINT8 *video_buf;
|
||||||
static struct video_mbuf gb_buffers;
|
static struct video_mbuf gb_buffers;
|
||||||
static struct video_mmap gb_buf;
|
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 gb_frame = 0;
|
||||||
|
|
||||||
static int v4l_init(URLContext *h)
|
static int v4l_init(URLContext *h)
|
||||||
@ -73,6 +73,7 @@ static int v4l_init(URLContext *h)
|
|||||||
|
|
||||||
/* unmute audio */
|
/* unmute audio */
|
||||||
ioctl(video_fd, VIDIOCGAUDIO, &audio);
|
ioctl(video_fd, VIDIOCGAUDIO, &audio);
|
||||||
|
memcpy(&audio_saved, &audio, sizeof(audio));
|
||||||
audio.flags &= ~VIDEO_AUDIO_MUTE;
|
audio.flags &= ~VIDEO_AUDIO_MUTE;
|
||||||
ioctl(video_fd, VIDIOCSAUDIO, &audio);
|
ioctl(video_fd, VIDIOCSAUDIO, &audio);
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ static int v4l_init(URLContext *h)
|
|||||||
s->time_frame = gettime();
|
s->time_frame = gettime();
|
||||||
|
|
||||||
/* start to grab the first frame */
|
/* 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.height = height;
|
||||||
gb_buf.width = width;
|
gb_buf.width = width;
|
||||||
gb_buf.format = VIDEO_PALETTE_YUV420P;
|
gb_buf.format = VIDEO_PALETTE_YUV420P;
|
||||||
@ -196,7 +197,7 @@ static int v4l_mm_read_picture(URLContext *h, UINT8 *buf)
|
|||||||
perror("VIDIOCMCAPTURE");
|
perror("VIDIOCMCAPTURE");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
gb_frame = 1 - gb_frame;
|
gb_frame = (gb_frame + 1) % gb_buffers.frames;
|
||||||
|
|
||||||
while (ioctl(s->fd, VIDIOCSYNC, &gb_frame) < 0 &&
|
while (ioctl(s->fd, VIDIOCSYNC, &gb_frame) < 0 &&
|
||||||
(errno == EAGAIN || errno == EINTR));
|
(errno == EAGAIN || errno == EINTR));
|
||||||
@ -301,6 +302,9 @@ static int video_close(URLContext *h)
|
|||||||
{
|
{
|
||||||
VideoData *s = h->priv_data;
|
VideoData *s = h->priv_data;
|
||||||
|
|
||||||
|
/* restore audio settings */
|
||||||
|
ioctl(s->fd, VIDIOCSAUDIO, &audio_saved);
|
||||||
|
|
||||||
close(s->fd);
|
close(s->fd);
|
||||||
free(s);
|
free(s);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user