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

Side by Side Diff: webkit/media/webmediaplayer_util.cc

Issue 13866046: Change original WebMediaPlayer signatures from float to double. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « webkit/media/webmediaplayer_util.h ('k') | webkit/media/webmediasourceclient_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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) {
12 float microseconds = seconds * base::Time::kMicrosecondsPerSecond; 12 double microseconds = seconds * base::Time::kMicrosecondsPerSecond;
13 float integer = ceilf(microseconds); 13 return base::TimeDelta::FromMicroseconds(
14 float difference = integer - microseconds; 14 microseconds > 0 ? microseconds + 0.5 : ceil(microseconds - 0.5));
15
16 // Round down if difference is large enough.
17 if ((microseconds > 0 && difference > 0.5f) ||
18 (microseconds <= 0 && difference >= 0.5f)) {
19 integer -= 1.0f;
20 }
21
22 // Now we can safely cast to int64 microseconds.
23 return base::TimeDelta::FromMicroseconds(static_cast<int64>(integer));
24 } 15 }
25 16
26 } // namespace webkit_media 17 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/webmediaplayer_util.h ('k') | webkit/media/webmediasourceclient_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698