mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-25 01:50:22 +08:00
fix[osal]: Fix timeout expire too soon issue
Using CLOCK_MONOTONIC instead of CLOCK_REALTIME to avoid date-2038 issue. Also timeout will expire sooner or later than intended if using CLOCK_REALTIME when clock changed dramatically. Platform: 32-bit program Spec: all Reported-by: #555412 at redmine Reprodece: 1. setting system date after 2040-01-01 2. running 32-bit program calling mpp video encoder at non-block mode with 100ms timeout. eg: screenrecord at Android 11. This program will call mpp via vpu_api_legacy routine with a 100ms timeout. 3. timeout will expire sooner than 100ms. Change-Id: I804146d6e33f5c30cbd3bdfdcf10b6dd56b0610c Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
This commit is contained in:
committed by
Herman Chen
parent
9c93a16e11
commit
0a0111b398
@@ -20,6 +20,10 @@
|
||||
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER
|
||||
#endif
|
||||
|
||||
#if defined(__USE_XOPEN2K) || (defined(__ANDROID__) && __ANDROID_API__ >= 21)
|
||||
#define COND_USE_CLOCK_MONOTONIC
|
||||
#endif
|
||||
|
||||
#define THREAD_NAME_LEN 16
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -37,16 +41,17 @@ typedef enum MppThreadStatus_e {
|
||||
} MppThreadStatus;
|
||||
|
||||
typedef struct MppMutex_t {
|
||||
pthread_mutex_t m_lock;
|
||||
pthread_mutex_t lock;
|
||||
} MppMutex;
|
||||
|
||||
typedef struct MppCond_t {
|
||||
pthread_cond_t m_cond;
|
||||
pthread_cond_t cond;
|
||||
clockid_t clock_id;
|
||||
} MppCond;
|
||||
|
||||
typedef struct MppMutexCond_t {
|
||||
MppMutex m_lock;
|
||||
MppCond m_cond;
|
||||
MppMutex lock;
|
||||
MppCond cond;
|
||||
} MppMutexCond;
|
||||
|
||||
typedef enum MppThreadSignalId_e {
|
||||
@@ -63,7 +68,7 @@ typedef struct MppThread_t {
|
||||
MppThreadStatus thd_status[THREAD_SIGNAL_BUTT];
|
||||
MppThreadFunc func;
|
||||
char name[THREAD_NAME_LEN];
|
||||
void *m_ctx;
|
||||
void *ctx;
|
||||
} MppThread;
|
||||
|
||||
// Mutex functions
|
||||
|
||||
Reference in New Issue
Block a user