~ubuntu-branches/ubuntu/utopic/lebiniou/utopic

« back to all changes in this revision

Viewing changes to src/webcam_open_close.c

  • Committer: Package Import Robot
  • Author(s): Logan Rosen
  • Date: 2013-11-13 21:19:20 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20131113211920-af65h37psw9fz6oy
Tags: 3.19.1-1ubuntu1
* Merge from Debian unstable. Remaining changes:
  - debian/patches/fix_ftbfs_with_binutils_gold: Add -lz to fix FTBFS with
    binutils-gold.
* debian/patches/fix_ftbfs_with_binutils_gold: Remove -lavutil, as it is
  already linked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright 1994-2012 Olivier Girondel
 
2
 *  Copyright 1994-2013 Olivier Girondel
3
3
 *
4
4
 *  This file is part of lebiniou.
5
5
 *
23
23
extern u_long options;
24
24
extern char *video_base;
25
25
 
26
 
 
27
26
int
28
27
open_device(webcam_t *cam, const uint8_t try)
29
28
{
39
38
  dev_name = g_strdup_printf("%s%d", video_base, cam->cam_no+try);
40
39
 
41
40
  if (-1 == stat(dev_name, &st)) {
42
 
    printf("[!] Cannot identify '%s': %d, %s\n",
43
 
           dev_name, errno, strerror(errno));
 
41
    fprintf(stderr, "[!] Cannot identify '%s': %d, %s\n",
 
42
            dev_name, errno, strerror(errno));
44
43
    g_free(dev_name);
45
44
    return -1;
46
45
  }
47
46
 
48
47
  if (!S_ISCHR(st.st_mode)) {
49
 
    printf("[!] %s is no device\n", dev_name);
 
48
    fprintf(stderr, "[!] %s is no device\n", dev_name);
50
49
    g_free(dev_name);
51
50
    return -1;
52
51
  }
54
53
  cam->fd = open(dev_name, O_RDWR /* required */ | O_NONBLOCK, 0);
55
54
 
56
55
  if (-1 == cam->fd) {
57
 
    printf("[!] Cannot open %s: %d, %s\n",
58
 
           dev_name, errno, strerror(errno));
 
56
    fprintf(stderr, "[!] Cannot open %s: %d, %s\n",
 
57
            dev_name, errno, strerror(errno));
59
58
    g_free(dev_name);
60
59
    return -1;
61
60
  } else
62
 
    printf("[i] Successfully opened %s as a video device, fd= %d\n", dev_name, cam->fd);
 
61
    VERBOSE(printf("[i] Successfully opened %s as a video device, fd= %d\n", dev_name, cam->fd));
63
62
 
64
63
  g_free(dev_name);
65
64