Improve recycling
This commit is contained in:
parent
25af6875f4
commit
4d999d9426
@ -23,6 +23,12 @@ void camera_close(camera_t *camera)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = MAX_DEVICES; i-- > 0; ) {
|
||||||
|
if (camera->links[i].callbacks.on_buffer) {
|
||||||
|
camera->links[i].callbacks.on_buffer = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memset(camera->links, 0, sizeof(camera->links));
|
memset(camera->links, 0, sizeof(camera->links));
|
||||||
free(camera);
|
free(camera);
|
||||||
}
|
}
|
||||||
|
12
hw/device.c
12
hw/device.c
@ -10,7 +10,7 @@ device_t *device_open(const char *name, const char *path) {
|
|||||||
dev->subdev_fd = -1;
|
dev->subdev_fd = -1;
|
||||||
dev->allow_dma = true;
|
dev->allow_dma = true;
|
||||||
if(dev->fd < 0) {
|
if(dev->fd < 0) {
|
||||||
E_LOG_ERROR(dev, "Can't open device");
|
E_LOG_ERROR(dev, "Can't open device: %s", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
E_LOG_DEBUG(dev, "Querying device capabilities ...");
|
E_LOG_DEBUG(dev, "Querying device capabilities ...");
|
||||||
@ -53,6 +53,8 @@ void device_close(device_t *dev) {
|
|||||||
close(dev->fd);
|
close(dev->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(dev->name);
|
||||||
|
free(dev->path);
|
||||||
free(dev);
|
free(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,8 +143,14 @@ int device_open_buffer_list_capture(device_t *dev, buffer_list_t *output_list, f
|
|||||||
format, 0, output_list->nbufs, do_mmap);
|
format, 0, output_list->nbufs, do_mmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int device_stream(device_t *dev, bool do_on)
|
int device_set_stream(device_t *dev, bool do_on)
|
||||||
{
|
{
|
||||||
|
struct v4l2_event_subscription sub = {0};
|
||||||
|
sub.type = V4L2_EVENT_SOURCE_CHANGE;
|
||||||
|
|
||||||
|
E_LOG_DEBUG(dev, "Subscribing to DV-timings events ...");
|
||||||
|
xioctl(dev_name(dev), dev->fd, do_on ? VIDIOC_SUBSCRIBE_EVENT : VIDIOC_UNSUBSCRIBE_EVENT, &sub);
|
||||||
|
|
||||||
if (dev->capture_list) {
|
if (dev->capture_list) {
|
||||||
if (buffer_list_stream(dev->capture_list, do_on) < 0) {
|
if (buffer_list_stream(dev->capture_list, do_on) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -27,7 +27,7 @@ int device_open_buffer_list_output(device_t *dev, struct buffer_list_s *capture_
|
|||||||
int device_open_buffer_list_capture(device_t *dev, struct buffer_list_s *output_list, float div, unsigned format, bool do_mmap);
|
int device_open_buffer_list_capture(device_t *dev, struct buffer_list_s *output_list, float div, unsigned format, bool do_mmap);
|
||||||
int device_consume_event(device_t *device);
|
int device_consume_event(device_t *device);
|
||||||
|
|
||||||
int device_stream(device_t *dev, bool do_on);
|
int device_set_stream(device_t *dev, bool do_on);
|
||||||
int device_video_force_key(device_t *dev);
|
int device_video_force_key(device_t *dev);
|
||||||
int device_set_pad_format(device_t *device, unsigned width, unsigned height, unsigned format);
|
int device_set_pad_format(device_t *device, unsigned width, unsigned height, unsigned format);
|
||||||
int device_set_option(device_t *dev, const char *name, uint32_t id, int32_t value);
|
int device_set_option(device_t *dev, const char *name, uint32_t id, int32_t value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user