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}
This commit is contained in:
tfarina
2015-10-29 04:50:08 -07:00
committed by Commit bot
parent 95192fbb1e
commit a35ae7f507
12 changed files with 119 additions and 87 deletions

View File

@ -62,7 +62,7 @@ class AlsaDeviceLocator : public SoundDeviceLocator {
&name_); &name_);
} }
virtual SoundDeviceLocator *Copy() const { SoundDeviceLocator *Copy() const override {
return new AlsaDeviceLocator(*this); return new AlsaDeviceLocator(*this);
} }
}; };
@ -242,46 +242,46 @@ class AlsaInputStream :
buffer_size_(0) { buffer_size_(0) {
} }
virtual ~AlsaInputStream() { ~AlsaInputStream() override {
bool success = StopReading(); bool success = StopReading();
// We need that to live. // We need that to live.
VERIFY(success); VERIFY(success);
} }
virtual bool StartReading() { bool StartReading() override {
return StartWork(); return StartWork();
} }
virtual bool StopReading() { bool StopReading() override {
return StopWork(); return StopWork();
} }
virtual bool GetVolume(int *volume) { bool GetVolume(int *volume) override {
// TODO: Implement this. // TODO: Implement this.
return false; return false;
} }
virtual bool SetVolume(int volume) { bool SetVolume(int volume) override {
// TODO: Implement this. // TODO: Implement this.
return false; return false;
} }
virtual bool Close() { bool Close() override {
return StopReading() && stream_.Close(); return StopReading() && stream_.Close();
} }
virtual int LatencyUsecs() { int LatencyUsecs() override {
return stream_.CurrentDelayUsecs(); return stream_.CurrentDelayUsecs();
} }
private: private:
// Inherited from Worker. // Inherited from Worker.
virtual void OnStart() { void OnStart() override {
HaveWork(); HaveWork();
} }
// Inherited from Worker. // Inherited from Worker.
virtual void OnHaveWork() { void OnHaveWork() override {
// Block waiting for data. // Block waiting for data.
snd_pcm_uframes_t avail = stream_.Wait(); snd_pcm_uframes_t avail = stream_.Wait();
if (avail > 0) { if (avail > 0) {
@ -317,7 +317,7 @@ class AlsaInputStream :
} }
// Inherited from Worker. // Inherited from Worker.
virtual void OnStop() { void OnStop() override {
// Nothing to do. // Nothing to do.
} }
@ -334,9 +334,8 @@ class AlsaInputStream :
// Implementation of an output stream. See soundoutputstreaminterface.h // Implementation of an output stream. See soundoutputstreaminterface.h
// regarding thread-safety. // regarding thread-safety.
class AlsaOutputStream : class AlsaOutputStream : public SoundOutputStreamInterface,
public SoundOutputStreamInterface, private rtc::Worker {
private rtc::Worker {
public: public:
AlsaOutputStream(AlsaSoundSystem *alsa, AlsaOutputStream(AlsaSoundSystem *alsa,
snd_pcm_t *handle, snd_pcm_t *handle,
@ -347,22 +346,21 @@ class AlsaOutputStream :
: stream_(alsa, handle, frame_size, wait_timeout_ms, flags, freq) { : stream_(alsa, handle, frame_size, wait_timeout_ms, flags, freq) {
} }
virtual ~AlsaOutputStream() { ~AlsaOutputStream() override {
bool success = DisableBufferMonitoring(); bool success = DisableBufferMonitoring();
// We need that to live. // We need that to live.
VERIFY(success); VERIFY(success);
} }
virtual bool EnableBufferMonitoring() { bool EnableBufferMonitoring() override {
return StartWork(); return StartWork();
} }
virtual bool DisableBufferMonitoring() { bool DisableBufferMonitoring() override {
return StopWork(); return StopWork();
} }
virtual bool WriteSamples(const void *sample_data, bool WriteSamples(const void *sample_data, size_t size) override {
size_t size) {
if (size % stream_.frame_size() != 0) { if (size % stream_.frame_size() != 0) {
// No client of SoundSystemInterface does this, so let's not support it. // 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 // (If we wanted to support it, we'd basically just buffer the fractional
@ -389,32 +387,32 @@ class AlsaOutputStream :
return true; return true;
} }
virtual bool GetVolume(int *volume) { bool GetVolume(int *volume) override {
// TODO: Implement this. // TODO: Implement this.
return false; return false;
} }
virtual bool SetVolume(int volume) { bool SetVolume(int volume) override {
// TODO: Implement this. // TODO: Implement this.
return false; return false;
} }
virtual bool Close() { bool Close() override {
return DisableBufferMonitoring() && stream_.Close(); return DisableBufferMonitoring() && stream_.Close();
} }
virtual int LatencyUsecs() { int LatencyUsecs() override {
return stream_.CurrentDelayUsecs(); return stream_.CurrentDelayUsecs();
} }
private: private:
// Inherited from Worker. // Inherited from Worker.
virtual void OnStart() { void OnStart() override {
HaveWork(); HaveWork();
} }
// Inherited from Worker. // Inherited from Worker.
virtual void OnHaveWork() { void OnHaveWork() override {
snd_pcm_uframes_t avail = stream_.Wait(); snd_pcm_uframes_t avail = stream_.Wait();
if (avail > 0) { if (avail > 0) {
size_t space = avail * stream_.frame_size(); size_t space = avail * stream_.frame_size();
@ -424,7 +422,7 @@ class AlsaOutputStream :
} }
// Inherited from Worker. // Inherited from Worker.
virtual void OnStop() { void OnStop() override {
// Nothing to do. // Nothing to do.
} }

View File

@ -34,25 +34,25 @@ class AlsaSoundSystem : public SoundSystemInterface {
AlsaSoundSystem(); AlsaSoundSystem();
virtual ~AlsaSoundSystem(); ~AlsaSoundSystem() override;
virtual bool Init(); bool Init() override;
virtual void Terminate(); void Terminate() override;
virtual bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices); bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices) override;
virtual bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices); bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices) override;
virtual bool GetDefaultPlaybackDevice(SoundDeviceLocator **device); bool GetDefaultPlaybackDevice(SoundDeviceLocator **device) override;
virtual bool GetDefaultCaptureDevice(SoundDeviceLocator **device); bool GetDefaultCaptureDevice(SoundDeviceLocator **device) override;
virtual SoundOutputStreamInterface *OpenPlaybackDevice( SoundOutputStreamInterface *OpenPlaybackDevice(
const SoundDeviceLocator *device, const SoundDeviceLocator *device,
const OpenParams &params); const OpenParams &params) override;
virtual SoundInputStreamInterface *OpenCaptureDevice( SoundInputStreamInterface *OpenCaptureDevice(
const SoundDeviceLocator *device, const SoundDeviceLocator *device,
const OpenParams &params); const OpenParams &params) override;
virtual const char *GetName() const; const char *GetName() const override;
private: private:
bool IsInitialized() { return initialized_; } bool IsInitialized() { return initialized_; }

View File

@ -16,9 +16,7 @@
#include "webrtc/base/logging.h" #include "webrtc/base/logging.h"
namespace rtc { namespace rtc {
class Thread; class Thread;
} }
namespace rtc { namespace rtc {
@ -30,69 +28,68 @@ class NullSoundDeviceLocator : public SoundDeviceLocator {
public: public:
NullSoundDeviceLocator() : SoundDeviceLocator(kNullName, kNullName) {} NullSoundDeviceLocator() : SoundDeviceLocator(kNullName, kNullName) {}
virtual SoundDeviceLocator *Copy() const { SoundDeviceLocator *Copy() const override {
return new NullSoundDeviceLocator(); return new NullSoundDeviceLocator();
} }
}; };
class NullSoundInputStream : public SoundInputStreamInterface { class NullSoundInputStream : public SoundInputStreamInterface {
public: public:
virtual bool StartReading() { bool StartReading() override {
return true; return true;
} }
virtual bool StopReading() { bool StopReading() override {
return true; return true;
} }
virtual bool GetVolume(int *volume) { bool GetVolume(int *volume) override {
*volume = SoundSystemInterface::kMinVolume; *volume = SoundSystemInterface::kMinVolume;
return true; return true;
} }
virtual bool SetVolume(int volume) { bool SetVolume(int volume) override {
return false; return false;
} }
virtual bool Close() { bool Close() override {
return true; return true;
} }
virtual int LatencyUsecs() { int LatencyUsecs() override {
return 0; return 0;
} }
}; };
class NullSoundOutputStream : public SoundOutputStreamInterface { class NullSoundOutputStream : public SoundOutputStreamInterface {
public: public:
virtual bool EnableBufferMonitoring() { bool EnableBufferMonitoring() override {
return true; return true;
} }
virtual bool DisableBufferMonitoring() { bool DisableBufferMonitoring() override {
return true; return true;
} }
virtual bool WriteSamples(const void *sample_data, bool WriteSamples(const void *sample_data, size_t size) override {
size_t size) {
LOG(LS_VERBOSE) << "Got " << size << " bytes of playback samples"; LOG(LS_VERBOSE) << "Got " << size << " bytes of playback samples";
return true; return true;
} }
virtual bool GetVolume(int *volume) { bool GetVolume(int *volume) override {
*volume = SoundSystemInterface::kMinVolume; *volume = SoundSystemInterface::kMinVolume;
return true; return true;
} }
virtual bool SetVolume(int volume) { bool SetVolume(int volume) override {
return false; return false;
} }
virtual bool Close() { bool Close() override {
return true; return true;
} }
virtual int LatencyUsecs() { int LatencyUsecs() override {
return 0; return 0;
} }
}; };

View File

@ -27,25 +27,25 @@ class NullSoundSystem : public SoundSystemInterface {
return new NullSoundSystem(); return new NullSoundSystem();
} }
virtual ~NullSoundSystem(); ~NullSoundSystem() override;
virtual bool Init(); bool Init() override;
virtual void Terminate(); void Terminate() override;
virtual bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices); bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices) override;
virtual bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices); bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices) override;
virtual SoundOutputStreamInterface *OpenPlaybackDevice( SoundOutputStreamInterface *OpenPlaybackDevice(
const SoundDeviceLocator *device, const SoundDeviceLocator *device,
const OpenParams &params); const OpenParams &params) override;
virtual SoundInputStreamInterface *OpenCaptureDevice( SoundInputStreamInterface *OpenCaptureDevice(
const SoundDeviceLocator *device, const SoundDeviceLocator *device,
const OpenParams &params); const OpenParams &params) override;
virtual bool GetDefaultPlaybackDevice(SoundDeviceLocator **device); bool GetDefaultPlaybackDevice(SoundDeviceLocator **device) override;
virtual bool GetDefaultCaptureDevice(SoundDeviceLocator **device); bool GetDefaultCaptureDevice(SoundDeviceLocator **device) override;
virtual const char *GetName() const; const char *GetName() const override;
}; };
} // namespace rtc } // namespace rtc

