Use monotonic system time instead of gettimeofday
Several Codec2 plugins used gettimeofday() to measure durations
which could cause overflows if during an inopportune clock change.
Replace with systemTime().
Bug: 229389483
Test: simple playback
Change-Id: Iefcfd12430763162f40a71d5d04e5fea95564069
diff --git a/media/codec2/components/hevc/C2SoftHevcDec.h b/media/codec2/components/hevc/C2SoftHevcDec.h
index b9296e9..6abf69e 100644
--- a/media/codec2/components/hevc/C2SoftHevcDec.h
+++ b/media/codec2/components/hevc/C2SoftHevcDec.h
@@ -20,6 +20,7 @@
#include <media/stagefright/foundation/ColorUtils.h>
#include <atomic>
+#include <inttypes.h>
#include <SimpleC2Component.h>
#include "ihevc_typedefs.h"
@@ -41,10 +42,6 @@
#define IVDEXT_CMD_CTL_SET_NUM_CORES \
(IVD_CONTROL_API_COMMAND_TYPE_T)IHEVCD_CXA_CMD_CTL_SET_NUM_CORES
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define GETTIME(a, b) gettimeofday(a, b);
-#define TIME_DIFF(start, end, diff) \
- diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
- ((end).tv_usec - (start).tv_usec);
struct C2SoftHevcDec : public SimpleC2Component {
@@ -142,8 +139,8 @@
} mBitstreamColorAspects;
// profile
- struct timeval mTimeStart;
- struct timeval mTimeEnd;
+ nsecs_t mTimeStart = 0;
+ nsecs_t mTimeEnd = 0;
C2_DO_NOT_COPY(C2SoftHevcDec);
};