diff --git a/webrtc/common_audio/audio_converter.cc b/webrtc/common_audio/audio_converter.cc index d6334b3866..9ebfabc286 100644 --- a/webrtc/common_audio/audio_converter.cc +++ b/webrtc/common_audio/audio_converter.cc @@ -136,11 +136,11 @@ class CompositionConverter : public AudioConverter { ScopedVector> buffers_; }; -std::unique_ptr AudioConverter::Create(size_t src_channels, +rtc::scoped_ptr AudioConverter::Create(size_t src_channels, size_t src_frames, size_t dst_channels, size_t dst_frames) { - std::unique_ptr sp; + rtc::scoped_ptr sp; if (src_channels > dst_channels) { if (src_frames != dst_frames) { ScopedVector converters; diff --git a/webrtc/common_audio/audio_converter.h b/webrtc/common_audio/audio_converter.h index 01dad4dfc8..c5f08c1d9b 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 - #include "webrtc/base/constructormagic.h" +#include "webrtc/base/scoped_ptr.h" namespace webrtc { @@ -27,7 +26,7 @@ class AudioConverter { public: // Returns a new AudioConverter, which will use the supplied format for its // lifetime. Caller is responsible for the memory. - static std::unique_ptr Create(size_t src_channels, + static rtc::scoped_ptr 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 f86e37b26f..dace0bdccf 100644 --- a/webrtc/common_audio/audio_converter_unittest.cc +++ b/webrtc/common_audio/audio_converter_unittest.cc @@ -10,19 +10,19 @@ #include #include -#include #include #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> ScopedBuffer; +typedef rtc::scoped_ptr> ScopedBuffer; // Sets the signal value to increase by |data| with every sample. ScopedBuffer CreateBuffer(const std::vector& data, size_t frames) { @@ -132,7 +132,7 @@ void RunAudioConverterTest(size_t src_channels, printf("(%" PRIuS ", %d Hz) -> (%" PRIuS ", %d Hz) ", src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz); - std::unique_ptr converter = AudioConverter::Create( + rtc::scoped_ptr 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 e73f55b73b..58e543adea 100644 --- a/webrtc/common_audio/audio_ring_buffer.h +++ b/webrtc/common_audio/audio_ring_buffer.h @@ -47,7 +47,7 @@ class AudioRingBuffer final { 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 buffers_; }; diff --git a/webrtc/common_audio/audio_ring_buffer_unittest.cc b/webrtc/common_audio/audio_ring_buffer_unittest.cc index c5c38de56d..a7a6a9442b 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 - #include "webrtc/common_audio/audio_ring_buffer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -29,7 +27,7 @@ void ReadAndWriteTest(const ChannelBuffer& input, 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 slice(new float*[num_channels]); + rtc::scoped_ptr 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 edf81d337a..3a67c134d0 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 - +#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 @@ class Blocker { // Space for the output block (can't wrap because of overlap/add). ChannelBuffer output_block_; - std::unique_ptr window_; + rtc::scoped_ptr 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 eea3e2516a..a5a7b56282 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 - #include "webrtc/common_audio/blocker.h" #include "testing/gtest/include/gtest/gtest.h" @@ -309,7 +307,7 @@ TEST_F(BlockerTest, InitialDelaysAreMinimum) { CopyBlockerCallback callback; for (size_t i = 0; i < arraysize(kChunkSize); ++i) { - std::unique_ptr window(new float[kBlockSize[i]]); + rtc::scoped_ptr 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 349d4245cc..44520c6100 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 @@ const ChannelBuffer* IFChannelBuffer::fbuf_const() const { 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::RefreshF() const { 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 faecec9194..9f2fb96357 100644 --- a/webrtc/common_audio/channel_buffer.h +++ b/webrtc/common_audio/channel_buffer.h @@ -13,10 +13,9 @@ #include -#include - #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 @@ class ChannelBuffer { } private: - std::unique_ptr data_; - std::unique_ptr channels_; - std::unique_ptr bands_; + rtc::scoped_ptr data_; + rtc::scoped_ptr channels_; + rtc::scoped_ptr 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 13a2237dae..dc1b776f99 100644 --- a/webrtc/common_audio/fir_filter.cc +++ b/webrtc/common_audio/fir_filter.cc @@ -13,8 +13,7 @@ #include #include -#include - +#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 @@ class FIRFilterC : public FIRFilter { private: size_t coefficients_length_; size_t state_length_; - std::unique_ptr coefficients_; - std::unique_ptr state_; + rtc::scoped_ptr coefficients_; + rtc::scoped_ptr 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 5576856b72..3aa6168dd2 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 - +#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 @@ class FIRFilterNEON : public FIRFilter { private: size_t coefficients_length_; size_t state_length_; - std::unique_ptr coefficients_; - std::unique_ptr state_; + rtc::scoped_ptr coefficients_; + rtc::scoped_ptr state_; }; } // namespace webrtc diff --git a/webrtc/common_audio/fir_filter_sse.cc b/webrtc/common_audio/fir_filter_sse.cc index 89abb00ba4..adbb2b75cc 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 -#include #include #include diff --git a/webrtc/common_audio/fir_filter_sse.h b/webrtc/common_audio/fir_filter_sse.h index 3b1e324fc8..a3325cd01d 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 - +#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 @@ class FIRFilterSSE2 : public FIRFilter { private: size_t coefficients_length_; size_t state_length_; - std::unique_ptr coefficients_; - std::unique_ptr state_; + rtc::scoped_ptr coefficients_; + rtc::scoped_ptr state_; }; } // namespace webrtc diff --git a/webrtc/common_audio/fir_filter_unittest.cc b/webrtc/common_audio/fir_filter_unittest.cc index 9dffcb615f..13f79d9482 100644 --- a/webrtc/common_audio/fir_filter_unittest.cc +++ b/webrtc/common_audio/fir_filter_unittest.cc @@ -12,9 +12,8 @@ #include -#include - #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/scoped_ptr.h" namespace webrtc { namespace { @@ -41,7 +40,7 @@ void VerifyOutput(const float* expected_output, TEST(FIRFilterTest, FilterAsIdentity) { const float kCoefficients[] = {1.f, 0.f, 0.f, 0.f, 0.f}; float output[kInputLength]; - std::unique_ptr filter( + rtc::scoped_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -51,7 +50,7 @@ TEST(FIRFilterTest, FilterAsIdentity) { TEST(FIRFilterTest, FilterUsedAsScalarMultiplication) { const float kCoefficients[] = {5.f, 0.f, 0.f, 0.f, 0.f}; float output[kInputLength]; - std::unique_ptr filter( + rtc::scoped_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -64,7 +63,7 @@ TEST(FIRFilterTest, FilterUsedAsScalarMultiplication) { TEST(FIRFilterTest, FilterUsedAsInputShifting) { const float kCoefficients[] = {0.f, 0.f, 0.f, 0.f, 1.f}; float output[kInputLength]; - std::unique_ptr filter( + rtc::scoped_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -77,7 +76,7 @@ TEST(FIRFilterTest, FilterUsedAsInputShifting) { TEST(FIRFilterTest, FilterUsedAsArbitraryWeighting) { float output[kInputLength]; - std::unique_ptr filter( + rtc::scoped_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -90,7 +89,7 @@ TEST(FIRFilterTest, FilterUsedAsArbitraryWeighting) { TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) { float output[kInputLength]; - std::unique_ptr filter( + rtc::scoped_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, 2)); filter->Filter(kInput, 2, output); @@ -107,7 +106,7 @@ TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) { TEST(FIRFilterTest, MultipleFilterCalls) { float output[kInputLength]; - std::unique_ptr filter( + rtc::scoped_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, 3)); filter->Filter(kInput, 2, output); EXPECT_FLOAT_EQ(0.2f, output[0]); @@ -138,7 +137,7 @@ TEST(FIRFilterTest, MultipleFilterCalls) { TEST(FIRFilterTest, VerifySampleBasedVsBlockBasedFiltering) { float output_block_based[kInputLength]; - std::unique_ptr filter( + rtc::scoped_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output_block_based); @@ -163,7 +162,7 @@ TEST(FIRFilterTest, SimplestHighPassFilter) { sizeof(kConstantInput[0]); float output[kConstantInputLength]; - std::unique_ptr filter(FIRFilter::Create( + rtc::scoped_ptr filter(FIRFilter::Create( kCoefficients, kCoefficientsLength, kConstantInputLength)); filter->Filter(kConstantInput, kConstantInputLength, output); EXPECT_FLOAT_EQ(1.f, output[0]); @@ -182,7 +181,7 @@ TEST(FIRFilterTest, SimplestLowPassFilter) { sizeof(kHighFrequencyInput[0]); float output[kHighFrequencyInputLength]; - std::unique_ptr filter(FIRFilter::Create( + rtc::scoped_ptr filter(FIRFilter::Create( kCoefficients, kCoefficientsLength, kHighFrequencyInputLength)); filter->Filter(kHighFrequencyInput, kHighFrequencyInputLength, output); EXPECT_FLOAT_EQ(-1.f, output[0]); @@ -194,7 +193,7 @@ TEST(FIRFilterTest, SimplestLowPassFilter) { TEST(FIRFilterTest, SameOutputWhenSwapedCoefficientsAndInput) { float output[kCoefficientsLength]; float output_swaped[kCoefficientsLength]; - std::unique_ptr filter(FIRFilter::Create( + rtc::scoped_ptr 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 e5ad701595..55dfc06a31 100644 --- a/webrtc/common_audio/include/audio_util.h +++ b/webrtc/common_audio/include/audio_util.h @@ -15,6 +15,7 @@ #include #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 832735991b..1373ca10e1 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 -#include +#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 @@ class LappedTransform { Callback* const block_processor_; Blocker blocker_; - std::unique_ptr fft_; + rtc::scoped_ptr fft_; const size_t cplx_length_; AlignedArray real_buf_; AlignedArray > cplx_pre_; diff --git a/webrtc/common_audio/real_fourier.cc b/webrtc/common_audio/real_fourier.cc index 67f942d560..55ec49cba2 100644 --- a/webrtc/common_audio/real_fourier.cc +++ b/webrtc/common_audio/real_fourier.cc @@ -21,11 +21,11 @@ using std::complex; const size_t RealFourier::kFftBufferAlignment = 32; -std::unique_ptr RealFourier::Create(int fft_order) { +rtc::scoped_ptr RealFourier::Create(int fft_order) { #if defined(RTC_USE_OPENMAX_DL) - return std::unique_ptr(new RealFourierOpenmax(fft_order)); + return rtc::scoped_ptr(new RealFourierOpenmax(fft_order)); #else - return std::unique_ptr(new RealFourierOoura(fft_order)); + return rtc::scoped_ptr(new RealFourierOoura(fft_order)); #endif } diff --git a/webrtc/common_audio/real_fourier.h b/webrtc/common_audio/real_fourier.h index 5e83e37f70..0be56a58b0 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 -#include +#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 @@ namespace webrtc { class RealFourier { public: // Shorthand typenames for the scopers used by the buffer allocation helpers. - typedef std::unique_ptr fft_real_scoper; - typedef std::unique_ptr[], AlignedFreeDeleter> + typedef rtc::scoped_ptr fft_real_scoper; + typedef rtc::scoped_ptr[], AlignedFreeDeleter> fft_cplx_scoper; // The alignment required for all input and output buffers, in bytes. @@ -34,7 +34,7 @@ class RealFourier { // Construct a wrapper instance for the given input order, which must be // between 1 and kMaxFftOrder, inclusively. - static std::unique_ptr Create(int fft_order); + static rtc::scoped_ptr 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 99d09d78fe..8d094bf494 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 -#include +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/real_fourier.h" namespace webrtc { @@ -35,8 +35,8 @@ class RealFourierOoura : public RealFourier { 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 work_ip_; - const std::unique_ptr work_w_; + const rtc::scoped_ptr work_ip_; + const rtc::scoped_ptr work_w_; }; } // namespace webrtc diff --git a/webrtc/common_audio/real_fourier_unittest.cc b/webrtc/common_audio/real_fourier_unittest.cc index 367fec3851..eb5880ee8a 100644 --- a/webrtc/common_audio/real_fourier_unittest.cc +++ b/webrtc/common_audio/real_fourier_unittest.cc @@ -13,6 +13,7 @@ #include #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 31e08e3640..eeda790497 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 - +#include "webrtc/base/scoped_ptr.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -37,15 +36,15 @@ class PushResampler { int Resample(const T* src, size_t src_length, T* dst, size_t dst_capacity); private: - std::unique_ptr sinc_resampler_; - std::unique_ptr sinc_resampler_right_; + rtc::scoped_ptr sinc_resampler_; + rtc::scoped_ptr sinc_resampler_right_; int src_sample_rate_hz_; int dst_sample_rate_hz_; size_t num_channels_; - std::unique_ptr src_left_; - std::unique_ptr src_right_; - std::unique_ptr dst_left_; - std::unique_ptr dst_right_; + rtc::scoped_ptr src_left_; + rtc::scoped_ptr src_right_; + rtc::scoped_ptr dst_left_; + rtc::scoped_ptr 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 2ba60cac9c..cefc62aa2a 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 - #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 @@ class PushSincResampler : public SincResamplerCallback { friend class PushSincResamplerTest; SincResampler* get_resampler_for_testing() { return resampler_.get(); } - std::unique_ptr resampler_; - std::unique_ptr float_buffer_; + rtc::scoped_ptr resampler_; + rtc::scoped_ptr 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 afb0963c3f..17e3dba1e2 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 #include -#include #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 @@ void PushSincResamplerTest::ResampleBenchmarkTest(bool int_format) { // Source for data to be resampled. ZeroSource resampler_source; - std::unique_ptr resampled_destination(new float[output_samples]); - std::unique_ptr source(new float[input_samples]); - std::unique_ptr source_int(new int16_t[input_samples]); - std::unique_ptr destination_int(new int16_t[output_samples]); + rtc::scoped_ptr resampled_destination(new float[output_samples]); + rtc::scoped_ptr source(new float[input_samples]); + rtc::scoped_ptr source_int(new int16_t[input_samples]); + rtc::scoped_ptr 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 @@ void PushSincResamplerTest::ResampleTest(bool int_format) { // 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 resampled_destination(new float[output_samples]); - std::unique_ptr pure_destination(new float[output_samples]); - std::unique_ptr source(new float[input_samples]); - std::unique_ptr source_int(new int16_t[input_block_size]); - std::unique_ptr destination_int(new int16_t[output_block_size]); + rtc::scoped_ptr resampled_destination(new float[output_samples]); + rtc::scoped_ptr pure_destination(new float[output_samples]); + rtc::scoped_ptr source(new float[input_samples]); + rtc::scoped_ptr source_int(new int16_t[input_block_size]); + rtc::scoped_ptr 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 d8ea6df72f..0980e2d756 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 - #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 @@ class SincResampler { // 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 kernel_storage_; - std::unique_ptr kernel_pre_sinc_storage_; - std::unique_ptr kernel_window_storage_; + rtc::scoped_ptr kernel_storage_; + rtc::scoped_ptr kernel_pre_sinc_storage_; + rtc::scoped_ptr kernel_window_storage_; // Data from the source is copied into this buffer for each processing pass. - std::unique_ptr input_buffer_; + rtc::scoped_ptr 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 42172ebdda..b8d6c341a2 100644 --- a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc +++ b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc @@ -16,10 +16,9 @@ #include -#include - #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 @@ TEST(SincResamplerTest, ChunkedResample) { static const int kChunks = 2; size_t max_chunk_size = resampler.ChunkSize() * kChunks; - std::unique_ptr resampled_destination(new float[max_chunk_size]); + rtc::scoped_ptr resampled_destination(new float[max_chunk_size]); // Verify requesting ChunkSize() frames causes a single callback. EXPECT_CALL(mock_source, Run(_, _)) @@ -82,7 +81,7 @@ TEST(SincResamplerTest, Flush) { MockSource mock_source; SincResampler resampler(kSampleRateRatio, SincResampler::kDefaultRequestSize, &mock_source); - std::unique_ptr resampled_destination( + rtc::scoped_ptr resampled_destination( new float[resampler.ChunkSize()]); // Fill the resampler with junk data. @@ -270,7 +269,7 @@ TEST_P(SincResamplerTest, Resample) { // Force an update to the sample rate ratio to ensure dyanmic sample rate // changes are working correctly. - std::unique_ptr kernel(new float[SincResampler::kKernelStorageSize]); + rtc::scoped_ptr kernel(new float[SincResampler::kKernelStorageSize]); memcpy(kernel.get(), resampler.get_kernel_for_testing(), SincResampler::kKernelStorageSize); resampler.SetRatio(M_PI); @@ -282,8 +281,8 @@ TEST_P(SincResamplerTest, Resample) { // 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 resampled_destination(new float[output_samples]); - std::unique_ptr pure_destination(new float[output_samples]); + rtc::scoped_ptr resampled_destination(new float[output_samples]); + rtc::scoped_ptr 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 92c470a02d..f8cce74d9c 100644 --- a/webrtc/common_audio/ring_buffer_unittest.cc +++ b/webrtc/common_audio/ring_buffer_unittest.cc @@ -12,11 +12,10 @@ #include #include - #include -#include #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/scoped_ptr.h" namespace webrtc { @@ -25,7 +24,7 @@ struct FreeBufferDeleter { WebRtc_FreeBuffer(ptr); } }; -typedef std::unique_ptr scoped_ring_buffer; +typedef rtc::scoped_ptr scoped_ring_buffer; static void AssertElementEq(int expected, int actual) { ASSERT_EQ(expected, actual); @@ -59,8 +58,8 @@ static void RandomStressTest(int** data_ptr) { srand(seed); for (int i = 0; i < kNumTests; i++) { const int buffer_size = std::max(rand() % kMaxBufferSize, 1); - std::unique_ptr write_data(new int[buffer_size]); - std::unique_ptr read_data(new int[buffer_size]); + rtc::scoped_ptr write_data(new int[buffer_size]); + rtc::scoped_ptr 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 21b28ed34a..82a53a5287 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 - #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 @@ TEST(SparseFIRFilterTest, SameOutputAsFIRFilterWhenSparsityOneAndOffsetZero) { const size_t kOffset = 0; float output[arraysize(kInput)]; float sparse_output[arraysize(kInput)]; - std::unique_ptr filter( - FIRFilter::Create(kCoeffs, arraysize(kCoeffs), arraysize(kInput))); + rtc::scoped_ptr 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 7bb79e1714..bb746ee635 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -297,11 +297,11 @@ int AudioProcessingImpl::InitializeLocked() { 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 46bb574c0b..25909b9008 100644 --- a/webrtc/modules/audio_processing/transient/transient_suppressor.cc +++ b/webrtc/modules/audio_processing/transient/transient_suppressor.cc @@ -17,7 +17,6 @@ #include #include -#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 @@ int TransientSuppressor::Initialize(int sample_rate_hz, 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(),