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

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

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android Created 4 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
« no previous file with comments | « media/base/audio_shifter.h ('k') | media/base/audio_shifter_unittest.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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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_shifter.h" 5 #include "media/base/audio_shifter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 private: 70 private:
71 base::TimeDelta clock_accuracy_; 71 base::TimeDelta clock_accuracy_;
72 std::deque<std::pair<base::TimeDelta, base::TimeDelta> > inaccuracies_; 72 std::deque<std::pair<base::TimeDelta, base::TimeDelta> > inaccuracies_;
73 base::TimeDelta inaccuracy_sum_; 73 base::TimeDelta inaccuracy_sum_;
74 base::TimeDelta inaccuracy_delta_; 74 base::TimeDelta inaccuracy_delta_;
75 base::TimeTicks previous_; 75 base::TimeTicks previous_;
76 }; 76 };
77 77
78 AudioShifter::AudioQueueEntry::AudioQueueEntry( 78 AudioShifter::AudioQueueEntry::AudioQueueEntry(
79 base::TimeTicks target_playout_time_, 79 base::TimeTicks target_playout_time_,
80 scoped_ptr<AudioBus> audio_) : 80 std::unique_ptr<AudioBus> audio_)
81 target_playout_time(target_playout_time_), 81 : target_playout_time(target_playout_time_), audio(audio_.release()) {}
82 audio(audio_.release()) {
83 }
84 82
85 AudioShifter::AudioQueueEntry::AudioQueueEntry(const AudioQueueEntry& other) = 83 AudioShifter::AudioQueueEntry::AudioQueueEntry(const AudioQueueEntry& other) =
86 default; 84 default;
87 85
88 AudioShifter::AudioQueueEntry::~AudioQueueEntry() {} 86 AudioShifter::AudioQueueEntry::~AudioQueueEntry() {}
89 87
90 AudioShifter::AudioShifter(base::TimeDelta max_buffer_size, 88 AudioShifter::AudioShifter(base::TimeDelta max_buffer_size,
91 base::TimeDelta clock_accuracy, 89 base::TimeDelta clock_accuracy,
92 base::TimeDelta adjustment_time, 90 base::TimeDelta adjustment_time,
93 int rate, 91 int rate,
(...skipping 10 matching lines...) Expand all
104 previous_requested_samples_(0), 102 previous_requested_samples_(0),
105 resampler_( 103 resampler_(
106 channels, 104 channels,
107 1.0, 105 1.0,
108 96, 106 96,
109 base::Bind(&AudioShifter::ResamplerCallback, base::Unretained(this))), 107 base::Bind(&AudioShifter::ResamplerCallback, base::Unretained(this))),
110 current_ratio_(1.0) {} 108 current_ratio_(1.0) {}
111 109
112 AudioShifter::~AudioShifter() {} 110 AudioShifter::~AudioShifter() {}
113 111
114 void AudioShifter::Push(scoped_ptr<AudioBus> input, 112 void AudioShifter::Push(std::unique_ptr<AudioBus> input,
115 base::TimeTicks playout_time) { 113 base::TimeTicks playout_time) {
116 if (!queue_.empty()) { 114 if (!queue_.empty()) {
117 playout_time = input_clock_smoother_->Smooth( 115 playout_time = input_clock_smoother_->Smooth(
118 playout_time, 116 playout_time,
119 base::TimeDelta::FromSeconds(queue_.back().audio->frames()) / rate_); 117 base::TimeDelta::FromSeconds(queue_.back().audio->frames()) / rate_);
120 } 118 }
121 queue_.push_back(AudioQueueEntry(playout_time, std::move(input))); 119 queue_.push_back(AudioQueueEntry(playout_time, std::move(input)));
122 while (!queue_.empty() && 120 while (!queue_.empty() &&
123 queue_.back().target_playout_time - 121 queue_.back().target_playout_time -
124 queue_.front().target_playout_time > max_buffer_size_) { 122 queue_.front().target_playout_time > max_buffer_size_) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 274 }
277 275
278 void AudioShifter::Zero(AudioBus* output) { 276 void AudioShifter::Zero(AudioBus* output) {
279 output->Zero(); 277 output->Zero();
280 running_ = false; 278 running_ = false;
281 previous_playout_time_ = base::TimeTicks(); 279 previous_playout_time_ = base::TimeTicks();
282 bias_ = base::TimeDelta(); 280 bias_ = base::TimeDelta();
283 } 281 }
284 282
285 } // namespace media 283 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_shifter.h ('k') | media/base/audio_shifter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698