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

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

Issue 156783003: Enhance AudioSplicer to crossfade marked splice frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve comments. Created 6 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 | Annotate | Revision Log
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 "media/base/audio_timestamp_helper.h" 5 #include "media/base/audio_timestamp_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 AudioTimestampHelper::AudioTimestampHelper(int samples_per_second) 12 AudioTimestampHelper::AudioTimestampHelper(int samples_per_second)
13 : base_timestamp_(kNoTimestamp()), 13 : base_timestamp_(kNoTimestamp()),
14 frame_count_(0) { 14 frame_count_(0) {
15 DCHECK_GT(samples_per_second, 0); 15 DCHECK_GT(samples_per_second, 0);
16 double fps = samples_per_second; 16 double fps = samples_per_second;
17 microseconds_per_frame_ = base::Time::kMicrosecondsPerSecond / fps; 17 microseconds_per_frame_ = base::Time::kMicrosecondsPerSecond / fps;
18 } 18 }
19 19
20 void AudioTimestampHelper::SetBaseTimestamp(base::TimeDelta base_timestamp) { 20 void AudioTimestampHelper::SetBaseTimestamp(base::TimeDelta base_timestamp) {
21 base_timestamp_ = base_timestamp; 21 base_timestamp_ = base_timestamp;
22 frame_count_ = 0; 22 frame_count_ = 0;
23 } 23 }
24 24
25 base::TimeDelta AudioTimestampHelper::base_timestamp() const {
26 return base_timestamp_;
27 }
28
29 void AudioTimestampHelper::AddFrames(int frame_count) { 25 void AudioTimestampHelper::AddFrames(int frame_count) {
30 DCHECK_GE(frame_count, 0); 26 DCHECK_GE(frame_count, 0);
31 DCHECK(base_timestamp_ != kNoTimestamp()); 27 DCHECK(base_timestamp_ != kNoTimestamp());
32 frame_count_ += frame_count; 28 frame_count_ += frame_count;
33 } 29 }
34 30
35 base::TimeDelta AudioTimestampHelper::GetTimestamp() const { 31 base::TimeDelta AudioTimestampHelper::GetTimestamp() const {
36 return ComputeTimestamp(frame_count_); 32 return ComputeTimestamp(frame_count_);
37 } 33 }
38 34
(...skipping 27 matching lines...) Expand all
66 62
67 base::TimeDelta AudioTimestampHelper::ComputeTimestamp( 63 base::TimeDelta AudioTimestampHelper::ComputeTimestamp(
68 int64 frame_count) const { 64 int64 frame_count) const {
69 DCHECK_GE(frame_count, 0); 65 DCHECK_GE(frame_count, 0);
70 DCHECK(base_timestamp_ != kNoTimestamp()); 66 DCHECK(base_timestamp_ != kNoTimestamp());
71 double frames_us = microseconds_per_frame_ * frame_count; 67 double frames_us = microseconds_per_frame_ * frame_count;
72 return base_timestamp_ + base::TimeDelta::FromMicroseconds(frames_us); 68 return base_timestamp_ + base::TimeDelta::FromMicroseconds(frames_us);
73 } 69 }
74 70
75 } // namespace media 71 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698