~ubuntu-branches/debian/sid/v4l-utils/sid

« back to all changes in this revision

Viewing changes to lib/libv4l2/libv4l2.c

  • Committer: Bazaar Package Importer
  • Author(s): Gregor Jasny
  • Date: 2010-10-03 16:26:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101003162640-88djisgfegdp020e
Tags: 0.8.1-1
* New upstream version (Closes: #598969)
* Bumped standards to version 3.9.1 (no changes needed)
* Updated copyright file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
268
268
static int v4l2_dequeue_and_convert(int index, struct v4l2_buffer *buf,
269
269
                unsigned char *dest, int dest_size)
270
270
{
271
 
        const int max_tries = 10;
 
271
        const int max_tries = V4L2_IGNORE_FIRST_FRAME_ERRORS + 1;
272
272
        int result, tries = max_tries;
273
273
 
274
274
        /* Make sure we have the real v4l2 buffers mapped */
308
308
                if (result < 0) {
309
309
                        int saved_err = errno;
310
310
 
311
 
                        if (errno == EAGAIN)
 
311
                        if (errno == EAGAIN || errno == EPIPE)
312
312
                                V4L2_LOG("warning error while converting frame data: %s",
313
313
                                                v4lconvert_get_error_message(devices[index].convert));
314
314
                        else
319
319
                        errno = saved_err;
320
320
                }
321
321
                tries--;
322
 
        } while (result < 0 && errno == EAGAIN && tries);
 
322
        } while (result < 0 && (errno == EAGAIN || errno == EPIPE) && tries);
323
323
 
324
324
        if (result < 0 && errno == EAGAIN) {
325
325
                V4L2_LOG_ERR("got %d consecutive frame decode errors, last error: %s",
327
327
                errno = EAGAIN;
328
328
        }
329
329
 
 
330
        if (result < 0 && errno == EPIPE) {
 
331
                V4L2_LOG("got %d consecutive short frame errors, "
 
332
                         "returning short frame", max_tries);
 
333
                result = devices[index].dest_fmt.fmt.pix.sizeimage;
 
334
                errno = 0;
 
335
        }
 
336
 
330
337
        return result;
331
338
}
332
339
 
333
340
static int v4l2_read_and_convert(int index, unsigned char *dest, int dest_size)
334
341
{
335
 
        const int max_tries = 10;
 
342
        const int max_tries = V4L2_IGNORE_FIRST_FRAME_ERRORS + 1;
336
343
        int result, buf_size, tries = max_tries;
337
344
 
338
345
        buf_size = devices[index].dest_fmt.fmt.pix.sizeimage;
376
383
                if (result < 0) {
377
384
                        int saved_err = errno;
378
385
 
379
 
                        if (errno == EAGAIN)
 
386
                        if (errno == EAGAIN || errno == EPIPE)
380
387
                                V4L2_LOG("warning error while converting frame data: %s",
381
388
                                                v4lconvert_get_error_message(devices[index].convert));
382
389
                        else
386
393
                        errno = saved_err;
387
394
                }
388
395
                tries--;
389
 
        } while (result < 0 && errno == EAGAIN && tries);
 
396
        } while (result < 0 && (errno == EAGAIN || errno == EPIPE) && tries);
390
397
 
391
398
        if (result < 0 && errno == EAGAIN) {
392
399
                V4L2_LOG_ERR("got %d consecutive frame decode errors, last error: %s",
393
400
                                max_tries, v4lconvert_get_error_message(devices[index].convert));
 
401
                errno = EAGAIN;
 
402
        }
 
403
 
 
404
        if (result < 0 && errno == EPIPE) {
 
405
                V4L2_LOG("got %d consecutive short frame errors, "
 
406
                         "returning short frame", max_tries);
 
407
                result = devices[index].dest_fmt.fmt.pix.sizeimage;
 
408
                errno = 0;
394
409
        }
395
410
 
396
411
        return result;
1403
1418
        }
1404
1419
 
1405
1420
        if (v4lconvert_vidioc_queryctrl(devices[index].convert, &qctrl))
1406
 
                return 0;
 
1421
                return -1;
1407
1422
 
1408
 
        if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
1409
 
                return 0;
 
1423
        if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
 
1424
                errno = EINVAL;
 
1425
                return -1;
 
1426
        }
1410
1427
 
1411
1428
        if (v4lconvert_vidioc_g_ctrl(devices[index].convert, &ctrl))
1412
 
                return 0;
 
1429
                return -1;
1413
1430
 
1414
1431
        return ((ctrl.value - qctrl.minimum) * 65535 +
1415
1432
                        (qctrl.maximum - qctrl.minimum) / 2) /