Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af702c1e authored by Dallas Delaney's avatar Dallas Delaney Committed by Arne Coucheron
Browse files

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
parent cbb8bb20
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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)
+12 −3
Original line number Diff line number Diff line
/*--------------------------------------------------------------------------
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)
+12 −3
Original line number Diff line number Diff line
/*--------------------------------------------------------------------------
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)
+12 −3
Original line number Diff line number Diff line
/*--------------------------------------------------------------------------
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)