Skip to content
Snippets Groups Projects
Commit 45f3725b authored by Andreas Traczyk's avatar Andreas Traczyk Committed by gerrit2
Browse files

audiolayer: use std::chrono for time calculations


- Notification tones for calls incoming when there is a call already
  in progress were using time_t objects to calculate the passage of
  time. This patch implements time_point objects instead, thus
  removing a dependency on sys/time.h which is not available on
  all platforms.

Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Change-Id: I3850706e2f6ddb3fd5d308148883031a9cd0cb6b
Tuleap: #790
parent 71882bc4
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@ AudioLayer::AudioLayer(const AudioPreference &pref)
, urgentRingBuffer_("urgentRingBuffer_id", SIZEBUF, audioFormat_)
, resampler_(new Resampler{audioFormat_.sample_rate})
, inputResampler_(new Resampler{audioInputFormat_.sample_rate})
, lastNotificationTime_(0)
, lastNotificationTime_()
{
urgentRingBuffer_.createReadOffset(RingBufferPool::DEFAULT_ID);
}
......@@ -93,10 +93,10 @@ void AudioLayer::notifyIncomingCall()
if (!Manager::instance().incomingCallsWaiting())
return;
time_t now = time(NULL);
auto now = std::chrono::system_clock::now();
// Notify maximum once every 5 seconds
if (difftime(now, lastNotificationTime_) < 5)
if ((now - lastNotificationTime_) < std::chrono::seconds(5))
return;
lastNotificationTime_ = now;
......
......@@ -29,7 +29,7 @@
#include "dcblocker.h"
#include "noncopyable.h"
#include <sys/time.h>
#include <chrono>
#include <mutex>
#include <vector>
#include <atomic>
......@@ -311,7 +311,7 @@ class AudioLayer {
/**
* Time of the last incoming call notification
*/
time_t lastNotificationTime_;
std::chrono::system_clock::time_point lastNotificationTime_;
};
} // namespace ring
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment