Time
APIs for the MLTime. More...
Functions
| Name | |
|---|---|
| MLResult | MLTimeConvertMLTimeToSystemTime(MLTime ml_time, struct timespec * out_timespec_time) Converts timestamps from MLTime to system time. |
| MLResult | MLTimeConvertSystemTimeToMLTime(const struct timespec timespec_time, MLTime out_ml_time) Converts timestamps from system time to MLTime. |
Detailed Description
APIs for the MLTime.
timespec time_spec{};
clock_gettime(CLOCK_MONOTONIC, &time_spec);
MLTime converted_ml_time{};
if (MLResult_Ok != MLTimeConvertSystemTimeToMLTime(&time_spec, &converted_ml_time)) {
ML_LOG_ERROR("Failed to convert to MLTime timestamp");
}
Shared Object:
- perception.magicleap*
Functions Documentation
MLTimeConvertMLTimeToSystemTime
MLResult MLTimeConvertMLTimeToSystemTime(
MLTime ml_time,
struct timespec * out_timespec_time
)
Converts timestamps from MLTime to system time.
Parameters
| MLTime | ml_time | Timestamp received from elsewhere in the ML system. |
| struct timespec * | out_timespec_time | Pointer to a converted equivalent timestamp as if received from clock_gettime using CLOCK_MONOTONIC. |
Returns
| MLResult | MLResult_Ok | Successfully converted timestamp. |
| MLResult | MLResult_InvalidParam | NULL passed for timespec_time. |
| MLResult | MLResult_UnspecifiedFailure | Failed to convert timestamp with unknown error. |
Required Permissions:
- None
See MLTime for more details. System time is equivalent to the systems monotonic clock. This can be used to calculate duration between two MLTime values by converting them both to a timespec and subtracting the subsequent values.
API Level:
- 20
MLTimeConvertSystemTimeToMLTime
MLResult MLTimeConvertSystemTimeToMLTime(
const struct timespec * timespec_time,
MLTime * out_ml_time
)
Converts timestamps from system time to MLTime.
Parameters
| const struct timespec * | timespec_time | System clock timestamp as received from clock_gettime using CLOCK_MONOTONIC. |
| MLTime * | out_ml_time | Pointer to system timestamp equivalent in MLTime. |
Returns
| MLResult | MLResult_Ok | Successfully converted timestamp. |
| MLResult | MLResult_InvalidParam | NULL passed for ml_time. |
| MLResult | MLResult_UnspecifiedFailure | Failed to convert timespec with unknown error. |
Required Permissions:
- None
See MLTime for more details. System time is equivalent to the systems monotonic clock.
API Level:
- 20