avoid stack overflow when no data is available

pull/33/head
Michel Promonet 10 years ago
parent 99b4c42a07
commit 1f89a9d1a5

@ -76,7 +76,8 @@ class V4L2DeviceSource: public FramedSource
void* thread();
static void deliverFrameStub(void* clientData) {((V4L2DeviceSource*) clientData)->deliverFrame();};
void deliverFrame();
static void incomingPacketHandlerStub(void* clientData, int mask) { ((V4L2DeviceSource*) clientData)->getNextFrame(); };
static void incomingPacketHandlerStub(void* clientData, int mask) { ((V4L2DeviceSource*) clientData)->incomingPacketHandler(); };
void incomingPacketHandler();
int getNextFrame();
void processFrame(char * frame, int frameSize, const timeval &ref);
void queueFrame(char * frame, int frameSize, const timeval &tv);

@ -175,12 +175,24 @@ void V4L2DeviceSource::deliverFrame()
}
pthread_mutex_unlock (&m_mutex);
if (fFrameSize > 0)
{
// send Frame to the consumer
FramedSource::afterGetting(this);
}
}
}
// FrameSource callback on read event
void V4L2DeviceSource::incomingPacketHandler()
{
if (this->getNextFrame() <= 0)
{
handleClosure(this);
}
}
// read from device
int V4L2DeviceSource::getNextFrame()
{
char buffer[m_device->getBufferSize()];
@ -191,12 +203,10 @@ int V4L2DeviceSource::getNextFrame()
if (frameSize < 0)
{
LOG(NOTICE) << "V4L2DeviceSource::getNextFrame errno:" << errno << " " << strerror(errno);
handleClosure(this);
}
else if (frameSize == 0)
{
LOG(NOTICE) << "V4L2DeviceSource::getNextFrame no data errno:" << errno << " " << strerror(errno);
handleClosure(this);
}
else
{

Loading…
Cancel
Save