View File

@ -20,12 +20,12 @@ namespace rtc {
class NullSoundSystemFactory : public SoundSystemFactory { class NullSoundSystemFactory : public SoundSystemFactory {
public: public:
NullSoundSystemFactory(); NullSoundSystemFactory();
virtual ~NullSoundSystemFactory(); ~NullSoundSystemFactory() override;
protected: protected:
// Inherited from SoundSystemFactory. // Inherited from SoundSystemFactory.
virtual bool SetupInstance(); bool SetupInstance() override;
virtual void CleanupInstance(); void CleanupInstance() override;
}; };
} // namespace rtc } // namespace rtc

View File

@ -20,16 +20,14 @@ namespace rtc {
class PlatformSoundSystemFactory : public SoundSystemFactory { class PlatformSoundSystemFactory : public SoundSystemFactory {
public: public:
PlatformSoundSystemFactory(); PlatformSoundSystemFactory();
virtual ~PlatformSoundSystemFactory(); ~PlatformSoundSystemFactory() override;
protected: protected:
// Inherited from SoundSystemFactory. // Inherited from SoundSystemFactory.
virtual bool SetupInstance(); bool SetupInstance() override;
virtual void CleanupInstance(); void CleanupInstance() override;
}; };
} // namespace rtc } // namespace rtc
#endif // WEBRTC_SOUND_PLATFORMSOUNDSYSTEMFACTORY_H_ #endif // WEBRTC_SOUND_PLATFORMSOUNDSYSTEMFACTORY_H_

