OLD | NEW |
---|---|
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 "webkit/media/webmediaplayer_util.h" | 5 #include "webkit/media/webmediaplayer_util.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 namespace webkit_media { | 9 namespace webkit_media { |
10 | 10 |
11 base::TimeDelta ConvertSecondsToTimestamp(float seconds) { | 11 base::TimeDelta ConvertSecondsToTimestamp(double seconds) { |
DaleCurtis
2013/04/16 01:19:48
This is a lot simpler written as:
const double mi
acolwell GONE FROM CHROMIUM
2013/04/16 16:58:15
Done.
| |
12 float microseconds = seconds * base::Time::kMicrosecondsPerSecond; | 12 double microseconds = seconds * base::Time::kMicrosecondsPerSecond; |
13 float integer = ceilf(microseconds); | 13 double integer = ceil(microseconds); |
14 float difference = integer - microseconds; | 14 double difference = integer - microseconds; |
15 | 15 |
16 // Round down if difference is large enough. | 16 // Round down if difference is large enough. |
17 if ((microseconds > 0 && difference > 0.5f) || | 17 if ((microseconds > 0 && difference > 0.5) || |
18 (microseconds <= 0 && difference >= 0.5f)) { | 18 (microseconds <= 0 && difference >= 0.5)) { |
19 integer -= 1.0f; | 19 integer -= 1.0; |
20 } | 20 } |
21 | 21 |
22 // Now we can safely cast to int64 microseconds. | 22 // Now we can safely cast to int64 microseconds. |
23 return base::TimeDelta::FromMicroseconds(static_cast<int64>(integer)); | 23 return base::TimeDelta::FromMicroseconds(static_cast<int64>(integer)); |
24 } | 24 } |
25 | 25 |
26 } // namespace webkit_media | 26 } // namespace webkit_media |
OLD | NEW |