libcamera: converter: Utilise shared MediaDevice pointers
With the upcoming addition of V4L2 requests support, the converters need to keep a handle to the corresponding media device. Prepare for that by changing the constructor parameter from a raw pointer to a shared pointer. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "libcamera/internal/converter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include <libcamera/base/log.h>
|
||||
|
||||
@@ -68,7 +69,7 @@ LOG_DEFINE_CATEGORY(Converter)
|
||||
* This searches for the entity implementing the data streaming function in the
|
||||
* media graph entities and use its device node as the converter device node.
|
||||
*/
|
||||
Converter::Converter(MediaDevice *media, Features features)
|
||||
Converter::Converter(std::shared_ptr<MediaDevice> media, Features features)
|
||||
{
|
||||
const std::vector<MediaEntity *> &entities = media->entities();
|
||||
auto it = std::find_if(entities.begin(), entities.end(),
|
||||
@@ -332,7 +333,7 @@ ConverterFactoryBase::ConverterFactoryBase(const std::string name, std::initiali
|
||||
* \return A new instance of the converter subclass corresponding to the media
|
||||
* device, or null if the media device driver name doesn't match anything
|
||||
*/
|
||||
std::unique_ptr<Converter> ConverterFactoryBase::create(MediaDevice *media)
|
||||
std::unique_ptr<Converter> ConverterFactoryBase::create(std::shared_ptr<MediaDevice> media)
|
||||
{
|
||||
const std::vector<ConverterFactoryBase *> &factories =
|
||||
ConverterFactoryBase::factories();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits.h>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include <libcamera/base/log.h>
|
||||
@@ -261,8 +262,7 @@ void V4L2M2MConverter::V4L2M2MStream::captureBufferReady(FrameBuffer *buffer)
|
||||
* \brief Construct a V4L2M2MConverter instance
|
||||
* \param[in] media The media device implementing the converter
|
||||
*/
|
||||
|
||||
V4L2M2MConverter::V4L2M2MConverter(MediaDevice *media)
|
||||
V4L2M2MConverter::V4L2M2MConverter(std::shared_ptr<MediaDevice> media)
|
||||
: Converter(media)
|
||||
{
|
||||
if (deviceNode().empty())
|
||||
|
||||
@@ -1445,7 +1445,7 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)
|
||||
|
||||
std::shared_ptr<MediaDevice> dwpMediaDevice = enumerator->search(dwp);
|
||||
if (dwpMediaDevice) {
|
||||
dewarper_ = std::make_unique<V4L2M2MConverter>(dwpMediaDevice.get());
|
||||
dewarper_ = std::make_unique<V4L2M2MConverter>(dwpMediaDevice);
|
||||
if (dewarper_->isValid()) {
|
||||
dewarper_->outputBufferReady.connect(
|
||||
this, &PipelineHandlerRkISP1::dewarpBufferReady);
|
||||
|
||||
@@ -415,7 +415,7 @@ public:
|
||||
|
||||
V4L2VideoDevice *video(const MediaEntity *entity);
|
||||
V4L2Subdevice *subdev(const MediaEntity *entity);
|
||||
MediaDevice *converter() { return converter_.get(); }
|
||||
std::shared_ptr<MediaDevice> converter() { return converter_; }
|
||||
bool swIspEnabled() const { return swIspEnabled_; }
|
||||
|
||||
protected:
|
||||
@@ -588,7 +588,7 @@ int SimpleCameraData::init()
|
||||
int ret;
|
||||
|
||||
/* Open the converter, if any. */
|
||||
MediaDevice *converter = pipe->converter();
|
||||
std::shared_ptr<MediaDevice> converter = pipe->converter();
|
||||
if (converter) {
|
||||
converter_ = ConverterFactoryBase::create(converter);
|
||||
if (!converter_) {
|
||||
|
||||
Reference in New Issue
Block a user