From dd21ededd0fe9dede5942b0b68c45d43f1d671bd Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Tue, 16 Jun 2020 19:45:36 +0000 Subject: libcamera: device_enumerator: Emit a signal when new devices are added Emit a signal whenever new MediaDevices are added to the DeviceEnumerator. This will allow CameraManager to be notified about the new devices and it can re-emumerate all the devices currently present on the system. Device enumeration by the CameraManger is an expensive operation hence, we want one signal emission per 'x' milliseconds to notify multiple devices additions as a single batch, by the DeviceEnumerator. Add a \todo to investigate the support for that. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Laurent Pinchart --- src/libcamera/device_enumerator.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/libcamera/device_enumerator.cpp') diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index e21a2a7d..647974b1 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -227,6 +227,16 @@ std::unique_ptr DeviceEnumerator::createDevice(const std::string &d return media; } +/** +* \var DeviceEnumerator::devicesAdded +* \brief Notify of new media devices being found +* +* This signal is emitted when the device enumerator finds new media devices in +* the system. It may be emitted for every newly detected device, or once for +* multiple devices, at the discretion of the device enumerator. Not all device +* enumerator types may support dynamic detection of new devices. +*/ + /** * \brief Add a media device to the enumerator * \param[in] media media device instance to add @@ -242,6 +252,9 @@ void DeviceEnumerator::addDevice(std::unique_ptr &&media) << "Added device " << media->deviceNode() << ": " << media->driver(); devices_.push_back(std::move(media)); + + /* \todo To batch multiple additions, emit with a small delay here. */ + devicesAdded.emit(); } /** -- cgit v1.2.1