diff --git a/webrtc/common_audio/audio_converter.cc b/webrtc/common_audio/audio_converter.cc index 9ebfabc286..d6334b3866 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_; }; -rtc::scoped_ptr AudioConverter::Create(size_t src_channels, +std::unique_ptr AudioConverter::Create(size_t src_channels, size_t src_frames, size_t dst_channels, size_t dst_frames) { - rtc::scoped_ptr sp; + std::unique_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 c5f08c1d9b..01dad4dfc8 100644 --- a/webrtc/common_audio/audio_converter.h +++ b/webrtc/common_audio/audio_converter.h @@ -11,8 +11,9 @@ #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 { @@ -26,7 +27,7 @@ class AudioConverter { public: // Returns a new AudioConverter, which will use the supplied format for its // lifetime. Caller is responsible for the memory. - static rtc::scoped_ptr Create(size_t src_channels, + static std::unique_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 dace0bdccf..f86e37b26f 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 rtc::scoped_ptr> ScopedBuffer; +typedef std::unique_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); - rtc::scoped_ptr converter = AudioConverter::Create( + std::unique_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 58e543adea..e73f55b73b 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 scoped_ptr for instance.) + // deleter (like unique_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 a7a6a9442b..c5c38de56d 100644 --- a/webrtc/common_audio/audio_ring_buffer_unittest.cc +++ b/webrtc/common_audio/audio_ring_buffer_unittest.cc @@ -8,6 +8,8 @@ * 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" @@ -27,7 +29,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); - rtc::scoped_ptr slice(new float* [num_channels]); + std::unique_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 3a67c134d0..edf81d337a 100644 --- a/webrtc/common_audio/blocker.h +++ b/webrtc/common_audio/blocker.h @@ -11,7 +11,8 @@ #ifndef WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_ #define WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_ -#include "webrtc/base/scoped_ptr.h" +#include + #include "webrtc/common_audio/audio_ring_buffer.h" #include "webrtc/common_audio/channel_buffer.h" @@ -109,7 +110,7 @@ class Blocker { // Space for the output block (can't wrap because of overlap/add). ChannelBuffer output_block_; - rtc::scoped_ptr window_; + std::unique_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 a5a7b56282..eea3e2516a 100644 --- a/webrtc/common_audio/blocker_unittest.cc +++ b/webrtc/common_audio/blocker_unittest.cc @@ -8,6 +8,8 @@ * 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" @@ -307,7 +309,7 @@ TEST_F(BlockerTest, InitialDelaysAreMinimum) { CopyBlockerCallback callback; for (size_t i = 0; i < arraysize(kChunkSize); ++i) { - rtc::scoped_ptr window(new float[kBlockSize[i]]); + std::unique_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 44520c6100..349d4245cc 100644 --- a/webrtc/common_audio/channel_buffer.cc +++ b/webrtc/common_audio/channel_buffer.cc @@ -10,6 +10,8 @@ #include "webrtc/common_audio/channel_buffer.h" +#include "webrtc/base/checks.h" + namespace webrtc { IFChannelBuffer::IFChannelBuffer(size_t num_frames, @@ -44,7 +46,7 @@ const ChannelBuffer* IFChannelBuffer::fbuf_const() const { void IFChannelBuffer::RefreshF() const { if (!fvalid_) { - assert(ivalid_); + RTC_DCHECK(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) { @@ -58,7 +60,7 @@ void IFChannelBuffer::RefreshF() const { void IFChannelBuffer::RefreshI() const { if (!ivalid_) { - assert(fvalid_); + RTC_DCHECK(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 9f2fb96357..faecec9194 100644 --- a/webrtc/common_audio/channel_buffer.h +++ b/webrtc/common_audio/channel_buffer.h @@ -13,9 +13,10 @@ #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 { @@ -125,9 +126,9 @@ class ChannelBuffer { } private: - rtc::scoped_ptr data_; - rtc::scoped_ptr channels_; - rtc::scoped_ptr bands_; + std::unique_ptr data_; + std::unique_ptr channels_; + std::unique_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 dc1b776f99..13a2237dae 100644 --- a/webrtc/common_audio/fir_filter.cc +++ b/webrtc/common_audio/fir_filter.cc @@ -13,7 +13,8 @@ #include #include -#include "webrtc/base/scoped_ptr.h" +#include + #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" @@ -30,8 +31,8 @@ class FIRFilterC : public FIRFilter { private: size_t coefficients_length_; size_t state_length_; - rtc::scoped_ptr coefficients_; - rtc::scoped_ptr state_; + std::unique_ptr coefficients_; + std::unique_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 3aa6168dd2..5576856b72 100644 --- a/webrtc/common_audio/fir_filter_neon.h +++ b/webrtc/common_audio/fir_filter_neon.h @@ -11,7 +11,8 @@ #ifndef WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_ #define WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_ -#include "webrtc/base/scoped_ptr.h" +#include + #include "webrtc/common_audio/fir_filter.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" @@ -28,8 +29,8 @@ class FIRFilterNEON : public FIRFilter { private: size_t coefficients_length_; size_t state_length_; - rtc::scoped_ptr coefficients_; - rtc::scoped_ptr state_; + std::unique_ptr coefficients_; + std::unique_ptr state_; }; } // namespace webrtc diff --git a/webrtc/common_audio/fir_filter_sse.cc b/webrtc/common_audio/fir_filter_sse.cc index adbb2b75cc..89abb00ba4 100644 --- a/webrtc/common_audio/fir_filter_sse.cc +++ b/webrtc/common_audio/fir_filter_sse.cc @@ -11,6 +11,7 @@ #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 a3325cd01d..3b1e324fc8 100644 --- a/webrtc/common_audio/fir_filter_sse.h +++ b/webrtc/common_audio/fir_filter_sse.h @@ -11,7 +11,8 @@ #ifndef WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_ #define WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_ -#include "webrtc/base/scoped_ptr.h" +#include + #include "webrtc/common_audio/fir_filter.h" #include "webrtc/system_wrappers/include/aligned_malloc.h" @@ -28,8 +29,8 @@ class FIRFilterSSE2 : public FIRFilter { private: size_t coefficients_length_; size_t state_length_; - rtc::scoped_ptr coefficients_; - rtc::scoped_ptr state_; + std::unique_ptr coefficients_; + std::unique_ptr state_; }; } // namespace webrtc diff --git a/webrtc/common_audio/fir_filter_unittest.cc b/webrtc/common_audio/fir_filter_unittest.cc index 13f79d9482..9dffcb615f 100644 --- a/webrtc/common_audio/fir_filter_unittest.cc +++ b/webrtc/common_audio/fir_filter_unittest.cc @@ -12,8 +12,9 @@ #include +#include + #include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/base/scoped_ptr.h" namespace webrtc { namespace { @@ -40,7 +41,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]; - rtc::scoped_ptr filter( + std::unique_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -50,7 +51,7 @@ TEST(FIRFilterTest, FilterAsIdentity) { TEST(FIRFilterTest, FilterUsedAsScalarMultiplication) { const float kCoefficients[] = {5.f, 0.f, 0.f, 0.f, 0.f}; float output[kInputLength]; - rtc::scoped_ptr filter( + std::unique_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -63,7 +64,7 @@ TEST(FIRFilterTest, FilterUsedAsScalarMultiplication) { TEST(FIRFilterTest, FilterUsedAsInputShifting) { const float kCoefficients[] = {0.f, 0.f, 0.f, 0.f, 1.f}; float output[kInputLength]; - rtc::scoped_ptr filter( + std::unique_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -76,7 +77,7 @@ TEST(FIRFilterTest, FilterUsedAsInputShifting) { TEST(FIRFilterTest, FilterUsedAsArbitraryWeighting) { float output[kInputLength]; - rtc::scoped_ptr filter( + std::unique_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output); @@ -89,7 +90,7 @@ TEST(FIRFilterTest, FilterUsedAsArbitraryWeighting) { TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) { float output[kInputLength]; - rtc::scoped_ptr filter( + std::unique_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, 2)); filter->Filter(kInput, 2, output); @@ -106,7 +107,7 @@ TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) { TEST(FIRFilterTest, MultipleFilterCalls) { float output[kInputLength]; - rtc::scoped_ptr filter( + std::unique_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, 3)); filter->Filter(kInput, 2, output); EXPECT_FLOAT_EQ(0.2f, output[0]); @@ -137,7 +138,7 @@ TEST(FIRFilterTest, MultipleFilterCalls) { TEST(FIRFilterTest, VerifySampleBasedVsBlockBasedFiltering) { float output_block_based[kInputLength]; - rtc::scoped_ptr filter( + std::unique_ptr filter( FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength)); filter->Filter(kInput, kInputLength, output_block_based); @@ -162,7 +163,7 @@ TEST(FIRFilterTest, SimplestHighPassFilter) { sizeof(kConstantInput[0]); float output[kConstantInputLength]; - rtc::scoped_ptr filter(FIRFilter::Create( + std::unique_ptr filter(FIRFilter::Create( kCoefficients, kCoefficientsLength, kConstantInputLength)); filter->Filter(kConstantInput, kConstantInputLength, output); EXPECT_FLOAT_EQ(1.f, output[0]); @@ -181,7 +182,7 @@ TEST(FIRFilterTest, SimplestLowPassFilter) { sizeof(kHighFrequencyInput[0]); float output[kHighFrequencyInputLength]; - rtc::scoped_ptr filter(FIRFilter::Create( + std::unique_ptr filter(FIRFilter::Create( kCoefficients, kCoefficientsLength, kHighFrequencyInputLength)); filter->Filter(kHighFrequencyInput, kHighFrequencyInputLength, output); EXPECT_FLOAT_EQ(-1.f, output[0]); @@ -193,7 +194,7 @@ TEST(FIRFilterTest, SimplestLowPassFilter) { TEST(FIRFilterTest, SameOutputWhenSwapedCoefficientsAndInput) { float output[kCoefficientsLength]; float output_swaped[kCoefficientsLength]; - rtc::scoped_ptr filter(FIRFilter::Create( + std::unique_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 55dfc06a31..e5ad701595 100644 --- a/webrtc/common_audio/include/audio_util.h +++ b/webrtc/common_audio/include/audio_util.h @@ -15,7 +15,6 @@ #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.cc b/webrtc/common_audio/lapped_transform.cc index 5ab1db1b25..0edf586d78 100644 --- a/webrtc/common_audio/lapped_transform.cc +++ b/webrtc/common_audio/lapped_transform.cc @@ -72,7 +72,8 @@ LappedTransform::LappedTransform(size_t num_in_channels, window, shift_amount, &blocker_callback_), - fft_(RealFourier::Create(RealFourier::FftOrder(block_length_))), + fft_(rtc::ScopedToUnique( + RealFourier::Create(RealFourier::FftOrder(block_length_)))), cplx_length_(RealFourier::ComplexLength(fft_->order())), real_buf_(num_in_channels, block_length_, diff --git a/webrtc/common_audio/lapped_transform.h b/webrtc/common_audio/lapped_transform.h index 1373ca10e1..832735991b 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_; - rtc::scoped_ptr fft_; + std::unique_ptr fft_; const size_t cplx_length_; AlignedArray real_buf_; AlignedArray > cplx_pre_; diff --git a/webrtc/common_audio/real_fourier_ooura.h b/webrtc/common_audio/real_fourier_ooura.h index 8d094bf494..99d09d78fe 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 rtc::scoped_ptr work_ip_; - const rtc::scoped_ptr work_w_; + const std::unique_ptr work_ip_; + const std::unique_ptr work_w_; }; } // namespace webrtc diff --git a/webrtc/common_audio/real_fourier_unittest.cc b/webrtc/common_audio/real_fourier_unittest.cc index eb5880ee8a..367fec3851 100644 --- a/webrtc/common_audio/real_fourier_unittest.cc +++ b/webrtc/common_audio/real_fourier_unittest.cc @@ -13,7 +13,6 @@ #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 eeda790497..31e08e3640 100644 --- a/webrtc/common_audio/resampler/include/push_resampler.h +++ b/webrtc/common_audio/resampler/include/push_resampler.h @@ -11,7 +11,8 @@ #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ #define WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ -#include "webrtc/base/scoped_ptr.h" +#include + #include "webrtc/typedefs.h" namespace webrtc { @@ -36,15 +37,15 @@ class PushResampler { int Resample(const T* src, size_t src_length, T* dst, size_t dst_capacity); private: - rtc::scoped_ptr sinc_resampler_; - rtc::scoped_ptr sinc_resampler_right_; + std::unique_ptr sinc_resampler_; + std::unique_ptr sinc_resampler_right_; int src_sample_rate_hz_; int dst_sample_rate_hz_; size_t num_channels_; - rtc::scoped_ptr src_left_; - rtc::scoped_ptr src_right_; - rtc::scoped_ptr dst_left_; - rtc::scoped_ptr dst_right_; + std::unique_ptr src_left_; + std::unique_ptr src_right_; + std::unique_ptr dst_left_; + std::unique_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 cefc62aa2a..2ba60cac9c 100644 --- a/webrtc/common_audio/resampler/push_sinc_resampler.h +++ b/webrtc/common_audio/resampler/push_sinc_resampler.h @@ -11,8 +11,9 @@ #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" @@ -56,8 +57,8 @@ class PushSincResampler : public SincResamplerCallback { friend class PushSincResamplerTest; SincResampler* get_resampler_for_testing() { return resampler_.get(); } - rtc::scoped_ptr resampler_; - rtc::scoped_ptr float_buffer_; + std::unique_ptr resampler_; + std::unique_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 17e3dba1e2..afb0963c3f 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; - 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]); + 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]); 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. - 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]); + 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]); // 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 0980e2d756..d8ea6df72f 100644 --- a/webrtc/common_audio/resampler/sinc_resampler.h +++ b/webrtc/common_audio/resampler/sinc_resampler.h @@ -14,9 +14,10 @@ #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" @@ -137,12 +138,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. - rtc::scoped_ptr kernel_storage_; - rtc::scoped_ptr kernel_pre_sinc_storage_; - rtc::scoped_ptr kernel_window_storage_; + std::unique_ptr kernel_storage_; + std::unique_ptr kernel_pre_sinc_storage_; + std::unique_ptr kernel_window_storage_; // Data from the source is copied into this buffer for each processing pass. - rtc::scoped_ptr input_buffer_; + std::unique_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 b8d6c341a2..42172ebdda 100644 --- a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc +++ b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc @@ -16,9 +16,10 @@ #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" @@ -62,7 +63,7 @@ TEST(SincResamplerTest, ChunkedResample) { static const int kChunks = 2; size_t max_chunk_size = resampler.ChunkSize() * kChunks; - rtc::scoped_ptr resampled_destination(new float[max_chunk_size]); + std::unique_ptr resampled_destination(new float[max_chunk_size]); // Verify requesting ChunkSize() frames causes a single callback. EXPECT_CALL(mock_source, Run(_, _)) @@ -81,7 +82,7 @@ TEST(SincResamplerTest, Flush) { MockSource mock_source; SincResampler resampler(kSampleRateRatio, SincResampler::kDefaultRequestSize, &mock_source); - rtc::scoped_ptr resampled_destination( + std::unique_ptr resampled_destination( new float[resampler.ChunkSize()]); // Fill the resampler with junk data. @@ -269,7 +270,7 @@ TEST_P(SincResamplerTest, Resample) { // Force an update to the sample rate ratio to ensure dyanmic sample rate // changes are working correctly. - rtc::scoped_ptr kernel(new float[SincResampler::kKernelStorageSize]); + std::unique_ptr kernel(new float[SincResampler::kKernelStorageSize]); memcpy(kernel.get(), resampler.get_kernel_for_testing(), SincResampler::kKernelStorageSize); resampler.SetRatio(M_PI); @@ -281,8 +282,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. - rtc::scoped_ptr resampled_destination(new float[output_samples]); - rtc::scoped_ptr pure_destination(new float[output_samples]); + std::unique_ptr resampled_destination(new float[output_samples]); + std::unique_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 f8cce74d9c..92c470a02d 100644 --- a/webrtc/common_audio/ring_buffer_unittest.cc +++ b/webrtc/common_audio/ring_buffer_unittest.cc @@ -12,10 +12,11 @@ #include #include + #include +#include #include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/base/scoped_ptr.h" namespace webrtc { @@ -24,7 +25,7 @@ struct FreeBufferDeleter { WebRtc_FreeBuffer(ptr); } }; -typedef rtc::scoped_ptr scoped_ring_buffer; +typedef std::unique_ptr scoped_ring_buffer; static void AssertElementEq(int expected, int actual) { ASSERT_EQ(expected, actual); @@ -58,8 +59,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); - rtc::scoped_ptr write_data(new int[buffer_size]); - rtc::scoped_ptr read_data(new int[buffer_size]); + std::unique_ptr write_data(new int[buffer_size]); + std::unique_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 82a53a5287..21b28ed34a 100644 --- a/webrtc/common_audio/sparse_fir_filter_unittest.cc +++ b/webrtc/common_audio/sparse_fir_filter_unittest.cc @@ -8,11 +8,12 @@ * 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 { @@ -214,9 +215,8 @@ TEST(SparseFIRFilterTest, SameOutputAsFIRFilterWhenSparsityOneAndOffsetZero) { const size_t kOffset = 0; float output[arraysize(kInput)]; float sparse_output[arraysize(kInput)]; - rtc::scoped_ptr filter(FIRFilter::Create(kCoeffs, - arraysize(kCoeffs), - arraysize(kInput))); + std::unique_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 0027c6687c..dbc04b7cf3 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -295,11 +295,11 @@ int AudioProcessingImpl::InitializeLocked() { formats_.rev_proc_format.num_channels(), rev_audio_buffer_out_num_frames)); if (rev_conversion_needed()) { - render_.render_converter = rtc::ScopedToUnique(AudioConverter::Create( + render_.render_converter = 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 25909b9008..46bb574c0b 100644 --- a/webrtc/modules/audio_processing/transient/transient_suppressor.cc +++ b/webrtc/modules/audio_processing/transient/transient_suppressor.cc @@ -17,6 +17,7 @@ #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" @@ -100,13 +101,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_) { - assert(false); + RTC_NOTREACHED(); return -1; } buffer_delay_ = analysis_length_ - data_length_; complex_analysis_length_ = analysis_length_ / 2 + 1; - assert(complex_analysis_length_ >= kMaxVoiceBin); + RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin); num_channels_ = num_channels; in_buffer_.reset(new float[analysis_length_ * num_channels_]); memset(in_buffer_.get(),