Changeset 5482


Ignore:
Timestamp:
Nov 15, 2016 2:23:38 AM (2 years ago)
Author:
ming
Message:

Re #1961: Fallback to CLOCK_MONOTONIC if /dev/alarm is not found, or getting ANDROID_ALARM_ELAPSED_REALTIME fails.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/os_timestamp_posix.c

    r5457 r5482  
    181181{ 
    182182    struct timespec tp; 
     183    int err = -1; 
    183184 
    184185    if (s_alarm_fd == -1) { 
     
    187188            s_alarm_fd = fd; 
    188189            pj_atexit(&close_alarm_fd); 
    189         } else { 
    190             return PJ_RETURN_OS_ERROR(pj_get_native_os_error());                 
    191         } 
    192     } 
    193     int err = ioctl(s_alarm_fd, 
    194             ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &tp); 
     190        } 
     191    } 
     192     
     193    if (s_alarm_fd != -1) { 
     194        err = ioctl(s_alarm_fd, 
     195              ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &tp); 
     196    } 
     197     
     198    if (err != 0) { 
     199        /* Fallback to CLOCK_MONOTONIC if /dev/alarm is not found, or 
     200         * getting ANDROID_ALARM_ELAPSED_REALTIME fails. 
     201         */ 
     202        err = clock_gettime(CLOCK_MONOTONIC, &tp); 
     203    } 
    195204 
    196205    if (err != 0) { 
Note: See TracChangeset for help on using the changeset viewer.