I have an application that's streaming frames from a webcam. After a few minutes of streaming, the QSocketNotifier associated with camera fd stops generating activated events.
This might be a camera hardware, firmware, or RPI kernel issue, but I want to make sure my use of a QSocketNotifier instead of the exact code in the Vl42 example isn't part of the problem
In examples mainLoop() function there is a blocking select:
r = select(fd + 1, &fds, NULL, NULL, &tv);
if (-1 == r) {
if (EINTR == errno)
continue;
r = select(fd + 1, &fds, NULL, NULL, &tv);
if (-1 == r) {
if (EINTR == errno)
continue;
To copy to clipboard, switch view to plain text mode
I have these lines of code instead:
fd = open(dev_name.toAscii().data(), O_RDWR /* required */ | O_NONBLOCK, 0);
connect(notify_fd, SIGNAL(activated(int)), this, SLOT(read_frame(int)), Qt::QueuedConnection );
fd = open(dev_name.toAscii().data(), O_RDWR /* required */ | O_NONBLOCK, 0);
notify_fd = new QSocketNotifier(fd, QSocketNotifier::Read);
connect(notify_fd, SIGNAL(activated(int)), this, SLOT(read_frame(int)), Qt::QueuedConnection );
To copy to clipboard, switch view to plain text mode
So, what happens when the fd associated the QSocketNotifier breaks out of the select with EINTR==errno? I've been assuming that's a QSocketNotifier::Exception event, so creating the QSocketNotifier using a QSocketNotifier::Read type would result in exceptions like the EINTR==errno being ignored. That's the equivalent of the example code.
Is this true? Can I check errno in the read_frame slot, or will it likely be reset before the slot code executes?
Next step will be to redo the code without the QtSocketNotifier, but that will take a few hours to get working, I think.
Thanks!
Bookmarks