From a35ae7f507cc4e909dd4253106c97528db315adb Mon Sep 17 00:00:00 2001 From: tfarina Date: Thu, 29 Oct 2015 04:50:08 -0700 Subject: [PATCH] Fix chromium-style warnings in webrtc/sound/. Tested on Linux with the following command lines: $ ./webrtc/build/gyp_webrtc -Dclang_use_chrome_plugins=1 $ ninja -C out/Release rtc_sound BUG=webrtc:163 R=perkj@webrtc.org Review URL: https://codereview.webrtc.org/1425533003 Cr-Commit-Position: refs/heads/master@{#10447} --- webrtc/sound/alsasoundsystem.cc | 50 +++++++++++----------- webrtc/sound/alsasoundsystem.h | 24 +++++------ webrtc/sound/nullsoundsystem.cc | 31 ++++++-------- webrtc/sound/nullsoundsystem.h | 24 +++++------ webrtc/sound/nullsoundsystemfactory.h | 6 +-- webrtc/sound/platformsoundsystemfactory.h | 8 ++-- webrtc/sound/sound.gyp | 2 + webrtc/sound/soundinputstreaminterface.cc | 18 ++++++++ webrtc/sound/soundinputstreaminterface.h | 4 +- webrtc/sound/soundoutputstreaminterface.cc | 19 ++++++++ webrtc/sound/soundoutputstreaminterface.h | 4 +- webrtc/sound/soundsystemproxy.h | 16 +++---- 12 files changed, 119 insertions(+), 87 deletions(-) create mode 100644 webrtc/sound/soundinputstreaminterface.cc create mode 100644 webrtc/sound/soundoutputstreaminterface.cc diff --git a/webrtc/sound/alsasoundsystem.cc b/webrtc/sound/alsasoundsystem.cc index d96db0b046..3cc77a988c 100644 --- a/webrtc/sound/alsasoundsystem.cc +++ b/webrtc/sound/alsasoundsystem.cc @@ -62,7 +62,7 @@ class AlsaDeviceLocator : public SoundDeviceLocator { &name_); } - virtual SoundDeviceLocator *Copy() const { + SoundDeviceLocator *Copy() const override { return new AlsaDeviceLocator(*this); } }; @@ -242,46 +242,46 @@ class AlsaInputStream : buffer_size_(0) { } - virtual ~AlsaInputStream() { + ~AlsaInputStream() override { bool success = StopReading(); // We need that to live. VERIFY(success); } - virtual bool StartReading() { + bool StartReading() override { return StartWork(); } - virtual bool StopReading() { + bool StopReading() override { return StopWork(); } - virtual bool GetVolume(int *volume) { + bool GetVolume(int *volume) override { // TODO: Implement this. return false; } - virtual bool SetVolume(int volume) { + bool SetVolume(int volume) override { // TODO: Implement this. return false; } - virtual bool Close() { + bool Close() override { return StopReading() && stream_.Close(); } - virtual int LatencyUsecs() { + int LatencyUsecs() override { return stream_.CurrentDelayUsecs(); } private: // Inherited from Worker. - virtual void OnStart() { + void OnStart() override { HaveWork(); } // Inherited from Worker. - virtual void OnHaveWork() { + void OnHaveWork() override { // Block waiting for data. snd_pcm_uframes_t avail = stream_.Wait(); if (avail > 0) { @@ -317,7 +317,7 @@ class AlsaInputStream : } // Inherited from Worker. - virtual void OnStop() { + void OnStop() override { // Nothing to do. } @@ -334,9 +334,8 @@ class AlsaInputStream : // Implementation of an output stream. See soundoutputstreaminterface.h // regarding thread-safety. -class AlsaOutputStream : - public SoundOutputStreamInterface, - private rtc::Worker { +class AlsaOutputStream : public SoundOutputStreamInterface, + private rtc::Worker { public: AlsaOutputStream(AlsaSoundSystem *alsa, snd_pcm_t *handle, @@ -347,22 +346,21 @@ class AlsaOutputStream : : stream_(alsa, handle, frame_size, wait_timeout_ms, flags, freq) { } - virtual ~AlsaOutputStream() { + ~AlsaOutputStream() override { bool success = DisableBufferMonitoring(); // We need that to live. VERIFY(success); } - virtual bool EnableBufferMonitoring() { + bool EnableBufferMonitoring() override { return StartWork(); } - virtual bool DisableBufferMonitoring() { + bool DisableBufferMonitoring() override { return StopWork(); } - virtual bool WriteSamples(const void *sample_data, - size_t size) { + bool WriteSamples(const void *sample_data, size_t size) override { if (size % stream_.frame_size() != 0) { // No client of SoundSystemInterface does this, so let's not support it. // (If we wanted to support it, we'd basically just buffer the fractional @@ -389,32 +387,32 @@ class AlsaOutputStream : return true; } - virtual bool GetVolume(int *volume) { + bool GetVolume(int *volume) override { // TODO: Implement this. return false; } - virtual bool SetVolume(int volume) { + bool SetVolume(int volume) override { // TODO: Implement this. return false; } - virtual bool Close() { + bool Close() override { return DisableBufferMonitoring() && stream_.Close(); } - virtual int LatencyUsecs() { + int LatencyUsecs() override { return stream_.CurrentDelayUsecs(); } private: // Inherited from Worker. - virtual void OnStart() { + void OnStart() override { HaveWork(); } // Inherited from Worker. - virtual void OnHaveWork() { + void OnHaveWork() override { snd_pcm_uframes_t avail = stream_.Wait(); if (avail > 0) { size_t space = avail * stream_.frame_size(); @@ -424,7 +422,7 @@ class AlsaOutputStream : } // Inherited from Worker. - virtual void OnStop() { + void OnStop() override { // Nothing to do. } diff --git a/webrtc/sound/alsasoundsystem.h b/webrtc/sound/alsasoundsystem.h index b0cc1a4029..dbf34d178b 100644 --- a/webrtc/sound/alsasoundsystem.h +++ b/webrtc/sound/alsasoundsystem.h @@ -34,25 +34,25 @@ class AlsaSoundSystem : public SoundSystemInterface { AlsaSoundSystem(); - virtual ~AlsaSoundSystem(); + ~AlsaSoundSystem() override; - virtual bool Init(); - virtual void Terminate(); + bool Init() override; + void Terminate() override; - virtual bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices); - virtual bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices); + bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices) override; + bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices) override; - virtual bool GetDefaultPlaybackDevice(SoundDeviceLocator **device); - virtual bool GetDefaultCaptureDevice(SoundDeviceLocator **device); + bool GetDefaultPlaybackDevice(SoundDeviceLocator **device) override; + bool GetDefaultCaptureDevice(SoundDeviceLocator **device) override; - virtual SoundOutputStreamInterface *OpenPlaybackDevice( + SoundOutputStreamInterface *OpenPlaybackDevice( const SoundDeviceLocator *device, - const OpenParams ¶ms); - virtual SoundInputStreamInterface *OpenCaptureDevice( + const OpenParams ¶ms) override; + SoundInputStreamInterface *OpenCaptureDevice( const SoundDeviceLocator *device, - const OpenParams ¶ms); + const OpenParams ¶ms) override; - virtual const char *GetName() const; + const char *GetName() const override; private: bool IsInitialized() { return initialized_; } diff --git a/webrtc/sound/nullsoundsystem.cc b/webrtc/sound/nullsoundsystem.cc index 962f410572..6f908c9fc3 100644 --- a/webrtc/sound/nullsoundsystem.cc +++ b/webrtc/sound/nullsoundsystem.cc @@ -16,9 +16,7 @@ #include "webrtc/base/logging.h" namespace rtc { - class Thread; - } namespace rtc { @@ -30,69 +28,68 @@ class NullSoundDeviceLocator : public SoundDeviceLocator { public: NullSoundDeviceLocator() : SoundDeviceLocator(kNullName, kNullName) {} - virtual SoundDeviceLocator *Copy() const { + SoundDeviceLocator *Copy() const override { return new NullSoundDeviceLocator(); } }; class NullSoundInputStream : public SoundInputStreamInterface { public: - virtual bool StartReading() { + bool StartReading() override { return true; } - virtual bool StopReading() { + bool StopReading() override { return true; } - virtual bool GetVolume(int *volume) { + bool GetVolume(int *volume) override { *volume = SoundSystemInterface::kMinVolume; return true; } - virtual bool SetVolume(int volume) { + bool SetVolume(int volume) override { return false; } - virtual bool Close() { + bool Close() override { return true; } - virtual int LatencyUsecs() { + int LatencyUsecs() override { return 0; } }; class NullSoundOutputStream : public SoundOutputStreamInterface { public: - virtual bool EnableBufferMonitoring() { + bool EnableBufferMonitoring() override { return true; } - virtual bool DisableBufferMonitoring() { + bool DisableBufferMonitoring() override { return true; } - virtual bool WriteSamples(const void *sample_data, - size_t size) { + bool WriteSamples(const void *sample_data, size_t size) override { LOG(LS_VERBOSE) << "Got " << size << " bytes of playback samples"; return true; } - virtual bool GetVolume(int *volume) { + bool GetVolume(int *volume) override { *volume = SoundSystemInterface::kMinVolume; return true; } - virtual bool SetVolume(int volume) { + bool SetVolume(int volume) override { return false; } - virtual bool Close() { + bool Close() override { return true; } - virtual int LatencyUsecs() { + int LatencyUsecs() override { return 0; } }; diff --git a/webrtc/sound/nullsoundsystem.h b/webrtc/sound/nullsoundsystem.h index 6b74997665..08ffad1015 100644 --- a/webrtc/sound/nullsoundsystem.h +++ b/webrtc/sound/nullsoundsystem.h @@ -27,25 +27,25 @@ class NullSoundSystem : public SoundSystemInterface { return new NullSoundSystem(); } - virtual ~NullSoundSystem(); + ~NullSoundSystem() override; - virtual bool Init(); - virtual void Terminate(); + bool Init() override; + void Terminate() override; - virtual bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices); - virtual bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices); + bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices) override; + bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices) override; - virtual SoundOutputStreamInterface *OpenPlaybackDevice( + SoundOutputStreamInterface *OpenPlaybackDevice( const SoundDeviceLocator *device, - const OpenParams ¶ms); - virtual SoundInputStreamInterface *OpenCaptureDevice( + const OpenParams ¶ms) override; + SoundInputStreamInterface *OpenCaptureDevice( const SoundDeviceLocator *device, - const OpenParams ¶ms); + const OpenParams ¶ms) override; - virtual bool GetDefaultPlaybackDevice(SoundDeviceLocator **device); - virtual bool GetDefaultCaptureDevice(SoundDeviceLocator **device); + bool GetDefaultPlaybackDevice(SoundDeviceLocator **device) override; + bool GetDefaultCaptureDevice(SoundDeviceLocator **device) override; - virtual const char *GetName() const; + const char *GetName() const override; }; } // namespace rtc diff --git a/webrtc/sound/nullsoundsystemfactory.h b/webrtc/sound/nullsoundsystemfactory.h index 8bdb46394b..a14490cfe9 100644 --- a/webrtc/sound/nullsoundsystemfactory.h +++ b/webrtc/sound/nullsoundsystemfactory.h @@ -20,12 +20,12 @@ namespace rtc { class NullSoundSystemFactory : public SoundSystemFactory { public: NullSoundSystemFactory(); - virtual ~NullSoundSystemFactory(); + ~NullSoundSystemFactory() override; protected: // Inherited from SoundSystemFactory. - virtual bool SetupInstance(); - virtual void CleanupInstance(); + bool SetupInstance() override; + void CleanupInstance() override; }; } // namespace rtc diff --git a/webrtc/sound/platformsoundsystemfactory.h b/webrtc/sound/platformsoundsystemfactory.h index c5105ef051..5319fa50b6 100644 --- a/webrtc/sound/platformsoundsystemfactory.h +++ b/webrtc/sound/platformsoundsystemfactory.h @@ -20,16 +20,14 @@ namespace rtc { class PlatformSoundSystemFactory : public SoundSystemFactory { public: PlatformSoundSystemFactory(); - virtual ~PlatformSoundSystemFactory(); + ~PlatformSoundSystemFactory() override; protected: // Inherited from SoundSystemFactory. - virtual bool SetupInstance(); - virtual void CleanupInstance(); + bool SetupInstance() override; + void CleanupInstance() override; }; } // namespace rtc #endif // WEBRTC_SOUND_PLATFORMSOUNDSYSTEMFACTORY_H_ - - diff --git a/webrtc/sound/sound.gyp b/webrtc/sound/sound.gyp index a7d929b25d..e09215371b 100644 --- a/webrtc/sound/sound.gyp +++ b/webrtc/sound/sound.gyp @@ -26,7 +26,9 @@ 'platformsoundsystemfactory.cc', 'platformsoundsystemfactory.h', 'sounddevicelocator.h', + 'soundinputstreaminterface.cc', 'soundinputstreaminterface.h', + 'soundoutputstreaminterface.cc', 'soundoutputstreaminterface.h', 'soundsystemfactory.h', 'soundsysteminterface.cc', diff --git a/webrtc/sound/soundinputstreaminterface.cc b/webrtc/sound/soundinputstreaminterface.cc new file mode 100644 index 0000000000..b7bf0744ed --- /dev/null +++ b/webrtc/sound/soundinputstreaminterface.cc @@ -0,0 +1,18 @@ +/* + * Copyright 2015 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "webrtc/sound/soundinputstreaminterface.h" +namespace rtc { + +SoundInputStreamInterface::~SoundInputStreamInterface() {} + +SoundInputStreamInterface::SoundInputStreamInterface() {} + +} // namespace rtc diff --git a/webrtc/sound/soundinputstreaminterface.h b/webrtc/sound/soundinputstreaminterface.h index 424ce8e927..2c934ba679 100644 --- a/webrtc/sound/soundinputstreaminterface.h +++ b/webrtc/sound/soundinputstreaminterface.h @@ -21,7 +21,7 @@ namespace rtc { // for rtc::Worker. class SoundInputStreamInterface { public: - virtual ~SoundInputStreamInterface() {} + virtual ~SoundInputStreamInterface(); // Starts the reading of samples on the current thread. virtual bool StartReading() = 0; @@ -57,7 +57,7 @@ class SoundInputStreamInterface { SoundInputStreamInterface *> SignalSamplesRead; protected: - SoundInputStreamInterface() {} + SoundInputStreamInterface(); private: RTC_DISALLOW_COPY_AND_ASSIGN(SoundInputStreamInterface); diff --git a/webrtc/sound/soundoutputstreaminterface.cc b/webrtc/sound/soundoutputstreaminterface.cc new file mode 100644 index 0000000000..c40f1d70d9 --- /dev/null +++ b/webrtc/sound/soundoutputstreaminterface.cc @@ -0,0 +1,19 @@ +/* + * Copyright 2015 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "webrtc/sound/soundoutputstreaminterface.h" + +namespace rtc { + +SoundOutputStreamInterface::~SoundOutputStreamInterface() {} + +SoundOutputStreamInterface::SoundOutputStreamInterface() {} + +} // namespace rtc diff --git a/webrtc/sound/soundoutputstreaminterface.h b/webrtc/sound/soundoutputstreaminterface.h index f56d39b7c9..a94147b838 100644 --- a/webrtc/sound/soundoutputstreaminterface.h +++ b/webrtc/sound/soundoutputstreaminterface.h @@ -21,7 +21,7 @@ namespace rtc { // DisableBufferMonitoring() are the same as for rtc::Worker. class SoundOutputStreamInterface { public: - virtual ~SoundOutputStreamInterface() {} + virtual ~SoundOutputStreamInterface(); // Enables monitoring the available buffer space on the current thread. virtual bool EnableBufferMonitoring() = 0; @@ -61,7 +61,7 @@ class SoundOutputStreamInterface { sigslot::signal2 SignalBufferSpace; protected: - SoundOutputStreamInterface() {} + SoundOutputStreamInterface(); private: RTC_DISALLOW_COPY_AND_ASSIGN(SoundOutputStreamInterface); diff --git a/webrtc/sound/soundsystemproxy.h b/webrtc/sound/soundsystemproxy.h index d13cf15b74..19696b1fef 100644 --- a/webrtc/sound/soundsystemproxy.h +++ b/webrtc/sound/soundsystemproxy.h @@ -25,18 +25,18 @@ class SoundSystemProxy : public SoundSystemInterface { // Each of these methods simply defers to wrapped_ if non-NULL, else fails. - virtual bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices); - virtual bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices); + bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices) override; + bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices) override; - virtual bool GetDefaultPlaybackDevice(SoundDeviceLocator **device); - virtual bool GetDefaultCaptureDevice(SoundDeviceLocator **device); + bool GetDefaultPlaybackDevice(SoundDeviceLocator **device) override; + bool GetDefaultCaptureDevice(SoundDeviceLocator **device) override; - virtual SoundOutputStreamInterface *OpenPlaybackDevice( + SoundOutputStreamInterface *OpenPlaybackDevice( const SoundDeviceLocator *device, - const OpenParams ¶ms); - virtual SoundInputStreamInterface *OpenCaptureDevice( + const OpenParams ¶ms) override; + SoundInputStreamInterface *OpenCaptureDevice( const SoundDeviceLocator *device, - const OpenParams ¶ms); + const OpenParams ¶ms) override; protected: SoundSystemInterface *wrapped_;