Revision 5a56c87c

View differences:

libav/grab.c
42 42
static UINT8 *video_buf;
43 43
static struct video_mbuf gb_buffers;
44 44
static struct video_mmap gb_buf;
45
static struct video_audio audio;
45
static struct video_audio audio, audio_saved;
46 46
static int gb_frame = 0;
47 47

  
48 48
static int v4l_init(URLContext *h)
......
73 73
    
74 74
    /* unmute audio */
75 75
    ioctl(video_fd, VIDIOCGAUDIO, &audio);
76
    memcpy(&audio_saved, &audio, sizeof(audio));
76 77
    audio.flags &= ~VIDEO_AUDIO_MUTE;
77 78
    ioctl(video_fd, VIDIOCSAUDIO, &audio);
78 79

  
......
132 133
        s->time_frame = gettime();
133 134
        
134 135
        /* start to grab the first frame */
135
        gb_buf.frame = 1 - gb_frame;
136
        gb_buf.frame = (gb_frame + 1) % gb_buffers.frames;
136 137
        gb_buf.height = height;
137 138
        gb_buf.width = width;
138 139
        gb_buf.format = VIDEO_PALETTE_YUV420P;
......
196 197
            perror("VIDIOCMCAPTURE");
197 198
	return -EIO;
198 199
    }
199
    gb_frame = 1 - gb_frame;
200
    gb_frame = (gb_frame + 1) % gb_buffers.frames;
200 201

  
201 202
    while (ioctl(s->fd, VIDIOCSYNC, &gb_frame) < 0 &&
202 203
           (errno == EAGAIN || errno == EINTR));
......
301 302
{
302 303
    VideoData *s = h->priv_data;
303 304

  
305
    /* restore audio settings */
306
    ioctl(s->fd, VIDIOCSAUDIO, &audio_saved);
307

  
304 308
    close(s->fd);
305 309
    free(s);
306 310
    return 0;

Also available in: Unified diff