Skip to content

Commit

Permalink
fix #6: close properly MMAP device
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Sep 1, 2016
1 parent f213146 commit f1b7dbe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion inc/V4l2Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class V4l2Device
protected:
V4l2Device(const V4L2DeviceParameters& params, v4l2_buf_type deviceType);

bool init(unsigned int mandatoryCapabilities);
virtual bool init(unsigned int mandatoryCapabilities);
void close();

int initdevice(const char *dev_name, unsigned int mandatoryCapabilities);
Expand Down
8 changes: 6 additions & 2 deletions inc/V4l2MmapDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ class V4l2MmapDevice : public virtual V4l2Device
V4l2MmapDevice(V4L2DeviceParameters params, v4l2_buf_type deviceType);

public:
virtual bool captureStart();
virtual bool captureStop();
virtual ~V4l2MmapDevice();

bool captureStart();
bool captureStop();

virtual bool init(unsigned int mandatoryiCapabilities);
virtual bool isReady() { return ((m_fd != -1)&& (n_buffers != 0)); };

protected:
Expand Down
4 changes: 0 additions & 4 deletions src/V4l2MmapCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ V4l2MmapCapture* V4l2MmapCapture::createNew(V4L2DeviceParameters params)
delete device;
device=NULL;
}
if (device)
{
device->captureStart();
}
return device;
}

Expand Down
15 changes: 15 additions & 0 deletions src/V4l2MmapDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ V4l2MmapDevice::V4l2MmapDevice(V4L2DeviceParameters params, v4l2_buf_type device
memset(&m_buffer, 0, sizeof(m_buffer));
}

bool V4l2MmapDevice::init(unsigned int mandatoryCapabilities)
{
bool ret = V4l2Device::init(mandatoryCapabilities);
if (ret)
{
this->captureStart();
}
return ret;
}

V4l2MmapDevice::~V4l2MmapDevice()
{
this->captureStop();
}


bool V4l2MmapDevice::captureStart()
{
Expand Down
4 changes: 0 additions & 4 deletions src/V4l2MmapOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ V4l2MmapOutput* V4l2MmapOutput::createNew(V4L2DeviceParameters params)
delete device;
device=NULL;
}
if (device)
{
device->captureStart();
}
return device;
}

Expand Down

0 comments on commit f1b7dbe

Please sign in to comment.