diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-08-27 04:45:28 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-09-02 01:16:45 +0300 |
commit | 3335d5a504374166f749a267ba1e1d803a0ed1f6 (patch) | |
tree | 9ea78ff7c716319cb0ce031f28b4337e46f96f12 /src | |
parent | 3f662ae3c0c6e6564f1abe09d7d297e34f77b4fb (diff) |
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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/base/event_dispatcher_poll.cpp | 4 | ||||
-rw-r--r-- | src/libcamera/base/thread.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/camera.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/device_enumerator.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/device_enumerator_udev.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/ipc_pipe_unixsocket.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/ipc_unixsocket.cpp | 4 | ||||
-rw-r--r-- | src/libcamera/pipeline_handler.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/process.cpp | 4 | ||||
-rw-r--r-- | src/libcamera/v4l2_device.cpp | 3 | ||||
-rw-r--r-- | src/libcamera/v4l2_videodevice.cpp | 3 |
11 files changed, 14 insertions, 16 deletions
diff --git a/src/libcamera/base/event_dispatcher_poll.cpp b/src/libcamera/base/event_dispatcher_poll.cpp index 4f22f579..3c9a126c 100644 --- a/src/libcamera/base/event_dispatcher_poll.cpp +++ b/src/libcamera/base/event_dispatcher_poll.cpp @@ -278,7 +278,7 @@ void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pol } if (pfd.revents & event.events) - notifier->activated.emit(notifier); + notifier->activated.emit(); } /* Erase the notifiers_ entry if it is now empty. */ @@ -300,7 +300,7 @@ void EventDispatcherPoll::processTimers() timers_.pop_front(); timer->stop(); - timer->timeout.emit(timer); + timer->timeout.emit(); } } diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index bd7b7391..d0ca30e3 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -384,7 +384,7 @@ void Thread::finishThread() data_->running_ = false; data_->mutex_.unlock(); - finished.emit(this); + finished.emit(); data_->cv_.notify_all(); } diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 98438312..71809bcd 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -688,7 +688,7 @@ void Camera::disconnect() LOG(Camera, Debug) << "Disconnecting camera " << id(); _d()->disconnect(); - disconnected.emit(this); + disconnected.emit(); } int Camera::exportFrameBuffers(Stream *stream, diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index ec59927e..d1258050 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -288,7 +288,7 @@ void DeviceEnumerator::removeDevice(const std::string &deviceNode) LOG(DeviceEnumerator, Debug) << "Media device for node " << deviceNode << " removed."; - media->disconnected.emit(media.get()); + media->disconnected.emit(); } /** diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp index 37a2c5aa..5317afbd 100644 --- a/src/libcamera/device_enumerator_udev.cpp +++ b/src/libcamera/device_enumerator_udev.cpp @@ -327,7 +327,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum) return 0; } -void DeviceEnumeratorUdev::udevNotify([[maybe_unused]] EventNotifier *notifier) +void DeviceEnumeratorUdev::udevNotify() { struct udev_device *dev = udev_monitor_receive_device(monitor_); std::string action(udev_device_get_action(dev)); diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp index 38bcc30a..533560cf 100644 --- a/src/libcamera/ipc_pipe_unixsocket.cpp +++ b/src/libcamera/ipc_pipe_unixsocket.cpp @@ -82,7 +82,7 @@ int IPCPipeUnixSocket::sendAsync(const IPCMessage &data) return 0; } -void IPCPipeUnixSocket::readyRead([[maybe_unused]] IPCUnixSocket *socket) +void IPCPipeUnixSocket::readyRead() { IPCUnixSocket::Payload payload; int ret = socket_->receive(&payload); diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp index 7188cf29..bd32fca3 100644 --- a/src/libcamera/ipc_unixsocket.cpp +++ b/src/libcamera/ipc_unixsocket.cpp @@ -311,7 +311,7 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, return 0; } -void IPCUnixSocket::dataNotifier([[maybe_unused]] EventNotifier *notifier) +void IPCUnixSocket::dataNotifier() { int ret; @@ -342,7 +342,7 @@ void IPCUnixSocket::dataNotifier([[maybe_unused]] EventNotifier *notifier) return; notifier_->setEnabled(false); - readyRead.emit(this); + readyRead.emit(); } } /* namespace libcamera */ diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 597d4c6a..f69c4f03 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -448,7 +448,7 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera) */ void PipelineHandler::hotplugMediaDevice(MediaDevice *media) { - media->disconnected.connect(this, &PipelineHandler::mediaDeviceDisconnected); + media->disconnected.connect(this, [=]() { mediaDeviceDisconnected(media); }); } /** diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index 998d08c2..eca1b300 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -66,7 +66,7 @@ void sigact(int signal, siginfo_t *info, void *ucontext) } /* namespace */ -void ProcessManager::sighandler([[maybe_unused]] EventNotifier *notifier) +void ProcessManager::sighandler() { char data; ssize_t ret = read(pipe_[0], &data, sizeof(data)); @@ -326,7 +326,7 @@ void Process::died(int wstatus) exitStatus_ = WIFEXITED(wstatus) ? NormalExit : SignalExit; exitCode_ = exitStatus_ == NormalExit ? WEXITSTATUS(wstatus) : -1; - finished.emit(this, exitStatus_, exitCode_); + finished.emit(exitStatus_, exitCode_); } /** diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 951592c6..9c783c9c 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -705,12 +705,11 @@ void V4L2Device::updateControls(ControlList *ctrls, /** * \brief Slot to handle V4L2 events from the V4L2 device - * \param[in] notifier The event notifier * * When this slot is called, a V4L2 event is available to be dequeued from the * device. */ -void V4L2Device::eventAvailable([[maybe_unused]] EventNotifier *notifier) +void V4L2Device::eventAvailable() { struct v4l2_event event{}; int ret = ioctl(VIDIOC_DQEVENT, &event); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 9d35618d..4e1c2b7c 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1524,7 +1524,6 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) /** * \brief Slot to handle completed buffer events from the V4L2 video device - * \param[in] notifier The event notifier * * When this slot is called, a Buffer has become available from the device, and * will be emitted through the bufferReady Signal. @@ -1532,7 +1531,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) * For Capture video devices the FrameBuffer will contain valid data. * For Output video devices the FrameBuffer can be considered empty. */ -void V4L2VideoDevice::bufferAvailable([[maybe_unused]] EventNotifier *notifier) +void V4L2VideoDevice::bufferAvailable() { FrameBuffer *buffer = dequeueBuffer(); if (!buffer) |