utils: Add unary negation operation to Duration

In the near future we will add a SyncAdjustment control for adjusting
the frame duration via the sync algorithm. This control needs to be able
to take on a negative value, since the frame duration can be shortened
in addition to being extended. While the control is an int, it would be
convenient to be able to clamp it to frame duration limits, which are
usually handled as utils::Duration values internally. To allow this
using utils::Duration, add a unary negation operation to
utils::Duration. Also add a test for the operator.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Paul Elder
2025-09-01 12:43:43 +01:00
committed by Kieran Bingham
parent 278cdfd865
commit 6554b62642
3 changed files with 17 additions and 0 deletions
+6
View File
@@ -167,6 +167,12 @@ protected:
return TestFail;
}
exposure = 100ms;
if ((-exposure).get<std::milli>() != -100) {
cerr << "utils::Duration failed negation" << endl;
return TestFail;
}
return TestPass;
}