Commit af832000 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Use base::TimeDelta::FromTimeSpec helper in more places.

Change-Id: Id3444dca74b55269c4f07c303f2f9c49cc0e6049
Reviewed-on: https://chromium-review.googlesource.com/c/1485699Reviewed-by: default avatarDan Erat <derat@chromium.org>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635312}
parent 820b0894
......@@ -6,6 +6,7 @@
#include <time.h>
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/resource_coordinator/tab_manager.h"
#include "dbus/message.h"
......@@ -54,7 +55,7 @@ void MetricsEventServiceProvider::EmitSignal(metrics_event::Event_Type type) {
PLOG(DFATAL) << "clock_gettime";
return;
}
int64_t now_ms = timespec.tv_sec * 1000 + timespec.tv_nsec / (1000 * 1000);
int64_t now_ms = base::TimeDelta::FromTimeSpec(timespec).InMilliseconds();
dbus::MessageWriter writer(&signal);
payload.set_type(type);
......
......@@ -19,8 +19,7 @@ base::TimeDelta RealBootClock::GetTimeSinceBoot() {
struct timespec ts = {0};
const int ret = clock_gettime(CLOCK_BOOTTIME, &ts);
DCHECK_EQ(ret, 0);
return base::TimeDelta::FromSeconds(ts.tv_sec) +
base::TimeDelta::FromNanoseconds(ts.tv_nsec);
return base::TimeDelta::FromTimeSpec(ts);
}
} // namespace ml
......
......@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chromecast/media/cma/base/decoder_buffer_base.h"
#include "jni/AudioSinkAudioTrackImpl_jni.h"
#include "media/base/audio_bus.h"
......@@ -284,12 +285,10 @@ void AudioSinkAndroidAudioTrackImpl::ReformatData() {
void AudioSinkAndroidAudioTrackImpl::TrackRawMonotonicClockDeviation() {
timespec now = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &now);
int64_t now_usec =
static_cast<int64_t>(now.tv_sec) * 1000000 + now.tv_nsec / 1000;
int64_t now_usec = base::TimeDelta::FromTimeSpec(now).InMicroseconds();
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
int64_t now_raw_usec =
static_cast<int64_t>(now.tv_sec) * 1000000 + now.tv_nsec / 1000;
int64_t now_raw_usec = base::TimeDelta::FromTimeSpec(now).InMicroseconds();
// TODO(ckuiper): Eventually we want to use this to convert from non-RAW to
// RAW timestamps to improve accuracy.
......
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chromecast/base/task_runner_impl.h"
#include "chromecast/media/cma/backend/audio_decoder_for_mixer.h"
......@@ -235,7 +236,7 @@ int64_t MediaPipelineBackendForMixer::MonotonicClockNow() const {
#else
clock_gettime(CLOCK_MONOTONIC, &now);
#endif // MEDIA_CLOCK_MONOTONIC_RAW
return static_cast<int64_t>(now.tv_sec) * 1000000 + now.tv_nsec / 1000;
return base::TimeDelta::FromTimeSpec(now).InMicroseconds();
}
#elif defined(OS_FUCHSIA)
int64_t MediaPipelineBackendForMixer::MonotonicClockNow() const {
......
......@@ -78,8 +78,7 @@ bool SyncControlVSyncProvider::GetVSyncParametersIfAvailable(
base::TimeTicks::Clock::LINUX_CLOCK_MONOTONIC);
int64_t real_time_in_microseconds =
real_time.tv_sec * base::Time::kMicrosecondsPerSecond +
real_time.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
base::TimeDelta::FromTimeSpec(real_time).InMicroseconds();
int64_t monotonic_time_in_microseconds =
monotonic_time.since_origin().InMicroseconds();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment