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

Side by Side Diff: media/base/audio_bus.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, 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_bus.h ('k') | media/base/audio_bus_perftest.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 "media/base/audio_bus.h" 5 #include "media/base/audio_bus.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/numerics/safe_conversions.h" 14 #include "base/numerics/safe_conversions.h"
14 #include "media/base/audio_parameters.h" 15 #include "media/base/audio_parameters.h"
15 #include "media/base/limits.h" 16 #include "media/base/limits.h"
16 #include "media/base/vector_math.h" 17 #include "media/base/vector_math.h"
17 18
18 namespace media { 19 namespace media {
19 20
20 static const uint8_t kUint8Bias = 128; 21 static const uint8_t kUint8Bias = 128;
21 22
22 static bool IsAligned(void* ptr) { 23 static bool IsAligned(void* ptr) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 : channel_data_(channels), 147 : channel_data_(channels),
147 frames_(0), 148 frames_(0),
148 can_set_channel_data_(true) { 149 can_set_channel_data_(true) {
149 CHECK_GT(channels, 0); 150 CHECK_GT(channels, 0);
150 for (size_t i = 0; i < channel_data_.size(); ++i) 151 for (size_t i = 0; i < channel_data_.size(); ++i)
151 channel_data_[i] = NULL; 152 channel_data_[i] = NULL;
152 } 153 }
153 154
154 AudioBus::~AudioBus() {} 155 AudioBus::~AudioBus() {}
155 156
156 scoped_ptr<AudioBus> AudioBus::Create(int channels, int frames) { 157 std::unique_ptr<AudioBus> AudioBus::Create(int channels, int frames) {
157 return scoped_ptr<AudioBus>(new AudioBus(channels, frames)); 158 return base::WrapUnique(new AudioBus(channels, frames));
158 } 159 }
159 160
160 scoped_ptr<AudioBus> AudioBus::Create(const AudioParameters& params) { 161 std::unique_ptr<AudioBus> AudioBus::Create(const AudioParameters& params) {
161 return scoped_ptr<AudioBus>(new AudioBus( 162 return base::WrapUnique(
162 params.channels(), params.frames_per_buffer())); 163 new AudioBus(params.channels(), params.frames_per_buffer()));
163 } 164 }
164 165
165 scoped_ptr<AudioBus> AudioBus::CreateWrapper(int channels) { 166 std::unique_ptr<AudioBus> AudioBus::CreateWrapper(int channels) {
166 return scoped_ptr<AudioBus>(new AudioBus(channels)); 167 return base::WrapUnique(new AudioBus(channels));
167 } 168 }
168 169
169 scoped_ptr<AudioBus> AudioBus::WrapVector( 170 std::unique_ptr<AudioBus> AudioBus::WrapVector(
170 int frames, const std::vector<float*>& channel_data) { 171 int frames,
171 return scoped_ptr<AudioBus>(new AudioBus(frames, channel_data)); 172 const std::vector<float*>& channel_data) {
173 return base::WrapUnique(new AudioBus(frames, channel_data));
172 } 174 }
173 175
174 scoped_ptr<AudioBus> AudioBus::WrapMemory(int channels, int frames, 176 std::unique_ptr<AudioBus> AudioBus::WrapMemory(int channels,
175 void* data) { 177 int frames,
178 void* data) {
176 // |data| must be aligned by AudioBus::kChannelAlignment. 179 // |data| must be aligned by AudioBus::kChannelAlignment.
177 CHECK(IsAligned(data)); 180 CHECK(IsAligned(data));
178 return scoped_ptr<AudioBus>(new AudioBus( 181 return base::WrapUnique(
179 channels, frames, static_cast<float*>(data))); 182 new AudioBus(channels, frames, static_cast<float*>(data)));
180 } 183 }
181 184
182 scoped_ptr<AudioBus> AudioBus::WrapMemory(const AudioParameters& params, 185 std::unique_ptr<AudioBus> AudioBus::WrapMemory(const AudioParameters& params,
183 void* data) { 186 void* data) {
184 // |data| must be aligned by AudioBus::kChannelAlignment. 187 // |data| must be aligned by AudioBus::kChannelAlignment.
185 CHECK(IsAligned(data)); 188 CHECK(IsAligned(data));
186 return scoped_ptr<AudioBus>(new AudioBus( 189 return base::WrapUnique(new AudioBus(params.channels(),
187 params.channels(), params.frames_per_buffer(), 190 params.frames_per_buffer(),
188 static_cast<float*>(data))); 191 static_cast<float*>(data)));
189 } 192 }
190 193
191 void AudioBus::SetChannelData(int channel, float* data) { 194 void AudioBus::SetChannelData(int channel, float* data) {
192 CHECK(can_set_channel_data_); 195 CHECK(can_set_channel_data_);
193 CHECK(data); 196 CHECK(data);
194 CHECK_GE(channel, 0); 197 CHECK_GE(channel, 0);
195 CHECK_LT(static_cast<size_t>(channel), channel_data_.size()); 198 CHECK_LT(static_cast<size_t>(channel), channel_data_.size());
196 DCHECK(IsAligned(data)); 199 DCHECK(IsAligned(data));
197 channel_data_[channel] = data; 200 channel_data_[channel] = data;
198 } 201 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return scoped_refptr<AudioBusRefCounted>( 369 return scoped_refptr<AudioBusRefCounted>(
367 new AudioBusRefCounted(channels, frames)); 370 new AudioBusRefCounted(channels, frames));
368 } 371 }
369 372
370 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames) 373 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames)
371 : AudioBus(channels, frames) {} 374 : AudioBus(channels, frames) {}
372 375
373 AudioBusRefCounted::~AudioBusRefCounted() {} 376 AudioBusRefCounted::~AudioBusRefCounted() {}
374 377
375 } // namespace media 378 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_bus.h ('k') | media/base/audio_bus_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698