Move device/hw/links.h
to device/links.h
This commit is contained in:
parent
febc3f9f9f
commit
dfc6df83cf
@ -1,7 +1,7 @@
|
||||
#include "device/hw/buffer.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "device/hw/device.h"
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/v4l2.h"
|
||||
#include "http/http.h"
|
||||
#include "opts/opts.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "device/hw/device.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/v4l2.h"
|
||||
|
||||
void camera_init(camera_t *camera)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/device.h"
|
||||
|
||||
#define MAX_DEVICES 20
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "device/hw/buffer.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "device/hw/device.h"
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/v4l2.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "device/hw/buffer.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "device/hw/device.h"
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/v4l2.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "device/hw/buffer.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "device/hw/device.h"
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/v4l2.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "device/hw/buffer.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "device/hw/device.h"
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/v4l2.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
@ -169,7 +169,7 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int buffer_list_request(buffer_list_t *buf_list, int nbufs)
|
||||
int buffer_list_set_buffers(buffer_list_t *buf_list, int nbufs)
|
||||
{
|
||||
struct v4l2_requestbuffers v4l2_req = {0};
|
||||
v4l2_req.count = nbufs;
|
||||
@ -206,7 +206,7 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int buffer_list_stream(buffer_list_t *buf_list, bool do_on)
|
||||
int buffer_list_set_stream(buffer_list_t *buf_list, bool do_on)
|
||||
{
|
||||
if (!buf_list) {
|
||||
return -1;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
typedef struct buffer_s buffer_t;
|
||||
typedef struct device_s device_t;
|
||||
struct pollfd;
|
||||
|
||||
typedef struct buffer_list_s {
|
||||
char *name;
|
||||
@ -33,14 +34,13 @@ typedef struct buffer_list_s {
|
||||
buffer_list_t *buffer_list_open(const char *name, struct device_s *dev, unsigned type, bool do_mmap);
|
||||
void buffer_list_close(buffer_list_t *buf_list);
|
||||
|
||||
int buffer_list_set_stream(buffer_list_t *buf_list, bool do_on);
|
||||
int buffer_list_set_format(buffer_list_t *buffer_list, unsigned width, unsigned height, unsigned format, unsigned bytesperline);
|
||||
int buffer_list_request(buffer_list_t *buf_list, int nbufs);
|
||||
|
||||
int buffer_list_stream(buffer_list_t *buf_list, bool do_on);
|
||||
int buffer_list_set_buffers(buffer_list_t *buf_list, int nbufs);
|
||||
|
||||
int buffer_list_pollfd(buffer_list_t *buf_list, struct pollfd *pollfd, bool can_dequeue);
|
||||
buffer_t *buffer_list_find_slot(buffer_list_t *buf_list);
|
||||
buffer_t *buffer_list_dequeue(buffer_list_t *buf_list);
|
||||
int buffer_list_count_enqueued(buffer_list_t *buf_list);
|
||||
|
||||
int buffer_list_enqueue(buffer_list_t *buf_list, buffer_t *dma_buf);
|
||||
int buffer_list_refresh_states(buffer_list_t *buf_list);
|
||||
|
@ -210,3 +210,19 @@ buffer_t *buffer_list_dequeue(buffer_list_t *buf_list)
|
||||
error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int buffer_list_pollfd(buffer_list_t *buf_list, struct pollfd *pollfd, bool can_dequeue)
|
||||
{
|
||||
int count_enqueued = buffer_list_count_enqueued(buf_list);
|
||||
|
||||
// Can something be dequeued?
|
||||
pollfd->fd = buf_list->device->fd;
|
||||
pollfd->events = POLLHUP;
|
||||
if (count_enqueued > 0 && can_dequeue)
|
||||
if (buf_list->do_capture)
|
||||
pollfd->events |= POLLIN;
|
||||
else
|
||||
pollfd->events |= POLLOUT;
|
||||
pollfd->revents = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ int device_open_buffer_list(device_t *dev, bool do_capture, unsigned width, unsi
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (buffer_list_request(*buf_list, nbufs) < 0) {
|
||||
if (buffer_list_set_buffers(*buf_list, nbufs) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -160,13 +160,13 @@ int device_set_stream(device_t *dev, bool do_on)
|
||||
xioctl(dev_name(dev), dev->fd, do_on ? VIDIOC_SUBSCRIBE_EVENT : VIDIOC_UNSUBSCRIBE_EVENT, &sub);
|
||||
|
||||
if (dev->capture_list) {
|
||||
if (buffer_list_stream(dev->capture_list, do_on) < 0) {
|
||||
if (buffer_list_set_stream(dev->capture_list, do_on) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->output_list) {
|
||||
if (buffer_list_stream(dev->output_list, do_on) < 0) {
|
||||
if (buffer_list_set_stream(dev->output_list, do_on) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "device/hw/links.h"
|
||||
#include "device/links.h"
|
||||
#include "device/hw/device.h"
|
||||
#include "device/hw/buffer.h"
|
||||
#include "device/hw/buffer_list.h"
|
||||
@ -44,19 +44,15 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
||||
continue;
|
||||
}
|
||||
|
||||
int count_enqueued = buffer_list_count_enqueued(sink);
|
||||
|
||||
// Can something be dequeued?
|
||||
fds[n].fd = sink->device->fd;
|
||||
fds[n].events = POLLHUP;
|
||||
if (count_enqueued > 0)
|
||||
fds[n].events |= POLLOUT;
|
||||
fds[n].revents = 0;
|
||||
buf_lists[n] = sink;
|
||||
links[n] = NULL;
|
||||
n++;
|
||||
if (buffer_list_pollfd(sink, &fds[n], true) == 0) {
|
||||
buf_lists[n] = sink;
|
||||
links[n] = NULL;
|
||||
n++;
|
||||
}
|
||||
|
||||
// Can this chain pauses
|
||||
int count_enqueued = buffer_list_count_enqueued(sink);
|
||||
if (!sink->device->paused && count_enqueued < sink->nbufs) {
|
||||
paused = false;
|
||||
}
|
||||
@ -67,7 +63,7 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
||||
if (source->device->output_device) {
|
||||
source->device->output_device->paused = paused;
|
||||
}
|
||||
|
||||
|
||||
int count_enqueued = buffer_list_count_enqueued(source);
|
||||
bool can_dequeue = count_enqueued > 0;
|
||||
|
||||
@ -78,13 +74,11 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
||||
}
|
||||
#endif
|
||||
|
||||
fds[n].fd = source->device->fd;
|
||||
fds[n].events = POLLHUP;
|
||||
if (can_dequeue)
|
||||
fds[n].events |= POLLIN;
|
||||
fds[n].revents = 0;
|
||||
buf_lists[n] = source;
|
||||
links[n] = link;
|
||||
if (buffer_list_pollfd(source, &fds[n], can_dequeue) == 0) {
|
||||
buf_lists[n] = source;
|
||||
links[n] = link;
|
||||
n++;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
|
||||
@ -244,12 +238,12 @@ int links_stream(link_t *all_links, bool do_stream)
|
||||
bool streaming = true;
|
||||
link_t *link = &all_links[i];
|
||||
|
||||
if (buffer_list_stream(link->source, streaming) < 0) {
|
||||
if (buffer_list_set_stream(link->source, streaming) < 0) {
|
||||
E_LOG_ERROR(link->source, "Failed to start streaming");
|
||||
}
|
||||
|
||||
for (int j = 0; link->sinks[j]; j++) {
|
||||
if (buffer_list_stream(link->sinks[j], streaming) < 0) {
|
||||
if (buffer_list_set_stream(link->sinks[j], streaming) < 0) {
|
||||
E_LOG_ERROR(link->sinks[j], "Failed to start streaming");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user