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

Side by Side Diff: media/base/synchronizer.cc

Issue 19739: Changed media::Buffer interfaces to use base::TimeDelta. (Closed)
Patch Set: Created 11 years, 10 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
« no previous file with comments | « media/base/data_buffer_unittest.cc ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/logging.h" 5 #include "base/logging.h"
6 #include "media/base/synchronizer.h" 6 #include "media/base/synchronizer.h"
7 7
8 namespace media { 8 namespace media {
9 9
10 const int64 Synchronizer::kMinFrameDelayUs = 0; 10 const int64 Synchronizer::kMinFrameDelayUs = 0;
(...skipping 15 matching lines...) Expand all
26 26
27 void Synchronizer::CalculateDelay(base::TimeDelta time, 27 void Synchronizer::CalculateDelay(base::TimeDelta time,
28 const StreamSample* now, 28 const StreamSample* now,
29 const StreamSample* next, 29 const StreamSample* next,
30 base::TimeDelta* delay_out, 30 base::TimeDelta* delay_out,
31 bool* should_skip_out) { 31 bool* should_skip_out) {
32 // How long rendering took. 32 // How long rendering took.
33 base::TimeDelta render_delta = rendering_stop_ - rendering_start_; 33 base::TimeDelta render_delta = rendering_stop_ - rendering_start_;
34 34
35 // The duration to display the sample |now|. 35 // The duration to display the sample |now|.
36 base::TimeDelta duration = 36 base::TimeDelta duration = now->GetDuration();
37 base::TimeDelta::FromMicroseconds(now->GetDuration());
38 37
39 // The presentation timestamp (pts) of the sample |now|. 38 // The presentation timestamp (pts) of the sample |now|.
40 base::TimeDelta now_pts = 39 base::TimeDelta now_pts = now->GetTimestamp();
41 base::TimeDelta::FromMicroseconds(now->GetTimestamp());
42 40
43 // The presentation timestamp (pts) of the next sample. 41 // The presentation timestamp (pts) of the next sample.
44 base::TimeDelta next_pts; 42 base::TimeDelta next_pts;
45 43
46 // If we were provided the next sample in the stream |next|, use it to 44 // If we were provided the next sample in the stream |next|, use it to
47 // calculate the actual sample duration as opposed to the expected duration 45 // calculate the actual sample duration as opposed to the expected duration
48 // provided by the current sample |now|. 46 // provided by the current sample |now|.
49 // 47 //
50 // We also use |next| to get the exact next timestamp as opposed to assuming 48 // We also use |next| to get the exact next timestamp as opposed to assuming
51 // it will be |now| + |now|'s duration, which may not always be true. 49 // it will be |now| + |now|'s duration, which may not always be true.
52 if (next) { 50 if (next) {
53 next_pts = base::TimeDelta::FromMicroseconds(next->GetTimestamp()); 51 next_pts = next->GetTimestamp();
54 duration = next_pts - now_pts; 52 duration = next_pts - now_pts;
55 53
56 // Timestamps appear out of order, so skip this frame. 54 // Timestamps appear out of order, so skip this frame.
57 if (duration.InMicroseconds() < 0) { 55 if (duration.InMicroseconds() < 0) {
58 *delay_out = base::TimeDelta(); 56 *delay_out = base::TimeDelta();
59 *should_skip_out = true; 57 *should_skip_out = true;
60 return; 58 return;
61 } 59 }
62 } else { 60 } else {
63 // Assume next presentation timestamp is |now| + |now|'s duration. 61 // Assume next presentation timestamp is |now| + |now|'s duration.
(...skipping 20 matching lines...) Expand all
84 sleep = base::TimeDelta::FromMicroseconds(kMaxFrameDelayUs); 82 sleep = base::TimeDelta::FromMicroseconds(kMaxFrameDelayUs);
85 } 83 }
86 } 84 }
87 last_time_ = time; 85 last_time_ = time;
88 86
89 *delay_out = sleep; 87 *delay_out = sleep;
90 *should_skip_out = false; 88 *should_skip_out = false;
91 } 89 }
92 90
93 } // namespace media 91 } // namespace media
OLDNEW
« no previous file with comments | « media/base/data_buffer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698