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

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

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, 7 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_renderer_mixer_unittest.cc ('k') | media/base/audio_shifter.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 #ifndef MEDIA_BASE_AUDIO_SHIFTER_H 5 #ifndef MEDIA_BASE_AUDIO_SHIFTER_H
6 #define MEDIA_BASE_AUDIO_SHIFTER_H 6 #define MEDIA_BASE_AUDIO_SHIFTER_H
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <memory>
11 12
12 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
16 #include "media/base/multi_channel_resampler.h" 16 #include "media/base/multi_channel_resampler.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 class AudioBus; 20 class AudioBus;
21 class ClockSmoother; 21 class ClockSmoother;
22 22
23 // This class works like a buffer between a push based audio source 23 // This class works like a buffer between a push based audio source
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // channels, but bus size can vary. The playout time can be noisy and 67 // channels, but bus size can vary. The playout time can be noisy and
68 // does not have to line up perfectly with the number of samples pushed 68 // does not have to line up perfectly with the number of samples pushed
69 // so far. However, the playout_time in Push calls and Pull calls must 69 // so far. However, the playout_time in Push calls and Pull calls must
70 // not diverge over time. 70 // not diverge over time.
71 // Given audio from an a microphone, a reasonable way to calculate 71 // Given audio from an a microphone, a reasonable way to calculate
72 // playout_time would be now + 30ms. 72 // playout_time would be now + 30ms.
73 // Ideally playout_time is some time in the future, in which case 73 // Ideally playout_time is some time in the future, in which case
74 // the samples will be buffered until the approperiate time. If 74 // the samples will be buffered until the approperiate time. If
75 // playout_time is in the past, everything will still work, and we'll 75 // playout_time is in the past, everything will still work, and we'll
76 // try to keep the buffring to a minimum. 76 // try to keep the buffring to a minimum.
77 void Push(scoped_ptr<AudioBus> input, base::TimeTicks playout_time); 77 void Push(std::unique_ptr<AudioBus> input, base::TimeTicks playout_time);
78 78
79 // Fills out |output| with samples. Tries to stretch/shrink the audio 79 // Fills out |output| with samples. Tries to stretch/shrink the audio
80 // to compensate for drift between input and output. 80 // to compensate for drift between input and output.
81 // If called from an output device data pull, a reasonable way to 81 // If called from an output device data pull, a reasonable way to
82 // calculate playout_time would be now + audio pipeline delay. 82 // calculate playout_time would be now + audio pipeline delay.
83 void Pull(AudioBus* output, base::TimeTicks playout_time); 83 void Pull(AudioBus* output, base::TimeTicks playout_time);
84 84
85 private: 85 private:
86 void Zero(AudioBus* output); 86 void Zero(AudioBus* output);
87 void ResamplerCallback(int frame_delay, AudioBus* destination); 87 void ResamplerCallback(int frame_delay, AudioBus* destination);
88 88
89 struct AudioQueueEntry { 89 struct AudioQueueEntry {
90 AudioQueueEntry(base::TimeTicks target_playout_time_, 90 AudioQueueEntry(base::TimeTicks target_playout_time_,
91 scoped_ptr<AudioBus> audio_); 91 std::unique_ptr<AudioBus> audio_);
92 AudioQueueEntry(const AudioQueueEntry& other); 92 AudioQueueEntry(const AudioQueueEntry& other);
93 ~AudioQueueEntry(); 93 ~AudioQueueEntry();
94 base::TimeTicks target_playout_time; 94 base::TimeTicks target_playout_time;
95 linked_ptr<AudioBus> audio; 95 linked_ptr<AudioBus> audio;
96 }; 96 };
97 97
98 typedef std::deque<AudioQueueEntry> AudioShifterQueue; 98 typedef std::deque<AudioQueueEntry> AudioShifterQueue;
99 99
100 // Set from constructor. 100 // Set from constructor.
101 const base::TimeDelta max_buffer_size_; 101 const base::TimeDelta max_buffer_size_;
102 const base::TimeDelta clock_accuracy_; 102 const base::TimeDelta clock_accuracy_;
103 const base::TimeDelta adjustment_time_; 103 const base::TimeDelta adjustment_time_;
104 const int rate_; 104 const int rate_;
105 const int channels_; 105 const int channels_;
106 106
107 // The clock smoothers are used to smooth out timestamps 107 // The clock smoothers are used to smooth out timestamps
108 // and adjust for drift and inaccurate clocks. 108 // and adjust for drift and inaccurate clocks.
109 scoped_ptr<ClockSmoother> input_clock_smoother_; 109 std::unique_ptr<ClockSmoother> input_clock_smoother_;
110 scoped_ptr<ClockSmoother> output_clock_smoother_; 110 std::unique_ptr<ClockSmoother> output_clock_smoother_;
111 111
112 // Are we currently outputting data? 112 // Are we currently outputting data?
113 bool running_; 113 bool running_;
114 114
115 // Number of frames already consumed from |queue_|. 115 // Number of frames already consumed from |queue_|.
116 size_t position_; 116 size_t position_;
117 117
118 // Queue of data provided to us. 118 // Queue of data provided to us.
119 AudioShifterQueue queue_; 119 AudioShifterQueue queue_;
120 120
(...skipping 13 matching lines...) Expand all
134 // Resampler. 134 // Resampler.
135 MultiChannelResampler resampler_; 135 MultiChannelResampler resampler_;
136 136
137 // Current resampler ratio. 137 // Current resampler ratio.
138 double current_ratio_; 138 double current_ratio_;
139 }; 139 };
140 140
141 } // namespace media 141 } // namespace media
142 142
143 #endif // MEDIA_BASE_AUDIO_SHIFTER_H 143 #endif // MEDIA_BASE_AUDIO_SHIFTER_H
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer_unittest.cc ('k') | media/base/audio_shifter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698