Revert "HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE is never defined."
This reverts commit f815f857b92629fb9dd6e81e201eea983fb0a4ed.
Change-Id: Iac490089fa548189e49626834aff7af155fc3acd
diff --git a/audio_utils/echo_reference.c b/audio_utils/echo_reference.c
index b2ea43a..178b306 100644
--- a/audio_utils/echo_reference.c
+++ b/audio_utils/echo_reference.c
@@ -332,6 +332,10 @@
uint32_t timeoutMs = (uint32_t)((1000 * buffer->frame_count) / er->rd_sampling_rate / 2);
struct timespec ts = {0, 0};
+#ifndef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
+ clock_gettime(CLOCK_REALTIME, &ts);
+#endif
+
ts.tv_sec += timeoutMs/1000;
ts.tv_nsec += (timeoutMs%1000) * 1000000;
if (ts.tv_nsec >= 1000000000) {
@@ -339,7 +343,11 @@
ts.tv_sec += 1;
}
+#ifdef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
+ pthread_cond_timedwait_relative_np(&er->cond, &er->lock, &ts);
+#else
pthread_cond_timedwait(&er->cond, &er->lock, &ts);
+#endif
ALOGV_IF((er->frames_in < buffer->frame_count),
"echo_reference_read() waited %d ms but still not enough frames"\