[libcamera-devel] [PATCH] android: Rework request completion notification
Niklas Söderlund
niklas.soderlund at ragnatech.se
Thu May 6 11:03:09 CEST 2021
Hi Jacopo,
On 2021-05-06 10:53:02 +0200, Jacopo Mondi wrote:
<snip>
> > >
> > > - resultMetadata = getResultMetadata(descriptor);
> > > + /*
> > > + * Generate the metadata associated with the captured buffers.
> > > + *
> > > + * Notify if the metadata generation has failed, but continue processing
> > > + * buffers and return an empty metadata pack.
> > > + */
> > > + std::unique_ptr<CameraMetadata> resultMetadata = getResultMetadata(descriptor);
> > > + if (!resultMetadata)
> > > + notifyError(descriptor.frameNumber_, descriptor.buffers_[0].stream,
> > > + CAMERA3_MSG_ERROR_RESULT);
> > > + captureResult.result = resultMetadata->get();
> >
> > Hum if !resultMetadata will not resultMetadata->get() give us a nullptr
> > exception here?
> >
>
> According to the std::unique_ptr<>::get() documentation:
>
> "Returns a pointer to the managed object or nullptr if no object is owned."
>
> as getResultMetadata() returns nullptr on error, and the function
> signature is
> std::unique_ptr<CameraMetadata> CameraDevice::getResultMetadata()
>
> my understanding is that the returned unique_ptr<> will own no object,
> hence get() should return nullptr. Or have I missed something about
> the "no object is owned" vs "a unique_ptr<> that owns nullptr" ?
I share your understanding of std::unique_ptr<>::get() but that would be
resultMetadata.get()
and not
resultMetadata->get()
The later calls CameraMetadata::get() which returns camera_metadata_t *
which is the correct datatype for the captureResult.result right? So I
think the code calls the correct get(), only the manual protection for
the nullptr is missing.
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list