From b7f89d6e668602e46a20e3a9927790ff34029b2a Mon Sep 17 00:00:00 2001 From: kwiberg Date: Wed, 17 Feb 2016 10:04:18 -0800 Subject: [PATCH] Replace scoped_ptr with unique_ptr in webrtc/voice_engine/ Also introduce a pair of scoped_ptr <-> unique_ptr conversion functions. By using them judiciously, we can keep these CL:s small and avoid having to convert enormous amounts of code at once. BUG=webrtc:5520 Review URL: https://codereview.webrtc.org/1702983002 Cr-Commit-Position: refs/heads/master@{#11658} --- webrtc/audio/audio_receive_stream.cc | 5 +-- webrtc/audio/audio_send_stream.cc | 3 +- webrtc/base/scoped_ptr.h | 11 ++++++ webrtc/test/mock_voice_engine.h | 6 ++-- webrtc/voice_engine/channel.cc | 6 ++-- webrtc/voice_engine/channel.h | 35 ++++++++++--------- webrtc/voice_engine/channel_manager.cc | 2 +- webrtc/voice_engine/channel_manager.h | 6 ++-- webrtc/voice_engine/channel_proxy.cc | 2 +- webrtc/voice_engine/channel_proxy.h | 3 +- webrtc/voice_engine/network_predictor.h | 4 ++- .../network_predictor_unittest.cc | 4 ++- webrtc/voice_engine/shared_data.cc | 3 +- webrtc/voice_engine/shared_data.h | 7 ++-- .../auto_test/fakes/conference_transport.h | 6 ++-- .../fixtures/after_initialization_fixture.h | 6 ++-- .../auto_test/standard/rtp_rtcp_extensions.cc | 4 ++- .../test/auto_test/standard/rtp_rtcp_test.cc | 4 ++- .../test/auto_test/voe_cpu_test.cc | 5 +-- .../test/auto_test/voe_output_test.cc | 1 - .../test/auto_test/voe_stress_test.cc | 3 +- .../test/auto_test/voe_stress_test.h | 7 ++-- .../test/cmd_test/voe_cmd_test.cc | 4 +-- webrtc/voice_engine/transmit_mixer.cc | 4 ++- webrtc/voice_engine/transmit_mixer.h | 1 - webrtc/voice_engine/voe_codec_unittest.cc | 5 +-- webrtc/voice_engine/voice_engine_impl.cc | 4 +-- webrtc/voice_engine/voice_engine_impl.h | 7 ++-- 28 files changed, 94 insertions(+), 64 deletions(-) diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc index e8bc0f1857..9f19b32e59 100644 --- a/webrtc/audio/audio_receive_stream.cc +++ b/webrtc/audio/audio_receive_stream.cc @@ -93,7 +93,8 @@ AudioReceiveStream::AudioReceiveStream( RTC_DCHECK(rtp_header_parser_); VoiceEngineImpl* voe_impl = static_cast(voice_engine()); - channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); + channel_proxy_ = + rtc::UniqueToScoped(voe_impl->GetChannelProxy(config_.voe_channel_id)); channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc); for (const auto& extension : config.rtp.extensions) { if (extension.name == RtpExtension::kAudioLevel) { @@ -230,7 +231,7 @@ webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { void AudioReceiveStream::SetSink(rtc::scoped_ptr sink) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); - channel_proxy_->SetSink(std::move(sink)); + channel_proxy_->SetSink(rtc::ScopedToUnique(std::move(sink))); } const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc index 62121c63a5..f3696392c8 100644 --- a/webrtc/audio/audio_send_stream.cc +++ b/webrtc/audio/audio_send_stream.cc @@ -67,7 +67,8 @@ AudioSendStream::AudioSendStream( RTC_DCHECK(congestion_controller); VoiceEngineImpl* voe_impl = static_cast(voice_engine()); - channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); + channel_proxy_ = + rtc::UniqueToScoped(voe_impl->GetChannelProxy(config_.voe_channel_id)); channel_proxy_->RegisterSenderCongestionControlObjects( congestion_controller->pacer(), congestion_controller->GetTransportFeedbackObserver(), diff --git a/webrtc/base/scoped_ptr.h b/webrtc/base/scoped_ptr.h index d6aedfc198..955bcfeab4 100644 --- a/webrtc/base/scoped_ptr.h +++ b/webrtc/base/scoped_ptr.h @@ -88,6 +88,7 @@ #include // For std::swap(). #include +#include #include "webrtc/base/constructormagic.h" #include "webrtc/base/deprecation.h" @@ -605,6 +606,16 @@ void swap(rtc::scoped_ptr& p1, rtc::scoped_ptr& p2) { p1.swap(p2); } +// Convert between the most common kinds of scoped_ptr and unique_ptr. +template +std::unique_ptr ScopedToUnique(scoped_ptr sp) { + return std::unique_ptr(sp.release()); +} +template +scoped_ptr UniqueToScoped(std::unique_ptr up) { + return scoped_ptr(up.release()); +} + } // namespace rtc template diff --git a/webrtc/test/mock_voice_engine.h b/webrtc/test/mock_voice_engine.h index 28a75f8063..887dd35305 100644 --- a/webrtc/test/mock_voice_engine.h +++ b/webrtc/test/mock_voice_engine.h @@ -11,6 +11,8 @@ #ifndef WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ #define WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ +#include + #include "testing/gmock/include/gmock/gmock.h" #include "webrtc/test/mock_voe_channel_proxy.h" #include "webrtc/voice_engine/voice_engine_impl.h" @@ -43,8 +45,8 @@ class MockVoiceEngine : public VoiceEngineImpl { MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); // VoiceEngineImpl - rtc::scoped_ptr GetChannelProxy(int channel_id) override { - return rtc::scoped_ptr(ChannelProxyFactory(channel_id)); + std::unique_ptr GetChannelProxy(int channel_id) override { + return std::unique_ptr(ChannelProxyFactory(channel_id)); } // VoEAudioProcessing diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index c078d20a91..9e27ce8b7b 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -1071,7 +1071,7 @@ int32_t Channel::UpdateLocalTimeStamp() { return 0; } -void Channel::SetSink(rtc::scoped_ptr sink) { +void Channel::SetSink(std::unique_ptr sink) { rtc::CritScope cs(&_callbackCritSect); audio_sink_ = std::move(sink); } @@ -3265,7 +3265,7 @@ int Channel::GetRtpRtcp(RtpRtcp** rtpRtcpModule, // TODO(andrew): refactor Mix functions here and in transmit_mixer.cc to use // a shared helper. int32_t Channel::MixOrReplaceAudioWithFile(int mixingFrequency) { - rtc::scoped_ptr fileBuffer(new int16_t[640]); + std::unique_ptr fileBuffer(new int16_t[640]); size_t fileSamples(0); { @@ -3313,7 +3313,7 @@ int32_t Channel::MixOrReplaceAudioWithFile(int mixingFrequency) { int32_t Channel::MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency) { assert(mixingFrequency <= 48000); - rtc::scoped_ptr fileBuffer(new int16_t[960]); + std::unique_ptr fileBuffer(new int16_t[960]); size_t fileSamples(0); { diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index 60c751e0d5..0e87252877 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -11,9 +11,10 @@ #ifndef WEBRTC_VOICE_ENGINE_CHANNEL_H_ #define WEBRTC_VOICE_ENGINE_CHANNEL_H_ +#include + #include "webrtc/audio/audio_sink.h" #include "webrtc/base/criticalsection.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/resampler/include/push_resampler.h" #include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h" @@ -193,7 +194,7 @@ class Channel rtc::CriticalSection* callbackCritSect); int32_t UpdateLocalTimeStamp(); - void SetSink(rtc::scoped_ptr sink); + void SetSink(std::unique_ptr sink); // API methods @@ -493,15 +494,15 @@ class Channel RtcEventLog* const event_log_; - rtc::scoped_ptr rtp_header_parser_; - rtc::scoped_ptr rtp_payload_registry_; - rtc::scoped_ptr rtp_receive_statistics_; - rtc::scoped_ptr statistics_proxy_; - rtc::scoped_ptr rtp_receiver_; + std::unique_ptr rtp_header_parser_; + std::unique_ptr rtp_payload_registry_; + std::unique_ptr rtp_receive_statistics_; + std::unique_ptr statistics_proxy_; + std::unique_ptr rtp_receiver_; TelephoneEventHandler* telephone_event_handler_; - rtc::scoped_ptr _rtpRtcpModule; - rtc::scoped_ptr audio_coding_; - rtc::scoped_ptr audio_sink_; + std::unique_ptr _rtpRtcpModule; + std::unique_ptr audio_coding_; + std::unique_ptr audio_sink_; AudioLevel _outputAudioLevel; bool _externalTransport; AudioFrame _audioFrame; @@ -535,7 +536,7 @@ class Channel rtc::CriticalSection ts_stats_lock_; - rtc::scoped_ptr rtp_ts_wraparound_handler_; + std::unique_ptr rtp_ts_wraparound_handler_; // The rtp timestamp of the first played out audio frame. int64_t capture_start_rtp_time_stamp_; // The capture ntp time (in local timebase) of the first played out audio @@ -552,7 +553,7 @@ class Channel rtc::CriticalSection* _callbackCritSectPtr; // owned by base Transport* _transportPtr; // WebRtc socket or external transport RMSLevel rms_level_; - rtc::scoped_ptr rx_audioproc_; // far end AudioProcessing + std::unique_ptr rx_audioproc_; // far end AudioProcessing VoERxVadCallback* _rxVadObserverPtr; int32_t _oldVadDecision; int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise @@ -584,17 +585,17 @@ class Channel bool _rxNsIsEnabled; bool restored_packet_in_use_; // RtcpBandwidthObserver - rtc::scoped_ptr rtcp_observer_; - rtc::scoped_ptr network_predictor_; + std::unique_ptr rtcp_observer_; + std::unique_ptr network_predictor_; // An associated send channel. rtc::CriticalSection assoc_send_channel_lock_; ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_); bool pacing_enabled_; PacketRouter* packet_router_ = nullptr; - rtc::scoped_ptr feedback_observer_proxy_; - rtc::scoped_ptr seq_num_allocator_proxy_; - rtc::scoped_ptr rtp_packet_sender_proxy_; + std::unique_ptr feedback_observer_proxy_; + std::unique_ptr seq_num_allocator_proxy_; + std::unique_ptr rtp_packet_sender_proxy_; }; } // namespace voe diff --git a/webrtc/voice_engine/channel_manager.cc b/webrtc/voice_engine/channel_manager.cc index eac2e50919..96f6d2b2ee 100644 --- a/webrtc/voice_engine/channel_manager.cc +++ b/webrtc/voice_engine/channel_manager.cc @@ -49,7 +49,7 @@ ChannelManager::ChannelManager(uint32_t instance_id, const Config& config) : instance_id_(instance_id), last_channel_id_(-1), config_(config), - event_log_(RtcEventLog::Create()) {} + event_log_(rtc::ScopedToUnique(RtcEventLog::Create())) {} ChannelOwner ChannelManager::CreateChannel() { return CreateChannelInternal(config_); diff --git a/webrtc/voice_engine/channel_manager.h b/webrtc/voice_engine/channel_manager.h index 7c86959097..77dfc454d8 100644 --- a/webrtc/voice_engine/channel_manager.h +++ b/webrtc/voice_engine/channel_manager.h @@ -11,11 +11,11 @@ #ifndef WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H #define WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H +#include #include #include "webrtc/base/constructormagic.h" #include "webrtc/base/criticalsection.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/call/rtc_event_log.h" #include "webrtc/system_wrappers/include/atomic32.h" #include "webrtc/typedefs.h" @@ -62,7 +62,7 @@ class ChannelOwner { // deleted when no references to them are held. struct ChannelRef { ChannelRef(Channel* channel); - const rtc::scoped_ptr channel; + const std::unique_ptr channel; Atomic32 ref_count; }; @@ -127,7 +127,7 @@ class ChannelManager { std::vector channels_; const Config& config_; - rtc::scoped_ptr event_log_; + std::unique_ptr event_log_; RTC_DISALLOW_COPY_AND_ASSIGN(ChannelManager); }; diff --git a/webrtc/voice_engine/channel_proxy.cc b/webrtc/voice_engine/channel_proxy.cc index 1e2281aef4..3beaf9b294 100644 --- a/webrtc/voice_engine/channel_proxy.cc +++ b/webrtc/voice_engine/channel_proxy.cc @@ -155,7 +155,7 @@ bool ChannelProxy::SendTelephoneEventOutband(uint8_t event, channel()->SendTelephoneEventOutband(event, duration_ms, 10, false) == 0; } -void ChannelProxy::SetSink(rtc::scoped_ptr sink) { +void ChannelProxy::SetSink(std::unique_ptr sink) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); channel()->SetSink(std::move(sink)); } diff --git a/webrtc/voice_engine/channel_proxy.h b/webrtc/voice_engine/channel_proxy.h index 9d6839c8de..3461cf3e78 100644 --- a/webrtc/voice_engine/channel_proxy.h +++ b/webrtc/voice_engine/channel_proxy.h @@ -15,6 +15,7 @@ #include "webrtc/voice_engine/channel_manager.h" #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" +#include #include #include @@ -69,7 +70,7 @@ class ChannelProxy { virtual bool SetSendTelephoneEventPayloadType(int payload_type); virtual bool SendTelephoneEventOutband(uint8_t event, uint32_t duration_ms); - virtual void SetSink(rtc::scoped_ptr sink); + virtual void SetSink(std::unique_ptr sink); private: Channel* channel() const; diff --git a/webrtc/voice_engine/network_predictor.h b/webrtc/voice_engine/network_predictor.h index b35ccd8756..bf08fe98ce 100644 --- a/webrtc/voice_engine/network_predictor.h +++ b/webrtc/voice_engine/network_predictor.h @@ -11,6 +11,8 @@ #ifndef WEBRTC_VOICE_ENGINE_NETWORK_PREDICTOR_H_ #define WEBRTC_VOICE_ENGINE_NETWORK_PREDICTOR_H_ +#include + #include "webrtc/base/exp_filter.h" #include "webrtc/system_wrappers/include/clock.h" @@ -38,7 +40,7 @@ class NetworkPredictor { int64_t last_loss_rate_update_time_ms_; // An exponential filter is used to predict packet loss rate. - rtc::scoped_ptr loss_rate_filter_; + std::unique_ptr loss_rate_filter_; }; } // namespace voe diff --git a/webrtc/voice_engine/network_predictor_unittest.cc b/webrtc/voice_engine/network_predictor_unittest.cc index 28ff57fb49..1471f4629b 100644 --- a/webrtc/voice_engine/network_predictor_unittest.cc +++ b/webrtc/voice_engine/network_predictor_unittest.cc @@ -10,6 +10,8 @@ #include +#include + #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/voice_engine/network_predictor.h" #include "webrtc/system_wrappers/include/clock.h" @@ -23,7 +25,7 @@ class TestNetworkPredictor : public ::testing::Test { : clock_(0), network_predictor_(new NetworkPredictor(&clock_)) {} SimulatedClock clock_; - rtc::scoped_ptr network_predictor_; + std::unique_ptr network_predictor_; }; TEST_F(TestNetworkPredictor, TestPacketLossRateFilter) { diff --git a/webrtc/voice_engine/shared_data.cc b/webrtc/voice_engine/shared_data.cc index 1d50c3c0bf..b21578c927 100644 --- a/webrtc/voice_engine/shared_data.cc +++ b/webrtc/voice_engine/shared_data.cc @@ -27,7 +27,8 @@ SharedData::SharedData(const Config& config) _channelManager(_gInstanceCounter, config), _engineStatistics(_gInstanceCounter), _audioDevicePtr(NULL), - _moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")) { + _moduleProcessThreadPtr( + rtc::ScopedToUnique(ProcessThread::Create("VoiceProcessThread"))) { Trace::CreateTrace(); if (OutputMixer::Create(_outputMixerPtr, _gInstanceCounter) == 0) { diff --git a/webrtc/voice_engine/shared_data.h b/webrtc/voice_engine/shared_data.h index 1d96103a98..a4a852a435 100644 --- a/webrtc/voice_engine/shared_data.h +++ b/webrtc/voice_engine/shared_data.h @@ -11,8 +11,9 @@ #ifndef WEBRTC_VOICE_ENGINE_SHARED_DATA_H #define WEBRTC_VOICE_ENGINE_SHARED_DATA_H +#include + #include "webrtc/base/criticalsection.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/audio_device/include/audio_device.h" #include "webrtc/modules/audio_processing/include/audio_processing.h" #include "webrtc/modules/utility/include/process_thread.h" @@ -69,8 +70,8 @@ protected: AudioDeviceModule* _audioDevicePtr; OutputMixer* _outputMixerPtr; TransmitMixer* _transmitMixerPtr; - rtc::scoped_ptr audioproc_; - rtc::scoped_ptr _moduleProcessThreadPtr; + std::unique_ptr audioproc_; + std::unique_ptr _moduleProcessThreadPtr; AudioDeviceModule::AudioLayer _audioDeviceLayer; diff --git a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h index cce6148f7e..8fd7457711 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h +++ b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h @@ -13,13 +13,13 @@ #include #include +#include #include #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/basictypes.h" #include "webrtc/base/criticalsection.h" #include "webrtc/base/platform_thread.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_types.h" #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" #include "webrtc/system_wrappers/include/event_wrapper.h" @@ -130,7 +130,7 @@ class ConferenceTransport: public webrtc::Transport { rtc::CriticalSection pq_crit_; rtc::CriticalSection stream_crit_; - const rtc::scoped_ptr packet_event_; + const std::unique_ptr packet_event_; rtc::PlatformThread thread_; unsigned int rtt_ms_; @@ -156,7 +156,7 @@ class ConferenceTransport: public webrtc::Transport { LoudestFilter loudest_filter_; - const rtc::scoped_ptr rtp_header_parser_; + const std::unique_ptr rtp_header_parser_; }; } // namespace voetest diff --git a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h index 46b7abf097..66086695d2 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h +++ b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h @@ -12,10 +12,10 @@ #define SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ #include +#include #include "webrtc/base/criticalsection.h" #include "webrtc/base/platform_thread.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_types.h" #include "webrtc/modules/rtp_rtcp/source/byte_io.h" #include "webrtc/system_wrappers/include/atomic32.h" @@ -143,7 +143,7 @@ class LoopBackTransport : public webrtc::Transport { } rtc::CriticalSection crit_; - const rtc::scoped_ptr packet_event_; + const std::unique_ptr packet_event_; rtc::PlatformThread thread_; std::deque packet_queue_ GUARDED_BY(crit_); const int channel_; @@ -163,7 +163,7 @@ class AfterInitializationFixture : public BeforeInitializationFixture { virtual ~AfterInitializationFixture(); protected: - rtc::scoped_ptr error_observer_; + std::unique_ptr error_observer_; }; #endif // SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ diff --git a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc index 1dc15dff49..16f17b1340 100644 --- a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc +++ b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" #include "webrtc/system_wrappers/include/atomic32.h" @@ -83,7 +85,7 @@ class ExtensionVerifyTransport : public webrtc::Transport { kPacketsExpected = 10, kSleepIntervalMs = 10 }; - rtc::scoped_ptr parser_; + std::unique_ptr parser_; webrtc::Atomic32 received_packets_; webrtc::Atomic32 bad_packets_; int audio_level_id_; diff --git a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc index d653cc1297..eeb7fa515a 100644 --- a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "webrtc/base/criticalsection.h" #include "webrtc/system_wrappers/include/atomic32.h" #include "webrtc/system_wrappers/include/event_wrapper.h" @@ -35,7 +37,7 @@ class TestRtpObserver : public webrtc::VoERTPObserver { public: rtc::CriticalSection crit_; unsigned int incoming_ssrc_; - rtc::scoped_ptr changed_ssrc_event_; + std::unique_ptr changed_ssrc_event_; }; void TestRtpObserver::OnIncomingSSRCChanged(int channel, diff --git a/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc b/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc index 5666b3f8d1..3bf51aa0ff 100644 --- a/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc @@ -17,7 +17,8 @@ #include #endif -#include "webrtc/base/scoped_ptr.h" +#include + #include "webrtc/test/channel_transport/channel_transport.h" #include "webrtc/voice_engine/test/auto_test/voe_test_defines.h" @@ -64,7 +65,7 @@ int VoECpuTest::DoTest() { CHECK(base->Init()); channel = base->CreateChannel(); - rtc::scoped_ptr voice_socket_transport( + std::unique_ptr voice_socket_transport( new VoiceChannelTransport(voe_network, channel)); CHECK(voice_socket_transport->SetSendDestination("127.0.0.1", 5566)); diff --git a/webrtc/voice_engine/test/auto_test/voe_output_test.cc b/webrtc/voice_engine/test/auto_test/voe_output_test.cc index 3bedbc3b17..d1bcf968b0 100644 --- a/webrtc/voice_engine/test/auto_test/voe_output_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_output_test.cc @@ -10,7 +10,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/random.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/timeutils.h" #include "webrtc/system_wrappers/include/sleep.h" #include "webrtc/test/channel_transport/channel_transport.h" diff --git a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc index 259eff0ccc..0b5660ff54 100644 --- a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc @@ -24,7 +24,6 @@ #include "webrtc/voice_engine/test/auto_test/voe_stress_test.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/include/sleep.h" #include "webrtc/test/channel_transport/channel_transport.h" #include "webrtc/voice_engine/test/auto_test/voe_standard_test.h" @@ -144,7 +143,7 @@ int VoEStressTest::StartStopTest() { printf("Test will take approximately %d minutes. \n", numberOfLoops * loopSleep / 1000 / 60 + 1); - rtc::scoped_ptr voice_channel_transport( + std::unique_ptr voice_channel_transport( new VoiceChannelTransport(voe_network, 0)); for (i = 0; i < numberOfLoops; ++i) { diff --git a/webrtc/voice_engine/test/auto_test/voe_stress_test.h b/webrtc/voice_engine/test/auto_test/voe_stress_test.h index 715e8ef724..1c913068ea 100644 --- a/webrtc/voice_engine/test/auto_test/voe_stress_test.h +++ b/webrtc/voice_engine/test/auto_test/voe_stress_test.h @@ -11,8 +11,9 @@ #ifndef WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H #define WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H +#include + #include "webrtc/base/platform_thread.h" -#include "webrtc/base/scoped_ptr.h" namespace voetest { @@ -37,8 +38,8 @@ class VoEStressTest { VoETestManager& _mgr; - // TODO(pbos): Remove scoped_ptr and use PlatformThread directly. - rtc::scoped_ptr _ptrExtraApiThread; + // TODO(pbos): Remove unique_ptr and use PlatformThread directly. + std::unique_ptr _ptrExtraApiThread; }; } // namespace voetest diff --git a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc index ccfe3c2bde..bfc8b6537e 100644 --- a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc +++ b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc @@ -15,12 +15,12 @@ #include #endif +#include #include #include "gflags/gflags.h" #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/format_macros.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/call/rtc_event_log.h" #include "webrtc/engine_configurations.h" #include "webrtc/modules/audio_processing/include/audio_processing.h" @@ -142,7 +142,7 @@ int main(int argc, char** argv) { MyObserver my_observer; - rtc::scoped_ptr trace_to_stderr; + std::unique_ptr trace_to_stderr; if (!FLAGS_use_log_file) { trace_to_stderr.reset(new test::TraceToStderr); } else { diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc index 14903501f6..d6a5213217 100644 --- a/webrtc/voice_engine/transmit_mixer.cc +++ b/webrtc/voice_engine/transmit_mixer.cc @@ -10,6 +10,8 @@ #include "webrtc/voice_engine/transmit_mixer.h" +#include + #include "webrtc/base/format_macros.h" #include "webrtc/base/logging.h" #include "webrtc/modules/utility/include/audio_frame_operations.h" @@ -1180,7 +1182,7 @@ int32_t TransmitMixer::RecordAudioToFile( int32_t TransmitMixer::MixOrReplaceAudioWithFile( int mixingFrequency) { - rtc::scoped_ptr fileBuffer(new int16_t[640]); + std::unique_ptr fileBuffer(new int16_t[640]); size_t fileSamples(0); { diff --git a/webrtc/voice_engine/transmit_mixer.h b/webrtc/voice_engine/transmit_mixer.h index e0246cf4ce..b5c483aa4b 100644 --- a/webrtc/voice_engine/transmit_mixer.h +++ b/webrtc/voice_engine/transmit_mixer.h @@ -12,7 +12,6 @@ #define WEBRTC_VOICE_ENGINE_TRANSMIT_MIXER_H #include "webrtc/base/criticalsection.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/resampler/include/push_resampler.h" #include "webrtc/common_types.h" #include "webrtc/modules/audio_processing/typing_detection.h" diff --git a/webrtc/voice_engine/voe_codec_unittest.cc b/webrtc/voice_engine/voe_codec_unittest.cc index f09e19e685..73e576bf51 100644 --- a/webrtc/voice_engine/voe_codec_unittest.cc +++ b/webrtc/voice_engine/voe_codec_unittest.cc @@ -8,10 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "webrtc/voice_engine/include/voe_codec.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/audio_device/include/fake_audio_device.h" #include "webrtc/voice_engine/include/voe_base.h" #include "webrtc/voice_engine/include/voe_hardware.h" @@ -93,7 +94,7 @@ class VoECodecTest : public ::testing::Test { int channel_; CodecInst primary_; CodecInst valid_secondary_; - rtc::scoped_ptr adm_; + std::unique_ptr adm_; // A codec which is not valid to be registered as secondary codec. CodecInst invalid_secondary_; diff --git a/webrtc/voice_engine/voice_engine_impl.cc b/webrtc/voice_engine/voice_engine_impl.cc index d0b7412076..919d0e8efd 100644 --- a/webrtc/voice_engine/voice_engine_impl.cc +++ b/webrtc/voice_engine/voice_engine_impl.cc @@ -62,12 +62,12 @@ int VoiceEngineImpl::Release() { return new_ref; } -rtc::scoped_ptr VoiceEngineImpl::GetChannelProxy( +std::unique_ptr VoiceEngineImpl::GetChannelProxy( int channel_id) { RTC_DCHECK(channel_id >= 0); rtc::CritScope cs(crit_sec()); RTC_DCHECK(statistics().Initialized()); - return rtc::scoped_ptr( + return std::unique_ptr( new voe::ChannelProxy(channel_manager().GetChannel(channel_id))); } diff --git a/webrtc/voice_engine/voice_engine_impl.h b/webrtc/voice_engine/voice_engine_impl.h index f98f881214..ed6efe3d9e 100644 --- a/webrtc/voice_engine/voice_engine_impl.h +++ b/webrtc/voice_engine/voice_engine_impl.h @@ -11,7 +11,8 @@ #ifndef WEBRTC_VOICE_ENGINE_VOICE_ENGINE_IMPL_H #define WEBRTC_VOICE_ENGINE_VOICE_ENGINE_IMPL_H -#include "webrtc/base/scoped_ptr.h" +#include + #include "webrtc/engine_configurations.h" #include "webrtc/system_wrappers/include/atomic32.h" #include "webrtc/voice_engine/voe_base_impl.h" @@ -134,14 +135,14 @@ class VoiceEngineImpl : public voe::SharedData, // Must be the first base class // Backdoor to access a voe::Channel object without a channel ID. This is only // to be used while refactoring the VoE API! - virtual rtc::scoped_ptr GetChannelProxy(int channel_id); + virtual std::unique_ptr GetChannelProxy(int channel_id); // This is *protected* so that FakeVoiceEngine can inherit from the class and // manipulate the reference count. See: fake_voice_engine.h. protected: Atomic32 _ref_count; private: - rtc::scoped_ptr own_config_; + std::unique_ptr own_config_; }; } // namespace webrtc