Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: base/time/time_posix.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Changes based on comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/time/time.h" 5 #include "base/time/time.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <sys/time.h> 8 #include <sys/time.h>
9 #include <time.h> 9 #include <time.h>
10 #if defined(OS_ANDROID) && !defined(__LP64__) 10 #if defined(OS_ANDROID) && !defined(__LP64__)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 #else // _POSIX_MONOTONIC_CLOCK 104 #else // _POSIX_MONOTONIC_CLOCK
105 #error No usable tick clock function on this platform. 105 #error No usable tick clock function on this platform.
106 #endif // _POSIX_MONOTONIC_CLOCK 106 #endif // _POSIX_MONOTONIC_CLOCK
107 #endif // !defined(OS_MACOSX) 107 #endif // !defined(OS_MACOSX)
108 108
109 } // namespace 109 } // namespace
110 110
111 namespace base { 111 namespace base {
112 112
113 // static
114 TimeDelta TimeDelta::FromTimeSpec(const timespec& ts) {
115 return TimeDelta(ts.tv_sec * Time::kMicrosecondsPerSecond +
116 ts.tv_nsec / Time::kNanosecondsPerMicrosecond);
117 }
118
113 struct timespec TimeDelta::ToTimeSpec() const { 119 struct timespec TimeDelta::ToTimeSpec() const {
114 int64_t microseconds = InMicroseconds(); 120 int64_t microseconds = InMicroseconds();
115 time_t seconds = 0; 121 time_t seconds = 0;
116 if (microseconds >= Time::kMicrosecondsPerSecond) { 122 if (microseconds >= Time::kMicrosecondsPerSecond) {
117 seconds = InSeconds(); 123 seconds = InSeconds();
118 microseconds -= seconds * Time::kMicrosecondsPerSecond; 124 microseconds -= seconds * Time::kMicrosecondsPerSecond;
119 } 125 }
120 struct timespec result = 126 struct timespec result =
121 {seconds, 127 {seconds,
122 static_cast<long>(microseconds * Time::kNanosecondsPerMicrosecond)}; 128 static_cast<long>(microseconds * Time::kNanosecondsPerMicrosecond)};
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; 388 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
383 return result; 389 return result;
384 } 390 }
385 int64_t us = us_ - kTimeTToMicrosecondsOffset; 391 int64_t us = us_ - kTimeTToMicrosecondsOffset;
386 result.tv_sec = us / Time::kMicrosecondsPerSecond; 392 result.tv_sec = us / Time::kMicrosecondsPerSecond;
387 result.tv_usec = us % Time::kMicrosecondsPerSecond; 393 result.tv_usec = us % Time::kMicrosecondsPerSecond;
388 return result; 394 return result;
389 } 395 }
390 396
391 } // namespace base 397 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698