[libcamera-devel] [PATCH 01/11] Fixes Bug 156, which breaks libcamera on Android < 12.

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Oct 26 10:24:41 CEST 2022


Quoting Nicholas Roth (2022-10-26 02:50:34)
> Another possible fix is to cast libcamera::utils::Duration to
> std::chrono::duration before performing division. I've tested that and it
> works. Would folks be amenable to that instead?

That sounds like we still have to make global updates. Are any of those
locations where we should store a libcamera::utils::Duration instead of
a std::chrono::duration to prevent having to cast?

If casting works around the issue, is it sufficient / possible to
provide an explicit casting operator? (I've never done this to more than
the POD types, but it 'looks' like you can specify specific target
classes as an operator?)

  https://en.cppreference.com/w/cpp/language/cast_operator

Something like (I have no idea if this is something that can work, or if
it helps the compiler as it should already know the type?!)...:

class Duration : public std::chrono::duration<double, std::nano>
{
...

	explicit operator std::chrono::duration() {
		return std::chrono::duration_cast<BaseDuration>>(*this);
	}

or perhaps 'worse' ? (but at least isolated to here in the class?)...

	constexpr explicit operator double() {
		return get<std::nano>();
	}

...
}

--
Kieran


More information about the libcamera-devel mailing list