From 3335d5a504374166f749a267ba1e1d803a0ed1f6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 27 Aug 2021 04:45:28 +0300 Subject: libcamera: Drop emitter object pointer from signal arguments Many signals used in internal and public APIs carry the emitter pointer as a signal argument. This was done to allow slots connected to multiple signal instances to differentiate between emitters. While starting from a good intention of facilitating the implementation of slots, it turned out to be a bad API design as the signal isn't meant to know what it will be connected to, and thus shouldn't carry parameters that are solely meant to support a use case specific to the connected slot. These pointers turn out to be unused in all slots but one. In the only case where it is needed, it can be obtained by wrapping the slot in a lambda function when connecting the signal. Do so, and drop the emitter pointer from all signals. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/base/event_notifier.h | 2 +- include/libcamera/base/thread.h | 2 +- include/libcamera/base/timer.h | 2 +- include/libcamera/camera.h | 2 +- include/libcamera/internal/device_enumerator_udev.h | 2 +- include/libcamera/internal/ipc_pipe_unixsocket.h | 2 +- include/libcamera/internal/ipc_unixsocket.h | 4 ++-- include/libcamera/internal/media_device.h | 2 +- include/libcamera/internal/process.h | 4 ++-- include/libcamera/internal/v4l2_device.h | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/libcamera/base/event_notifier.h b/include/libcamera/base/event_notifier.h index 5055ccbf..f7722a32 100644 --- a/include/libcamera/base/event_notifier.h +++ b/include/libcamera/base/event_notifier.h @@ -34,7 +34,7 @@ public: bool enabled() const { return enabled_; } void setEnabled(bool enable); - Signal activated; + Signal<> activated; protected: void message(Message *msg) override; diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h index 762beab2..e0ca0aea 100644 --- a/include/libcamera/base/thread.h +++ b/include/libcamera/base/thread.h @@ -41,7 +41,7 @@ public: bool isRunning(); - Signal finished; + Signal<> finished; static Thread *current(); static pid_t currentId(); diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h index 79882161..44876a85 100644 --- a/include/libcamera/base/timer.h +++ b/include/libcamera/base/timer.h @@ -33,7 +33,7 @@ public: std::chrono::steady_clock::time_point deadline() const { return deadline_; } - Signal timeout; + Signal<> timeout; protected: void message(Message *msg) override; diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 05cdab72..601ee46e 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -86,7 +86,7 @@ public: Signal bufferCompleted; Signal requestCompleted; - Signal disconnected; + Signal<> disconnected; int acquire(); int release(); diff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h index 58e64a29..c0352980 100644 --- a/include/libcamera/internal/device_enumerator_udev.h +++ b/include/libcamera/internal/device_enumerator_udev.h @@ -59,7 +59,7 @@ private: std::string lookupDeviceNode(dev_t devnum); int addV4L2Device(dev_t devnum); - void udevNotify(EventNotifier *notifier); + void udevNotify(); struct udev *udev_; struct udev_monitor *monitor_; diff --git a/include/libcamera/internal/ipc_pipe_unixsocket.h b/include/libcamera/internal/ipc_pipe_unixsocket.h index 4ffdddcc..ad2927fe 100644 --- a/include/libcamera/internal/ipc_pipe_unixsocket.h +++ b/include/libcamera/internal/ipc_pipe_unixsocket.h @@ -35,7 +35,7 @@ private: bool done; }; - void readyRead(IPCUnixSocket *socket); + void readyRead(); int call(const IPCUnixSocket::Payload &message, IPCUnixSocket::Payload *response, uint32_t seq); diff --git a/include/libcamera/internal/ipc_unixsocket.h b/include/libcamera/internal/ipc_unixsocket.h index 9f5b0677..2b87196c 100644 --- a/include/libcamera/internal/ipc_unixsocket.h +++ b/include/libcamera/internal/ipc_unixsocket.h @@ -37,7 +37,7 @@ public: int send(const Payload &payload); int receive(Payload *payload); - Signal readyRead; + Signal<> readyRead; private: struct Header { @@ -48,7 +48,7 @@ private: int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num); int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num); - void dataNotifier(EventNotifier *notifier); + void dataNotifier(); int fd_; bool headerReceived_; diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h index 3a7722c2..1f2304c1 100644 --- a/include/libcamera/internal/media_device.h +++ b/include/libcamera/internal/media_device.h @@ -53,7 +53,7 @@ public: MediaLink *link(const MediaPad *source, const MediaPad *sink); int disableLinks(); - Signal disconnected; + Signal<> disconnected; protected: std::string logPrefix() const override; diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h index c4d5d9c1..300e0521 100644 --- a/include/libcamera/internal/process.h +++ b/include/libcamera/internal/process.h @@ -38,7 +38,7 @@ public: void kill(); - Signal finished; + Signal finished; private: void closeAllFdsExcept(const std::vector &fds); @@ -70,7 +70,7 @@ public: private: static ProcessManager *self_; - void sighandler(EventNotifier *notifier); + void sighandler(); std::list processes_; diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index 423c8fb1..f21bc370 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -65,7 +65,7 @@ private: void updateControls(ControlList *ctrls, Span v4l2Ctrls); - void eventAvailable(EventNotifier *notifier); + void eventAvailable(); std::map controlInfo_; std::vector> controlIds_; diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 4a5d2cad..7a145f60 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -238,7 +238,7 @@ private: std::unique_ptr createBuffer(unsigned int index); FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane); - void bufferAvailable(EventNotifier *notifier); + void bufferAvailable(); FrameBuffer *dequeueBuffer(); V4L2Capability caps_; -- cgit v1.2.1