OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/audio_coding/neteq/audio_vector.h" | 11 #include "webrtc/modules/audio_coding/neteq/audio_vector.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
| 16 #include <memory> |
16 | 17 |
17 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 AudioVector::AudioVector() | 22 AudioVector::AudioVector() |
22 : array_(new int16_t[kDefaultInitialSize]), | 23 : array_(new int16_t[kDefaultInitialSize]), |
23 first_free_ix_(0), | 24 first_free_ix_(0), |
24 capacity_(kDefaultInitialSize) { | 25 capacity_(kDefaultInitialSize) { |
25 } | 26 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 const int16_t& AudioVector::operator[](size_t index) const { | 174 const int16_t& AudioVector::operator[](size_t index) const { |
174 return array_[index]; | 175 return array_[index]; |
175 } | 176 } |
176 | 177 |
177 int16_t& AudioVector::operator[](size_t index) { | 178 int16_t& AudioVector::operator[](size_t index) { |
178 return array_[index]; | 179 return array_[index]; |
179 } | 180 } |
180 | 181 |
181 void AudioVector::Reserve(size_t n) { | 182 void AudioVector::Reserve(size_t n) { |
182 if (capacity_ < n) { | 183 if (capacity_ < n) { |
183 rtc::scoped_ptr<int16_t[]> temp_array(new int16_t[n]); | 184 std::unique_ptr<int16_t[]> temp_array(new int16_t[n]); |
184 memcpy(temp_array.get(), array_.get(), Size() * sizeof(int16_t)); | 185 memcpy(temp_array.get(), array_.get(), Size() * sizeof(int16_t)); |
185 array_.swap(temp_array); | 186 array_.swap(temp_array); |
186 capacity_ = n; | 187 capacity_ = n; |
187 } | 188 } |
188 } | 189 } |
189 | 190 |
190 } // namespace webrtc | 191 } // namespace webrtc |
OLD | NEW |