diff --git a/src/autoapp/Projection/AudioInputService.cpp b/src/autoapp/Projection/AudioInputService.cpp index 1aa7669..755ddba 100644 --- a/src/autoapp/Projection/AudioInputService.cpp +++ b/src/autoapp/Projection/AudioInputService.cpp @@ -177,11 +177,8 @@ void AudioInputService::onAudioInputDataReady(aasdk::common::Data data) sendPromise->then(std::bind(&AudioInputService::readAudioInput, this->shared_from_this()), std::bind(&AudioInputService::onChannelError, this->shared_from_this(), std::placeholders::_1)); - - timespec tp; - clock_gettime(CLOCK_REALTIME, &tp); - auto timestamp = tp.tv_sec * 1000000 + tp.tv_nsec / 1000; - channel_->sendAVMediaWithTimestampIndication(timestamp, std::move(data), std::move(sendPromise)); + auto timestamp = std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()); + channel_->sendAVMediaWithTimestampIndication(timestamp.count(), std::move(data), std::move(sendPromise)); } void AudioInputService::readAudioInput() diff --git a/src/autoapp/Projection/InputService.cpp b/src/autoapp/Projection/InputService.cpp index 65f8c81..7bc611c 100644 --- a/src/autoapp/Projection/InputService.cpp +++ b/src/autoapp/Projection/InputService.cpp @@ -137,13 +137,11 @@ void InputService::onChannelError(const aasdk::error::Error& e) void InputService::onButtonEvent(const ButtonEvent& event) { - timespec tp; - clock_gettime(CLOCK_REALTIME, &tp); - auto timestamp = tp.tv_sec * 1000000 + tp.tv_nsec / 1000; + auto timestamp = std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()); - strand_.dispatch([this, self = this->shared_from_this(), event = std::move(event), timestamp]() { + strand_.dispatch([this, self = this->shared_from_this(), event = std::move(event), timestamp = std::move(timestamp)]() { aasdk::proto::messages::InputEventIndication inputEventIndication; - inputEventIndication.set_timestamp(timestamp); + inputEventIndication.set_timestamp(timestamp.count()); if(event.code == aasdk::proto::enums::ButtonCode::SCROLL_WHEEL) { @@ -168,13 +166,11 @@ void InputService::onButtonEvent(const ButtonEvent& event) void InputService::onTouchEvent(const TouchEvent& event) { - timespec tp; - clock_gettime(CLOCK_REALTIME, &tp); - auto timestamp = tp.tv_sec * 1000000 + tp.tv_nsec / 1000; + auto timestamp = std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()); - strand_.dispatch([this, self = this->shared_from_this(), event = std::move(event), timestamp]() { + strand_.dispatch([this, self = this->shared_from_this(), event = std::move(event), timestamp = std::move(timestamp)]() { aasdk::proto::messages::InputEventIndication inputEventIndication; - inputEventIndication.set_timestamp(timestamp); + inputEventIndication.set_timestamp(timestamp.count()); auto touchEvent = inputEventIndication.mutable_touch_event(); touchEvent->set_touch_action(event.type);