diff options
author | Dallas Delaney <ddelaney@codeaurora.org> | 2018-02-14 14:31:29 -0800 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2019-12-01 04:43:50 +0100 |
commit | 7d3f9bd1f85fd1fac86539fb7aa674cb392c9d37 (patch) | |
tree | 538a31d01bc320ef8379c9fe2fb2b056387dd63d | |
parent | 646982029d89e765489a76ecbbfab59eb7fc887d (diff) | |
download | hardware_qcom_audio-7d3f9bd1f85fd1fac86539fb7aa674cb392c9d37.tar.gz hardware_qcom_audio-7d3f9bd1f85fd1fac86539fb7aa674cb392c9d37.tar.bz2 hardware_qcom_audio-7d3f9bd1f85fd1fac86539fb7aa674cb392c9d37.zip |
mm-audio: Replace wall time in QC HAL code
Replace clock reference from REALTIME (wall clock) to MONOTONIC . This is to
avoid getting impacted when system time is set backwards or forwards (either
through network or manually)
Change-Id: I989c7bd0adc80ffb40f65ec909295ca1d8501877
-rw-r--r-- | mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp | 13 | ||||
-rw-r--r-- | mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp | 15 | ||||
-rw-r--r-- | mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp | 15 | ||||
-rw-r--r-- | mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp | 15 |
4 files changed, 47 insertions, 11 deletions
diff --git a/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp b/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp index e487e260..eb1aa51b 100644 --- a/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp +++ b/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp @@ -150,9 +150,14 @@ void omx_aac_aenc::wait_for_event() pthread_mutex_lock(&m_event_lock); while (0 == m_is_event_done) { - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); ts.tv_sec += (SLEEP_MS/1000); ts.tv_nsec += ((SLEEP_MS%1000) * 1000000); + if (ts.tv_nsec >= 1000000000) + { + ts.tv_nsec -= 1000000000; + ts.tv_sec += 1; + } rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts); if (rc == ETIMEDOUT && !m_is_event_done) { DEBUG_PRINT("Timed out waiting for flush"); @@ -297,6 +302,7 @@ omx_aac_aenc::omx_aac_aenc(): m_tmp_meta_buf(NULL), { int cond_ret = 0; component_Role.nSize = 0; + pthread_condattr_t attr; memset(&m_cmp, 0, sizeof(m_cmp)); memset(&m_cb, 0, sizeof(m_cb)); memset(&m_aac_pb_stats, 0, sizeof(m_aac_pb_stats)); @@ -342,7 +348,10 @@ omx_aac_aenc::omx_aac_aenc(): m_tmp_meta_buf(NULL), pthread_mutexattr_init(&in_buf_count_lock_attr); pthread_mutex_init(&in_buf_count_lock, &in_buf_count_lock_attr); - if ((cond_ret = pthread_cond_init (&cond, NULL)) != 0) + + pthread_condattr_init(&attr); + pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); + if ((cond_ret = pthread_cond_init (&cond, &attr)) != 0) { DEBUG_PRINT_ERROR("pthread_cond_init returns non zero for cond\n"); if (cond_ret == EAGAIN) diff --git a/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp b/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp index de0c063e..4222b110 100644 --- a/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp +++ b/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp @@ -1,5 +1,5 @@ /*-------------------------------------------------------------------------- -Copyright (c) 2010, 2014, 2016-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2010, 2014, 2016-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -149,9 +149,14 @@ void omx_amr_aenc::wait_for_event() pthread_mutex_lock(&m_event_lock); while (0 == m_is_event_done) { - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); ts.tv_sec += (SLEEP_MS/1000); ts.tv_nsec += ((SLEEP_MS%1000) * 1000000); + if (ts.tv_nsec >= 1000000000) + { + ts.tv_nsec -= 1000000000; + ts.tv_sec += 1; + } rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts); if (rc == ETIMEDOUT && !m_is_event_done) { DEBUG_PRINT("Timed out waiting for flush"); @@ -295,6 +300,7 @@ omx_amr_aenc::omx_amr_aenc(): m_tmp_meta_buf(NULL), { int cond_ret = 0; component_Role.nSize = 0; + pthread_condattr_t attr; memset(&m_cmp, 0, sizeof(m_cmp)); memset(&m_cb, 0, sizeof(m_cb)); memset(&m_pcm_param, 0, sizeof(m_pcm_param)); @@ -340,7 +346,10 @@ omx_amr_aenc::omx_amr_aenc(): m_tmp_meta_buf(NULL), pthread_mutexattr_init(&in_buf_count_lock_attr); pthread_mutex_init(&in_buf_count_lock, &in_buf_count_lock_attr); - if ((cond_ret = pthread_cond_init (&cond, NULL)) != 0) + + pthread_condattr_init(&attr); + pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); + if ((cond_ret = pthread_cond_init (&cond, &attr)) != 0) { DEBUG_PRINT_ERROR("pthread_cond_init returns non zero for cond\n"); if (cond_ret == EAGAIN) diff --git a/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp b/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp index 45020c19..d854ed25 100644 --- a/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp +++ b/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp @@ -1,5 +1,5 @@ /*-------------------------------------------------------------------------- -Copyright (c) 2010, 2014-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2010, 2014-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -149,9 +149,14 @@ void omx_evrc_aenc::wait_for_event() pthread_mutex_lock(&m_event_lock); while (0 == m_is_event_done) { - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); ts.tv_sec += (SLEEP_MS/1000); ts.tv_nsec += ((SLEEP_MS%1000) * 1000000); + if (ts.tv_nsec >= 1000000000) + { + ts.tv_nsec -= 1000000000; + ts.tv_sec += 1; + } rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts); if (rc == ETIMEDOUT && !m_is_event_done) { DEBUG_PRINT("Timed out waiting for flush"); @@ -292,6 +297,7 @@ omx_evrc_aenc::omx_evrc_aenc(): m_tmp_meta_buf(NULL), m_ipc_to_cmd_th(NULL) { int cond_ret = 0; + pthread_condattr_t attr; memset(&m_cmp, 0, sizeof(m_cmp)); memset(&m_cb, 0, sizeof(m_cb)); memset(&m_evrc_param, 0, sizeof(m_evrc_param)); @@ -337,7 +343,10 @@ omx_evrc_aenc::omx_evrc_aenc(): m_tmp_meta_buf(NULL), pthread_mutexattr_init(&in_buf_count_lock_attr); pthread_mutex_init(&in_buf_count_lock, &in_buf_count_lock_attr); - if ((cond_ret = pthread_cond_init (&cond, NULL)) != 0) + + pthread_condattr_init(&attr); + pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); + if ((cond_ret = pthread_cond_init (&cond, &attr)) != 0) { DEBUG_PRINT_ERROR("pthread_cond_init returns non zero for cond\n"); if (cond_ret == EAGAIN) diff --git a/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp b/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp index 6cdf8e6b..7b76e14f 100644 --- a/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp +++ b/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp @@ -1,5 +1,5 @@ /*-------------------------------------------------------------------------- -Copyright (c) 2010, 2014-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2010, 2014-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -149,9 +149,14 @@ void omx_qcelp13_aenc::wait_for_event() pthread_mutex_lock(&m_event_lock); while (0 == m_is_event_done) { - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); ts.tv_sec += (SLEEP_MS/1000); ts.tv_nsec += ((SLEEP_MS%1000) * 1000000); + if (ts.tv_nsec >= 1000000000) + { + ts.tv_nsec -= 1000000000; + ts.tv_sec += 1; + } rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts); if (rc == ETIMEDOUT && !m_is_event_done) { DEBUG_PRINT("Timed out waiting for flush"); @@ -296,6 +301,7 @@ omx_qcelp13_aenc::omx_qcelp13_aenc(): m_tmp_meta_buf(NULL), { int cond_ret = 0; component_Role.nSize = 0; + pthread_condattr_t attr; memset(&m_cmp, 0, sizeof(m_cmp)); memset(&m_cb, 0, sizeof(m_cb)); memset(&m_qcelp13_pb_stats, 0, sizeof(m_qcelp13_pb_stats)); @@ -341,7 +347,10 @@ omx_qcelp13_aenc::omx_qcelp13_aenc(): m_tmp_meta_buf(NULL), pthread_mutexattr_init(&in_buf_count_lock_attr); pthread_mutex_init(&in_buf_count_lock, &in_buf_count_lock_attr); - if ((cond_ret = pthread_cond_init (&cond, NULL)) != 0) + + pthread_condattr_init(&attr); + pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); + if ((cond_ret = pthread_cond_init (&cond, &attr)) != 0) { DEBUG_PRINT_ERROR("pthread_cond_init returns non zero for cond\n"); if (cond_ret == EAGAIN) |