View File

@ -26,7 +26,9 @@
'platformsoundsystemfactory.cc', 'platformsoundsystemfactory.cc',
'platformsoundsystemfactory.h', 'platformsoundsystemfactory.h',
'sounddevicelocator.h', 'sounddevicelocator.h',
'soundinputstreaminterface.cc',
'soundinputstreaminterface.h', 'soundinputstreaminterface.h',
'soundoutputstreaminterface.cc',
'soundoutputstreaminterface.h', 'soundoutputstreaminterface.h',
'soundsystemfactory.h', 'soundsystemfactory.h',
'soundsysteminterface.cc', 'soundsysteminterface.cc',

View File

@ -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

View File

@ -21,7 +21,7 @@ namespace rtc {
// for rtc::Worker. // for rtc::Worker.
class SoundInputStreamInterface { class SoundInputStreamInterface {
public: public:
virtual ~SoundInputStreamInterface() {} virtual ~SoundInputStreamInterface();
// Starts the reading of samples on the current thread. // Starts the reading of samples on the current thread.
virtual bool StartReading() = 0; virtual bool StartReading() = 0;
@ -57,7 +57,7 @@ class SoundInputStreamInterface {
SoundInputStreamInterface *> SignalSamplesRead; SoundInputStreamInterface *> SignalSamplesRead;
protected: protected:
SoundInputStreamInterface() {} SoundInputStreamInterface();
private: private:
RTC_DISALLOW_COPY_AND_ASSIGN(SoundInputStreamInterface); RTC_DISALLOW_COPY_AND_ASSIGN(SoundInputStreamInterface);

View File

@ -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

View File

@ -21,7 +21,7 @@ namespace rtc {
// DisableBufferMonitoring() are the same as for rtc::Worker. // DisableBufferMonitoring() are the same as for rtc::Worker.
class SoundOutputStreamInterface { class SoundOutputStreamInterface {
public: public:
virtual ~SoundOutputStreamInterface() {} virtual ~SoundOutputStreamInterface();
// Enables monitoring the available buffer space on the current thread. // Enables monitoring the available buffer space on the current thread.
virtual bool EnableBufferMonitoring() = 0; virtual bool EnableBufferMonitoring() = 0;
@ -61,7 +61,7 @@ class SoundOutputStreamInterface {
sigslot::signal2<size_t, SoundOutputStreamInterface *> SignalBufferSpace; sigslot::signal2<size_t, SoundOutputStreamInterface *> SignalBufferSpace;
protected: protected:
SoundOutputStreamInterface() {} SoundOutputStreamInterface();
private: private:
RTC_DISALLOW_COPY_AND_ASSIGN(SoundOutputStreamInterface); RTC_DISALLOW_COPY_AND_ASSIGN(SoundOutputStreamInterface);

View File

@ -25,18 +25,18 @@ class SoundSystemProxy : public SoundSystemInterface {
// Each of these methods simply defers to wrapped_ if non-NULL, else fails. // Each of these methods simply defers to wrapped_ if non-NULL, else fails.
virtual bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices); bool EnumeratePlaybackDevices(SoundDeviceLocatorList *devices) override;
virtual bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices); bool EnumerateCaptureDevices(SoundDeviceLocatorList *devices) override;
virtual bool GetDefaultPlaybackDevice(SoundDeviceLocator **device); bool GetDefaultPlaybackDevice(SoundDeviceLocator **device) override;
virtual bool GetDefaultCaptureDevice(SoundDeviceLocator **device); bool GetDefaultCaptureDevice(SoundDeviceLocator **device) override;
virtual SoundOutputStreamInterface *OpenPlaybackDevice( SoundOutputStreamInterface *OpenPlaybackDevice(
const SoundDeviceLocator *device, const SoundDeviceLocator *device,
const OpenParams &params); const OpenParams &params) override;
virtual SoundInputStreamInterface *OpenCaptureDevice( SoundInputStreamInterface *OpenCaptureDevice(
const SoundDeviceLocator *device, const SoundDeviceLocator *device,
const OpenParams &params); const OpenParams &params) override;
protected: protected:
SoundSystemInterface *wrapped_; SoundSystemInterface *wrapped_;