diff options
author | Edward Hervey <edward.hervey@collabora.co.uk> | 2012-06-29 18:04:04 +0200 |
---|---|---|
committer | Edward Hervey <edward.hervey@collabora.co.uk> | 2012-08-14 19:06:30 +0200 |
commit | 7a72c961de7996a27e64995e9321732d8e216fd0 (patch) | |
tree | 4369ea292c7e7a221c4cbb3258f9e58b7617be64 /sys | |
parent | 25cb359ddb0c4c23f69a5154efc2b7b34a18a4b6 (diff) | |
download | gstreamer-plugins-bad-7a72c961de7996a27e64995e9321732d8e216fd0.tar.gz |
cam: Allow time for CA to initialize
Some devices take some time to initialize, and until they are they
will error out when trying to get information about the CA device.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dvb/camdevice.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/dvb/camdevice.c b/sys/dvb/camdevice.c index d38d625ae..0a160ceb1 100644 --- a/sys/dvb/camdevice.c +++ b/sys/dvb/camdevice.c @@ -104,6 +104,7 @@ cam_device_open (CamDevice * device, const char *filename) ca_caps_t ca_caps; int ret; int i; + int count = 10; g_return_val_if_fail (device != NULL, FALSE); g_return_val_if_fail (device->state == CAM_DEVICE_STATE_CLOSED, FALSE); @@ -117,17 +118,31 @@ cam_device_open (CamDevice * device, const char *filename) return FALSE; } + GST_DEBUG ("Successfully opened device %s", filename); + device->fd = ret; ret = ioctl (device->fd, CA_RESET); - sleep (1); - /* get the capabilities of the CA */ - ret = ioctl (device->fd, CA_GET_CAP, &ca_caps); - if (ret == -1) { - GST_ERROR ("CA_GET_CAP ioctl failed: %s", strerror (errno)); - reset_state (device); - return FALSE; + g_usleep (G_USEC_PER_SEC / 10); + + while (TRUE) { + /* get the capabilities of the CA */ + ret = ioctl (device->fd, CA_GET_CAP, &ca_caps); + if (ret == -1) { + GST_ERROR ("CA_GET_CAP ioctl failed: %s", strerror (errno)); + reset_state (device); + return FALSE; + } + if (ca_caps.slot_num > 0) + break; + if (!count) { + GST_ERROR ("CA_GET_CAP succeeded but not slots"); + reset_state (device); + return FALSE; + } + count--; + g_usleep (G_USEC_PER_SEC / 5); } device->tl = cam_tl_new (device->fd); |