Revert of Replace scoped_ptr with unique_ptr in webrtc/common_audio/ (patchset #4 id:60001 of https://codereview.webrtc.org/1712513002/ ) Reason for revert: Breaks downstream compilation using webrtc/common_audio/real_fourier.h. Let's chat tomorrow on how to coordinate a re-land. Original issue's description: > Replace scoped_ptr with unique_ptr in webrtc/common_audio/ > > BUG=webrtc:5520 > > Committed: https://crrev.com/79d7a499c0c3e1de8f5ad1138236f0386701053f > Cr-Commit-Position: refs/heads/master@{#11716} TBR=henrik.lundin@webrtc.org,kwiberg@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5520 Review URL: https://codereview.webrtc.org/1726043002 Cr-Commit-Position: refs/heads/master@{#11726}
diff --git a/webrtc/common_audio/audio_converter.cc b/webrtc/common_audio/audio_converter.cc index d6334b3..9ebfabc 100644 --- a/webrtc/common_audio/audio_converter.cc +++ b/webrtc/common_audio/audio_converter.cc
@@ -136,11 +136,11 @@ ScopedVector<ChannelBuffer<float>> buffers_; }; -std::unique_ptr<AudioConverter> AudioConverter::Create(size_t src_channels, +rtc::scoped_ptr<AudioConverter> AudioConverter::Create(size_t src_channels, size_t src_frames, size_t dst_channels, size_t dst_frames) { - std::unique_ptr<AudioConverter> sp; + rtc::scoped_ptr<AudioConverter> sp; if (src_channels > dst_channels) { if (src_frames != dst_frames) { ScopedVector<AudioConverter> converters;
diff --git a/webrtc/common_audio/audio_converter.h b/webrtc/common_audio/audio_converter.h index 01dad4d..c5f08c1 100644 --- a/webrtc/common_audio/audio_converter.h +++ b/webrtc/common_audio/audio_converter.h
@@ -11,9 +11,8 @@ #ifndef WEBRTC_COMMON_AUDIO_AUDIO_CONVERTER_H_ #define WEBRTC_COMMON_AUDIO_AUDIO_CONVERTER_H_ -#include <memory> - #include "webrtc/base/constructormagic.h" +#include "webrtc/base/scoped_ptr.h" namespace webrtc { @@ -27,7 +26,7 @@ public: // Returns a new AudioConverter, which will use the supplied format for its // lifetime. Caller is responsible for the memory. - static std::unique_ptr<AudioConverter> Create(size_t src_channels, + static rtc::scoped_ptr<AudioConverter> Create(size_t src_channels, size_t src_frames, size_t dst_channels, size_t dst_frames);
diff --git a/webrtc/common_audio/audio_converter_unittest.cc b/webrtc/common_audio/audio_converter_unittest.cc index f86e37b..dace0bd 100644 --- a/webrtc/common_audio/audio_converter_unittest.cc +++ b/webrtc/common_audio/audio_converter_unittest.cc
@@ -10,19 +10,19 @@ #include <cmath> #include <algorithm> -#include <memory> #include <vector> #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/arraysize.h" #include "webrtc/base/format_macros.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/audio_converter.h" #include "webrtc/common_audio/channel_buffer.h" #include "webrtc/common_audio/resampler/push_sinc_resampler.h" namespace webrtc { -typedef std::unique_ptr<ChannelBuffer<float>> ScopedBuffer; +typedef rtc::scoped_ptr<ChannelBuffer<float>> ScopedBuffer; // Sets the signal value to increase by |data| with every sample. ScopedBuffer CreateBuffer(const std::vector<float>& data, size_t frames) { @@ -132,7 +132,7 @@ printf("(%" PRIuS ", %d Hz) -> (%" PRIuS ", %d Hz) ", src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz); - std::unique_ptr<AudioConverter> converter = AudioConverter::Create( + rtc::scoped_ptr<AudioConverter> converter = AudioConverter::Create( src_channels, src_frames, dst_channels, dst_frames); converter->Convert(src_buffer->channels(), src_buffer->size(), dst_buffer->channels(), dst_buffer->size());
diff --git a/webrtc/common_audio/audio_ring_buffer.h b/webrtc/common_audio/audio_ring_buffer.h index e73f55b..58e543a 100644 --- a/webrtc/common_audio/audio_ring_buffer.h +++ b/webrtc/common_audio/audio_ring_buffer.h
@@ -47,7 +47,7 @@ private: // We don't use a ScopedVector because it doesn't support a specialized - // deleter (like unique_ptr for instance.) + // deleter (like scoped_ptr for instance.) std::vector<RingBuffer*> buffers_; };
diff --git a/webrtc/common_audio/audio_ring_buffer_unittest.cc b/webrtc/common_audio/audio_ring_buffer_unittest.cc index c5c38de..a7a6a94 100644 --- a/webrtc/common_audio/audio_ring_buffer_unittest.cc +++ b/webrtc/common_audio/audio_ring_buffer_unittest.cc
@@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include <memory> - #include "webrtc/common_audio/audio_ring_buffer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -29,7 +27,7 @@ const size_t num_channels = input.num_channels(); const size_t total_frames = input.num_frames(); AudioRingBuffer buf(num_channels, buffer_frames); - std::unique_ptr<float* []> slice(new float*[num_channels]); + rtc::scoped_ptr<float* []> slice(new float* [num_channels]); size_t input_pos = 0; size_t output_pos = 0;
diff --git a/webrtc/common_audio/blocker.h b/webrtc/common_audio/blocker.h index edf81d3..3a67c13 100644 --- a/webrtc/common_audio/blocker.h +++ b/webrtc/common_audio/blocker.h
@@ -11,8 +11,7 @@ #ifndef WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_ #define WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_ -#include <memory> - +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/audio_ring_buffer.h" #include "webrtc/common_audio/channel_buffer.h" @@ -110,7 +109,7 @@ // Space for the output block (can't wrap because of overlap/add). ChannelBuffer<float> output_block_; - std::unique_ptr<float[]> window_; + rtc::scoped_ptr<float[]> window_; // The amount of frames between the start of contiguous blocks. For example, // |shift_amount_| = |block_size_| / 2 for a Hann window.
diff --git a/webrtc/common_audio/blocker_unittest.cc b/webrtc/common_audio/blocker_unittest.cc index eea3e25..a5a7b56 100644 --- a/webrtc/common_audio/blocker_unittest.cc +++ b/webrtc/common_audio/blocker_unittest.cc
@@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include <memory> - #include "webrtc/common_audio/blocker.h" #include "testing/gtest/include/gtest/gtest.h" @@ -309,7 +307,7 @@ CopyBlockerCallback callback; for (size_t i = 0; i < arraysize(kChunkSize); ++i) { - std::unique_ptr<float[]> window(new float[kBlockSize[i]]); + rtc::scoped_ptr<float[]> window(new float[kBlockSize[i]]); for (size_t j = 0; j < kBlockSize[i]; ++j) { window[j] = 1.f; }
diff --git a/webrtc/common_audio/channel_buffer.cc b/webrtc/common_audio/channel_buffer.cc index 349d424..44520c6 100644 --- a/webrtc/common_audio/channel_buffer.cc +++ b/webrtc/common_audio/channel_buffer.cc
@@ -10,8 +10,6 @@ #include "webrtc/common_audio/channel_buffer.h" -#include "webrtc/base/checks.h" - namespace webrtc { IFChannelBuffer::IFChannelBuffer(size_t num_frames, @@ -46,7 +44,7 @@ void IFChannelBuffer::RefreshF() const { if (!fvalid_) { - RTC_DCHECK(ivalid_); + assert(ivalid_); const int16_t* const* int_channels = ibuf_.channels(); float* const* float_channels = fbuf_.channels(); for (size_t i = 0; i < ibuf_.num_channels(); ++i) { @@ -60,7 +58,7 @@ void IFChannelBuffer::RefreshI() const { if (!ivalid_) { - RTC_DCHECK(fvalid_); + assert(fvalid_); int16_t* const* int_channels = ibuf_.channels(); const float* const* float_channels = fbuf_.channels(); for (size_t i = 0; i < ibuf_.num_channels(); ++i) {
diff --git a/webrtc/common_audio/channel_buffer.h b/webrtc/common_audio/channel_buffer.h index faecec9..9f2fb96 100644 --- a/webrtc/common_audio/channel_buffer.h +++ b/webrtc/common_audio/channel_buffer.h
@@ -13,10 +13,9 @@ #include <string.h> -#include <memory> - #include "webrtc/base/checks.h" #include "webrtc/base/gtest_prod_util.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/include/audio_util.h" namespace webrtc { @@ -126,9 +125,9 @@ } private: - std::unique_ptr<T[]> data_; - std::unique_ptr<T* []> channels_; - std::unique_ptr<T* []> bands_; + rtc::scoped_ptr<T[]> data_; + rtc::scoped_ptr<T* []> channels_; + rtc::scoped_ptr<T* []> bands_; const size_t num_frames_; const size_t num_frames_per_band_; const size_t num_channels_;
diff --git a/webrtc/common_audio/fir_filter.cc b/webrtc/common_audio/fir_filter.cc index 13a2237..dc1b776 100644 --- a/webrtc/common_audio/fir_filter.cc +++ b/webrtc/common_audio/fir_filter.cc
@@ -13,8 +13,7 @@ #include <assert.h> #include <string.h> -#include <memory> - +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/fir_filter_neon.h" #include "webrtc/common_audio/fir_filter_sse.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" @@ -31,8 +30,8 @@ private: size_t coefficients_length_; size_t state_length_; - std::unique_ptr<float[]> coefficients_; - std::unique_ptr<float[]> state_; + rtc::scoped_ptr<float[]> coefficients_; + rtc::scoped_ptr<float[]> state_; }; FIRFilter* FIRFilter::Create(const float* coefficients,
diff --git a/webrtc/common_audio/fir_filter_neon.h b/webrtc/common_audio/fir_filter_neon.h index 5576856..3aa6168 100644 --- a/webrtc/common_audio/fir_filter_neon.h +++ b/webrtc/common_audio/fir_filter_neon.h
@@ -11,8 +11,7 @@ #ifndef WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_ #define WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_ -#include <memory> - +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/fir_filter.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" @@ -29,8 +28,8 @@ private: size_t coefficients_length_; size_t state_length_; - std::unique_ptr<float[], AlignedFreeDeleter> coefficients_; - std::unique_ptr<float[], AlignedFreeDeleter> state_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> coefficients_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> state_; }; } // namespace webrtc
diff --git a/webrtc/common_audio/fir_filter_sse.cc b/webrtc/common_audio/fir_filter_sse.cc index 89abb00..adbb2b7 100644 --- a/webrtc/common_audio/fir_filter_sse.cc +++ b/webrtc/common_audio/fir_filter_sse.cc
@@ -11,7 +11,6 @@ #include "webrtc/common_audio/fir_filter_sse.h" #include <assert.h> -#include <stdint.h> #include <string.h> #include <xmmintrin.h>
diff --git a/webrtc/common_audio/fir_filter_sse.h b/webrtc/common_audio/fir_filter_sse.h index 3b1e324..a3325cd 100644 --- a/webrtc/common_audio/fir_filter_sse.h +++ b/webrtc/common_audio/fir_filter_sse.h
@@ -11,8 +11,7 @@ #ifndef WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_ #define WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_ -#include <memory> - +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/fir_filter.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" @@ -29,8 +28,8 @@ private: size_t coefficients_length_; size_t state_length_; - std::unique_ptr<float[], AlignedFreeDeleter> coefficients_; - std::unique_ptr<float[], AlignedFreeDeleter> state_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> coefficients_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> state_; }; } // namespace webrtc
diff --git a/webrtc/common_audio/fir_filter_unittest.cc b/webrtc/common_audio/fir_filter_unittest.cc index 9dffcb6..13f79d9 100644 --- a/webrtc/common_audio/fir_filter_unittest.cc +++ b/webrtc/common_audio/fir_filter_unittest.cc
@@ -12,9 +12,8 @@ #include <string.h> -#include <memory> - #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/scoped_ptr.h" namespace webrtc { namespace { @@ -41,7 +40,7 @@ TEST(FIRFilterTest, FilterAsIdentity) { const float kCoefficients[] = {1.f, 0.f, 0.f, 0.f, 0.f}; float output[kInputLength]; - std::unique_ptr<FIRFilter> filter( + rtc::scoped_ptr<FIRFilter> filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -51,7 +50,7 @@ TEST(FIRFilterTest, FilterUsedAsScalarMultiplication) { const float kCoefficients[] = {5.f, 0.f, 0.f, 0.f, 0.f}; float output[kInputLength]; - std::unique_ptr<FIRFilter> filter( + rtc::scoped_ptr<FIRFilter> filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -64,7 +63,7 @@ TEST(FIRFilterTest, FilterUsedAsInputShifting) { const float kCoefficients[] = {0.f, 0.f, 0.f, 0.f, 1.f}; float output[kInputLength]; - std::unique_ptr<FIRFilter> filter( + rtc::scoped_ptr<FIRFilter> filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -77,7 +76,7 @@ TEST(FIRFilterTest, FilterUsedAsArbitraryWeighting) { float output[kInputLength]; - std::unique_ptr<FIRFilter> filter( + rtc::scoped_ptr<FIRFilter> filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -90,7 +89,7 @@ TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) { float output[kInputLength]; - std::unique_ptr<FIRFilter> filter( + rtc::scoped_ptr<FIRFilter> filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, 2)); filter->Filter(kInput, 2, output); @@ -107,7 +106,7 @@ TEST(FIRFilterTest, MultipleFilterCalls) { float output[kInputLength]; - std::unique_ptr<FIRFilter> filter( + rtc::scoped_ptr<FIRFilter> filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, 3)); filter->Filter(kInput, 2, output); EXPECT_FLOAT_EQ(0.2f, output[0]); @@ -138,7 +137,7 @@ TEST(FIRFilterTest, VerifySampleBasedVsBlockBasedFiltering) { float output_block_based[kInputLength]; - std::unique_ptr<FIRFilter> filter( + rtc::scoped_ptr<FIRFilter> filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output_block_based); @@ -163,7 +162,7 @@ sizeof(kConstantInput[0]); float output[kConstantInputLength]; - std::unique_ptr<FIRFilter> filter(FIRFilter::Create( + rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create( kCoefficients, kCoefficientsLength, kConstantInputLength)); filter->Filter(kConstantInput, kConstantInputLength, output); EXPECT_FLOAT_EQ(1.f, output[0]); @@ -182,7 +181,7 @@ sizeof(kHighFrequencyInput[0]); float output[kHighFrequencyInputLength]; - std::unique_ptr<FIRFilter> filter(FIRFilter::Create( + rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create( kCoefficients, kCoefficientsLength, kHighFrequencyInputLength)); filter->Filter(kHighFrequencyInput, kHighFrequencyInputLength, output); EXPECT_FLOAT_EQ(-1.f, output[0]); @@ -194,7 +193,7 @@ TEST(FIRFilterTest, SameOutputWhenSwapedCoefficientsAndInput) { float output[kCoefficientsLength]; float output_swaped[kCoefficientsLength]; - std::unique_ptr<FIRFilter> filter(FIRFilter::Create( + rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create( kCoefficients, kCoefficientsLength, kCoefficientsLength)); // Use kCoefficientsLength for in_length to get same-length outputs. filter->Filter(kInput, kCoefficientsLength, output);
diff --git a/webrtc/common_audio/include/audio_util.h b/webrtc/common_audio/include/audio_util.h index e5ad701..55dfc06 100644 --- a/webrtc/common_audio/include/audio_util.h +++ b/webrtc/common_audio/include/audio_util.h
@@ -15,6 +15,7 @@ #include <cstring> #include "webrtc/base/checks.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/typedefs.h" namespace webrtc {
diff --git a/webrtc/common_audio/lapped_transform.h b/webrtc/common_audio/lapped_transform.h index 8327359..1373ca1 100644 --- a/webrtc/common_audio/lapped_transform.h +++ b/webrtc/common_audio/lapped_transform.h
@@ -12,8 +12,8 @@ #define WEBRTC_COMMON_AUDIO_LAPPED_TRANSFORM_H_ #include <complex> -#include <memory> +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/blocker.h" #include "webrtc/common_audio/real_fourier.h" #include "webrtc/system_wrappers/include/aligned_array.h" @@ -112,7 +112,7 @@ Callback* const block_processor_; Blocker blocker_; - std::unique_ptr<RealFourier> fft_; + rtc::scoped_ptr<RealFourier> fft_; const size_t cplx_length_; AlignedArray<float> real_buf_; AlignedArray<std::complex<float> > cplx_pre_;
diff --git a/webrtc/common_audio/real_fourier.cc b/webrtc/common_audio/real_fourier.cc index 67f942d..55ec49c 100644 --- a/webrtc/common_audio/real_fourier.cc +++ b/webrtc/common_audio/real_fourier.cc
@@ -21,11 +21,11 @@ const size_t RealFourier::kFftBufferAlignment = 32; -std::unique_ptr<RealFourier> RealFourier::Create(int fft_order) { +rtc::scoped_ptr<RealFourier> RealFourier::Create(int fft_order) { #if defined(RTC_USE_OPENMAX_DL) - return std::unique_ptr<RealFourier>(new RealFourierOpenmax(fft_order)); + return rtc::scoped_ptr<RealFourier>(new RealFourierOpenmax(fft_order)); #else - return std::unique_ptr<RealFourier>(new RealFourierOoura(fft_order)); + return rtc::scoped_ptr<RealFourier>(new RealFourierOoura(fft_order)); #endif }
diff --git a/webrtc/common_audio/real_fourier.h b/webrtc/common_audio/real_fourier.h index 5e83e37..0be56a5 100644 --- a/webrtc/common_audio/real_fourier.h +++ b/webrtc/common_audio/real_fourier.h
@@ -12,8 +12,8 @@ #define WEBRTC_COMMON_AUDIO_REAL_FOURIER_H_ #include <complex> -#include <memory> +#include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" // Uniform interface class for the real DFT and its inverse, for power-of-2 @@ -25,8 +25,8 @@ class RealFourier { public: // Shorthand typenames for the scopers used by the buffer allocation helpers. - typedef std::unique_ptr<float[], AlignedFreeDeleter> fft_real_scoper; - typedef std::unique_ptr<std::complex<float>[], AlignedFreeDeleter> + typedef rtc::scoped_ptr<float[], AlignedFreeDeleter> fft_real_scoper; + typedef rtc::scoped_ptr<std::complex<float>[], AlignedFreeDeleter> fft_cplx_scoper; // The alignment required for all input and output buffers, in bytes. @@ -34,7 +34,7 @@ // Construct a wrapper instance for the given input order, which must be // between 1 and kMaxFftOrder, inclusively. - static std::unique_ptr<RealFourier> Create(int fft_order); + static rtc::scoped_ptr<RealFourier> Create(int fft_order); virtual ~RealFourier() {}; // Helper to compute the smallest FFT order (a power of 2) which will contain
diff --git a/webrtc/common_audio/real_fourier_ooura.h b/webrtc/common_audio/real_fourier_ooura.h index 99d09d7..8d094bf 100644 --- a/webrtc/common_audio/real_fourier_ooura.h +++ b/webrtc/common_audio/real_fourier_ooura.h
@@ -12,8 +12,8 @@ #define WEBRTC_COMMON_AUDIO_REAL_FOURIER_OOURA_H_ #include <complex> -#include <memory> +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/real_fourier.h" namespace webrtc { @@ -35,8 +35,8 @@ const size_t complex_length_; // These are work arrays for Ooura. The names are based on the comments in // fft4g.c. - const std::unique_ptr<size_t[]> work_ip_; - const std::unique_ptr<float[]> work_w_; + const rtc::scoped_ptr<size_t[]> work_ip_; + const rtc::scoped_ptr<float[]> work_w_; }; } // namespace webrtc
diff --git a/webrtc/common_audio/real_fourier_unittest.cc b/webrtc/common_audio/real_fourier_unittest.cc index 367fec3..eb5880e 100644 --- a/webrtc/common_audio/real_fourier_unittest.cc +++ b/webrtc/common_audio/real_fourier_unittest.cc
@@ -13,6 +13,7 @@ #include <stdlib.h> #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/real_fourier_openmax.h" #include "webrtc/common_audio/real_fourier_ooura.h"
diff --git a/webrtc/common_audio/resampler/include/push_resampler.h b/webrtc/common_audio/resampler/include/push_resampler.h index 31e08e3..eeda790 100644 --- a/webrtc/common_audio/resampler/include/push_resampler.h +++ b/webrtc/common_audio/resampler/include/push_resampler.h
@@ -11,8 +11,7 @@ #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ #define WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ -#include <memory> - +#include "webrtc/base/scoped_ptr.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -37,15 +36,15 @@ int Resample(const T* src, size_t src_length, T* dst, size_t dst_capacity); private: - std::unique_ptr<PushSincResampler> sinc_resampler_; - std::unique_ptr<PushSincResampler> sinc_resampler_right_; + rtc::scoped_ptr<PushSincResampler> sinc_resampler_; + rtc::scoped_ptr<PushSincResampler> sinc_resampler_right_; int src_sample_rate_hz_; int dst_sample_rate_hz_; size_t num_channels_; - std::unique_ptr<T[]> src_left_; - std::unique_ptr<T[]> src_right_; - std::unique_ptr<T[]> dst_left_; - std::unique_ptr<T[]> dst_right_; + rtc::scoped_ptr<T[]> src_left_; + rtc::scoped_ptr<T[]> src_right_; + rtc::scoped_ptr<T[]> dst_left_; + rtc::scoped_ptr<T[]> dst_right_; }; } // namespace webrtc
diff --git a/webrtc/common_audio/resampler/push_sinc_resampler.h b/webrtc/common_audio/resampler/push_sinc_resampler.h index 2ba60ca..cefc62a 100644 --- a/webrtc/common_audio/resampler/push_sinc_resampler.h +++ b/webrtc/common_audio/resampler/push_sinc_resampler.h
@@ -11,9 +11,8 @@ #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ #define WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_ -#include <memory> - #include "webrtc/base/constructormagic.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/resampler/sinc_resampler.h" #include "webrtc/typedefs.h" @@ -57,8 +56,8 @@ friend class PushSincResamplerTest; SincResampler* get_resampler_for_testing() { return resampler_.get(); } - std::unique_ptr<SincResampler> resampler_; - std::unique_ptr<float[]> float_buffer_; + rtc::scoped_ptr<SincResampler> resampler_; + rtc::scoped_ptr<float[]> float_buffer_; const float* source_ptr_; const int16_t* source_ptr_int_; const size_t destination_frames_;
diff --git a/webrtc/common_audio/resampler/push_sinc_resampler_unittest.cc b/webrtc/common_audio/resampler/push_sinc_resampler_unittest.cc index afb0963..17e3dba 100644 --- a/webrtc/common_audio/resampler/push_sinc_resampler_unittest.cc +++ b/webrtc/common_audio/resampler/push_sinc_resampler_unittest.cc
@@ -10,10 +10,10 @@ #include <cmath> #include <cstring> -#include <memory> #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/include/audio_util.h" #include "webrtc/common_audio/resampler/push_sinc_resampler.h" #include "webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h" @@ -71,10 +71,10 @@ // Source for data to be resampled. ZeroSource resampler_source; - std::unique_ptr<float[]> resampled_destination(new float[output_samples]); - std::unique_ptr<float[]> source(new float[input_samples]); - std::unique_ptr<int16_t[]> source_int(new int16_t[input_samples]); - std::unique_ptr<int16_t[]> destination_int(new int16_t[output_samples]); + rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]); + rtc::scoped_ptr<float[]> source(new float[input_samples]); + rtc::scoped_ptr<int16_t[]> source_int(new int16_t[input_samples]); + rtc::scoped_ptr<int16_t[]> destination_int(new int16_t[output_samples]); resampler_source.Run(input_samples, source.get()); for (size_t i = 0; i < input_samples; ++i) { @@ -153,11 +153,11 @@ // TODO(dalecurtis): If we switch to AVX/SSE optimization, we'll need to // allocate these on 32-byte boundaries and ensure they're sized % 32 bytes. - std::unique_ptr<float[]> resampled_destination(new float[output_samples]); - std::unique_ptr<float[]> pure_destination(new float[output_samples]); - std::unique_ptr<float[]> source(new float[input_samples]); - std::unique_ptr<int16_t[]> source_int(new int16_t[input_block_size]); - std::unique_ptr<int16_t[]> destination_int(new int16_t[output_block_size]); + rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]); + rtc::scoped_ptr<float[]> pure_destination(new float[output_samples]); + rtc::scoped_ptr<float[]> source(new float[input_samples]); + rtc::scoped_ptr<int16_t[]> source_int(new int16_t[input_block_size]); + rtc::scoped_ptr<int16_t[]> destination_int(new int16_t[output_block_size]); // The sinc resampler has an implicit delay of approximately half the kernel // size at the input sample rate. By moving to a push model, this delay
diff --git a/webrtc/common_audio/resampler/sinc_resampler.h b/webrtc/common_audio/resampler/sinc_resampler.h index d8ea6df..0980e2d 100644 --- a/webrtc/common_audio/resampler/sinc_resampler.h +++ b/webrtc/common_audio/resampler/sinc_resampler.h
@@ -14,10 +14,9 @@ #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ #define WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ -#include <memory> - #include "webrtc/base/constructormagic.h" #include "webrtc/base/gtest_prod_util.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" #include "webrtc/typedefs.h" @@ -138,12 +137,12 @@ // Contains kKernelOffsetCount kernels back-to-back, each of size kKernelSize. // The kernel offsets are sub-sample shifts of a windowed sinc shifted from // 0.0 to 1.0 sample. - std::unique_ptr<float[], AlignedFreeDeleter> kernel_storage_; - std::unique_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_; - std::unique_ptr<float[], AlignedFreeDeleter> kernel_window_storage_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_storage_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_window_storage_; // Data from the source is copied into this buffer for each processing pass. - std::unique_ptr<float[], AlignedFreeDeleter> input_buffer_; + rtc::scoped_ptr<float[], AlignedFreeDeleter> input_buffer_; // Stores the runtime selection of which Convolve function to use. // TODO(ajm): Move to using a global static which must only be initialized
diff --git a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc index 42172eb..b8d6c34 100644 --- a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc +++ b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc
@@ -16,10 +16,9 @@ #include <math.h> -#include <memory> - #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/resampler/sinc_resampler.h" #include "webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" @@ -63,7 +62,7 @@ static const int kChunks = 2; size_t max_chunk_size = resampler.ChunkSize() * kChunks; - std::unique_ptr<float[]> resampled_destination(new float[max_chunk_size]); + rtc::scoped_ptr<float[]> resampled_destination(new float[max_chunk_size]); // Verify requesting ChunkSize() frames causes a single callback. EXPECT_CALL(mock_source, Run(_, _)) @@ -82,7 +81,7 @@ MockSource mock_source; SincResampler resampler(kSampleRateRatio, SincResampler::kDefaultRequestSize, &mock_source); - std::unique_ptr<float[]> resampled_destination( + rtc::scoped_ptr<float[]> resampled_destination( new float[resampler.ChunkSize()]); // Fill the resampler with junk data. @@ -270,7 +269,7 @@ // Force an update to the sample rate ratio to ensure dyanmic sample rate // changes are working correctly. - std::unique_ptr<float[]> kernel(new float[SincResampler::kKernelStorageSize]); + rtc::scoped_ptr<float[]> kernel(new float[SincResampler::kKernelStorageSize]); memcpy(kernel.get(), resampler.get_kernel_for_testing(), SincResampler::kKernelStorageSize); resampler.SetRatio(M_PI); @@ -282,8 +281,8 @@ // TODO(dalecurtis): If we switch to AVX/SSE optimization, we'll need to // allocate these on 32-byte boundaries and ensure they're sized % 32 bytes. - std::unique_ptr<float[]> resampled_destination(new float[output_samples]); - std::unique_ptr<float[]> pure_destination(new float[output_samples]); + rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]); + rtc::scoped_ptr<float[]> pure_destination(new float[output_samples]); // Generate resampled signal. resampler.Resample(output_samples, resampled_destination.get());
diff --git a/webrtc/common_audio/ring_buffer_unittest.cc b/webrtc/common_audio/ring_buffer_unittest.cc index 92c470a..f8cce74 100644 --- a/webrtc/common_audio/ring_buffer_unittest.cc +++ b/webrtc/common_audio/ring_buffer_unittest.cc
@@ -12,11 +12,10 @@ #include <stdlib.h> #include <time.h> - #include <algorithm> -#include <memory> #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/scoped_ptr.h" namespace webrtc { @@ -25,7 +24,7 @@ WebRtc_FreeBuffer(ptr); } }; -typedef std::unique_ptr<RingBuffer, FreeBufferDeleter> scoped_ring_buffer; +typedef rtc::scoped_ptr<RingBuffer, FreeBufferDeleter> scoped_ring_buffer; static void AssertElementEq(int expected, int actual) { ASSERT_EQ(expected, actual); @@ -59,8 +58,8 @@ srand(seed); for (int i = 0; i < kNumTests; i++) { const int buffer_size = std::max(rand() % kMaxBufferSize, 1); - std::unique_ptr<int[]> write_data(new int[buffer_size]); - std::unique_ptr<int[]> read_data(new int[buffer_size]); + rtc::scoped_ptr<int[]> write_data(new int[buffer_size]); + rtc::scoped_ptr<int[]> read_data(new int[buffer_size]); scoped_ring_buffer buffer(WebRtc_CreateBuffer(buffer_size, sizeof(int))); ASSERT_TRUE(buffer.get() != NULL); WebRtc_InitBuffer(buffer.get());
diff --git a/webrtc/common_audio/sparse_fir_filter_unittest.cc b/webrtc/common_audio/sparse_fir_filter_unittest.cc index 21b28ed..82a53a5 100644 --- a/webrtc/common_audio/sparse_fir_filter_unittest.cc +++ b/webrtc/common_audio/sparse_fir_filter_unittest.cc
@@ -8,12 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include <memory> - #include "webrtc/common_audio/sparse_fir_filter.h" #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/arraysize.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/fir_filter.h" namespace webrtc { @@ -215,8 +214,9 @@ const size_t kOffset = 0; float output[arraysize(kInput)]; float sparse_output[arraysize(kInput)]; - std::unique_ptr<FIRFilter> filter( - FIRFilter::Create(kCoeffs, arraysize(kCoeffs), arraysize(kInput))); + rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create(kCoeffs, + arraysize(kCoeffs), + arraysize(kInput))); SparseFIRFilter sparse_filter(kCoeffs, arraysize(kCoeffs), kSparsity,
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 7bb79e1..bb746ee 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -297,11 +297,11 @@ formats_.rev_proc_format.num_channels(), rev_audio_buffer_out_num_frames)); if (rev_conversion_needed()) { - render_.render_converter = AudioConverter::Create( + render_.render_converter = rtc::ScopedToUnique(AudioConverter::Create( formats_.api_format.reverse_input_stream().num_channels(), formats_.api_format.reverse_input_stream().num_frames(), formats_.api_format.reverse_output_stream().num_channels(), - formats_.api_format.reverse_output_stream().num_frames()); + formats_.api_format.reverse_output_stream().num_frames())); } else { render_.render_converter.reset(nullptr); }
diff --git a/webrtc/modules/audio_processing/transient/transient_suppressor.cc b/webrtc/modules/audio_processing/transient/transient_suppressor.cc index 46bb574..25909b9 100644 --- a/webrtc/modules/audio_processing/transient/transient_suppressor.cc +++ b/webrtc/modules/audio_processing/transient/transient_suppressor.cc
@@ -17,7 +17,6 @@ #include <deque> #include <set> -#include "webrtc/base/checks.h" #include "webrtc/common_audio/fft4g.h" #include "webrtc/common_audio/include/audio_util.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" @@ -101,13 +100,13 @@ detector_.reset(new TransientDetector(detection_rate_hz)); data_length_ = sample_rate_hz * ts::kChunkSizeMs / 1000; if (data_length_ > analysis_length_) { - RTC_NOTREACHED(); + assert(false); return -1; } buffer_delay_ = analysis_length_ - data_length_; complex_analysis_length_ = analysis_length_ / 2 + 1; - RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin); + assert(complex_analysis_length_ >= kMaxVoiceBin); num_channels_ = num_channels; in_buffer_.reset(new float[analysis_length_ * num_channels_]); memset(in_buffer_.get(),