mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Remove AudioDeviceObserver and make ADM not inherit from the Module interface.
(Re-upload of https://codereview.webrtc.org/3020493002/) Bug: webrtc:4690, webrtc:7306 Change-Id: I67fb9ebca1296aabc08eae8a292a5c69832dc35e Reviewed-on: https://webrtc-review.googlesource.com/5360 Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20083}
This commit is contained in:
parent
c007857ab9
commit
34cdd2d402
35 changed files with 14 additions and 698 deletions
|
@ -432,10 +432,6 @@ TEST(CallBitrateTest,
|
|||
TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) {
|
||||
constexpr uint32_t kSSRC = 12345;
|
||||
testing::NiceMock<test::MockAudioDeviceModule> mock_adm;
|
||||
// Reply with a 10ms timer every time TimeUntilNextProcess is called to
|
||||
// avoid entering a tight loop on the process thread.
|
||||
EXPECT_CALL(mock_adm, TimeUntilNextProcess())
|
||||
.WillRepeatedly(testing::Return(10));
|
||||
rtc::scoped_refptr<test::MockAudioMixer> mock_mixer(
|
||||
new rtc::RefCountedObject<test::MockAudioMixer>);
|
||||
|
||||
|
|
|
@ -25,11 +25,6 @@ constexpr AgcConfig kDefaultAgcConfig = { 3, 9, true };
|
|||
|
||||
struct TestHelper {
|
||||
TestHelper() {
|
||||
// Reply with a 10ms timer every time TimeUntilNextProcess is called to
|
||||
// avoid entering a tight loop on the process thread.
|
||||
EXPECT_CALL(mock_audio_device_, TimeUntilNextProcess())
|
||||
.WillRepeatedly(testing::Return(10));
|
||||
|
||||
// This replicates the conditions from voe_auto_test.
|
||||
Config config;
|
||||
config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
|
||||
|
|
|
@ -3341,9 +3341,6 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) {
|
|||
testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm;
|
||||
EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0));
|
||||
EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0));
|
||||
// Return 100ms just in case this function gets called. If we don't,
|
||||
// we could enter a tight loop since the mock would return 0.
|
||||
EXPECT_CALL(adm, TimeUntilNextProcess()).WillRepeatedly(Return(100));
|
||||
{
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> apm =
|
||||
webrtc::AudioProcessing::Create();
|
||||
|
|
|
@ -391,30 +391,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool PlayoutWarning() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlayoutError() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RecordingWarning() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RecordingError() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClearPlayoutWarning() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void ClearPlayoutError() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void ClearRecordingWarning() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void ClearRecordingError() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
output_.AttachAudioBuffer(audioBuffer);
|
||||
|
|
|
@ -28,8 +28,6 @@ const size_t kMaxDeltaTimeInMs = 500;
|
|||
// TODO(henrika): remove when no longer used by external client.
|
||||
const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz
|
||||
|
||||
class AudioDeviceObserver;
|
||||
|
||||
class AudioDeviceBuffer {
|
||||
public:
|
||||
enum LogState {
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
// Enumerators
|
||||
//
|
||||
enum { kAdmMaxIdleTimeProcess = 1000 };
|
||||
enum { GET_MIC_VOLUME_INTERVAL_MS = 1000 };
|
||||
|
||||
// Platform specifics
|
||||
|
|
|
@ -36,12 +36,6 @@ class ADMWrapper : public AudioDeviceModule, public AudioTransport {
|
|||
// Make sure we have a valid ADM before returning it to user.
|
||||
bool IsValid() { return is_valid_; }
|
||||
|
||||
// RefCountedModule methods overrides.
|
||||
int64_t TimeUntilNextProcess() override {
|
||||
return impl_->TimeUntilNextProcess();
|
||||
}
|
||||
void Process() override { return impl_->Process(); }
|
||||
|
||||
// AudioTransport methods overrides.
|
||||
int32_t RecordedDataIsAvailable(const void* audioSamples,
|
||||
const size_t nSamples,
|
||||
|
@ -127,9 +121,6 @@ class ADMWrapper : public AudioDeviceModule, public AudioTransport {
|
|||
return impl_->ActiveAudioLayer(audio_layer);
|
||||
}
|
||||
ErrorCode LastError() const override { return impl_->LastError(); }
|
||||
int32_t RegisterEventObserver(AudioDeviceObserver* event_callback) override {
|
||||
return impl_->RegisterEventObserver(event_callback);
|
||||
}
|
||||
int32_t Init() override { return impl_->Init(); }
|
||||
int32_t Terminate() override { return impl_->Terminate(); }
|
||||
bool Initialized() const override { return impl_->Initialized(); }
|
||||
|
|
|
@ -142,15 +142,6 @@ class AudioDeviceGeneric {
|
|||
virtual int GetRecordAudioParameters(AudioParameters* params) const;
|
||||
#endif // WEBRTC_IOS
|
||||
|
||||
virtual bool PlayoutWarning() const = 0;
|
||||
virtual bool PlayoutError() const = 0;
|
||||
virtual bool RecordingWarning() const = 0;
|
||||
virtual bool RecordingError() const = 0;
|
||||
virtual void ClearPlayoutWarning() = 0;
|
||||
virtual void ClearPlayoutError() = 0;
|
||||
virtual void ClearRecordingWarning() = 0;
|
||||
virtual void ClearRecordingError() = 0;
|
||||
|
||||
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0;
|
||||
|
||||
virtual ~AudioDeviceGeneric() {}
|
||||
|
|
|
@ -116,11 +116,9 @@ rtc::scoped_refptr<AudioDeviceModule> AudioDeviceModule::Create(
|
|||
|
||||
AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id,
|
||||
const AudioLayer audioLayer)
|
||||
: _ptrCbAudioDeviceObserver(NULL),
|
||||
_ptrAudioDevice(NULL),
|
||||
: _ptrAudioDevice(NULL),
|
||||
_id(id),
|
||||
_platformAudioLayer(audioLayer),
|
||||
_lastProcessTime(rtc::TimeMillis()),
|
||||
_platformType(kPlatformNotSupported),
|
||||
_initialized(false),
|
||||
_lastError(kAdmErrNone) {
|
||||
|
@ -359,78 +357,6 @@ AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {
|
|||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Module
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Module::TimeUntilNextProcess
|
||||
//
|
||||
// Returns the number of milliseconds until the module want a worker thread
|
||||
// to call Process().
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int64_t AudioDeviceModuleImpl::TimeUntilNextProcess() {
|
||||
int64_t now = rtc::TimeMillis();
|
||||
int64_t deltaProcess = kAdmMaxIdleTimeProcess - (now - _lastProcessTime);
|
||||
return deltaProcess;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Module::Process
|
||||
//
|
||||
// Check for posted error and warning reports. Generate callbacks if
|
||||
// new reports exists.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AudioDeviceModuleImpl::Process() {
|
||||
_lastProcessTime = rtc::TimeMillis();
|
||||
|
||||
// kPlayoutWarning
|
||||
if (_ptrAudioDevice->PlayoutWarning()) {
|
||||
rtc::CritScope lock(&_critSectEventCb);
|
||||
if (_ptrCbAudioDeviceObserver) {
|
||||
LOG(WARNING) << "=> OnWarningIsReported(kPlayoutWarning)";
|
||||
_ptrCbAudioDeviceObserver->OnWarningIsReported(
|
||||
AudioDeviceObserver::kPlayoutWarning);
|
||||
}
|
||||
_ptrAudioDevice->ClearPlayoutWarning();
|
||||
}
|
||||
|
||||
// kPlayoutError
|
||||
if (_ptrAudioDevice->PlayoutError()) {
|
||||
rtc::CritScope lock(&_critSectEventCb);
|
||||
if (_ptrCbAudioDeviceObserver) {
|
||||
LOG(LERROR) << "=> OnErrorIsReported(kPlayoutError)";
|
||||
_ptrCbAudioDeviceObserver->OnErrorIsReported(
|
||||
AudioDeviceObserver::kPlayoutError);
|
||||
}
|
||||
_ptrAudioDevice->ClearPlayoutError();
|
||||
}
|
||||
|
||||
// kRecordingWarning
|
||||
if (_ptrAudioDevice->RecordingWarning()) {
|
||||
rtc::CritScope lock(&_critSectEventCb);
|
||||
if (_ptrCbAudioDeviceObserver) {
|
||||
LOG(WARNING) << "=> OnWarningIsReported(kRecordingWarning)";
|
||||
_ptrCbAudioDeviceObserver->OnWarningIsReported(
|
||||
AudioDeviceObserver::kRecordingWarning);
|
||||
}
|
||||
_ptrAudioDevice->ClearRecordingWarning();
|
||||
}
|
||||
|
||||
// kRecordingError
|
||||
if (_ptrAudioDevice->RecordingError()) {
|
||||
rtc::CritScope lock(&_critSectEventCb);
|
||||
if (_ptrCbAudioDeviceObserver) {
|
||||
LOG(LERROR) << "=> OnErrorIsReported(kRecordingError)";
|
||||
_ptrCbAudioDeviceObserver->OnErrorIsReported(
|
||||
AudioDeviceObserver::kRecordingError);
|
||||
}
|
||||
_ptrAudioDevice->ClearRecordingError();
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Public API
|
||||
// ============================================================================
|
||||
|
@ -1320,19 +1246,6 @@ bool AudioDeviceModuleImpl::Recording() const {
|
|||
return (_ptrAudioDevice->Recording());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// RegisterEventObserver
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int32_t AudioDeviceModuleImpl::RegisterEventObserver(
|
||||
AudioDeviceObserver* eventCallback) {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
rtc::CritScope lock(&_critSectEventCb);
|
||||
_ptrCbAudioDeviceObserver = eventCallback;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// RegisterAudioCallback
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -44,15 +44,11 @@ class AudioDeviceModuleImpl : public AudioDeviceModule {
|
|||
AudioDeviceModuleImpl(const int32_t id, const AudioLayer audioLayer);
|
||||
~AudioDeviceModuleImpl() override;
|
||||
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
void Process() override;
|
||||
|
||||
// Retrieve the currently utilized audio layer
|
||||
int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override;
|
||||
|
||||
// Error handling
|
||||
ErrorCode LastError() const override;
|
||||
int32_t RegisterEventObserver(AudioDeviceObserver* eventCallback) override;
|
||||
|
||||
// Full-duplex transportation of PCM audio
|
||||
int32_t RegisterAudioCallback(AudioTransport* audioCallback) override;
|
||||
|
@ -178,11 +174,8 @@ class AudioDeviceModuleImpl : public AudioDeviceModule {
|
|||
AudioLayer PlatformAudioLayer() const;
|
||||
|
||||
rtc::CriticalSection _critSect;
|
||||
rtc::CriticalSection _critSectEventCb;
|
||||
rtc::CriticalSection _critSectAudioCb;
|
||||
|
||||
AudioDeviceObserver* _ptrCbAudioDeviceObserver;
|
||||
|
||||
AudioDeviceGeneric* _ptrAudioDevice;
|
||||
|
||||
AudioDeviceBuffer _audioDeviceBuffer;
|
||||
|
@ -191,7 +184,6 @@ class AudioDeviceModuleImpl : public AudioDeviceModule {
|
|||
#endif
|
||||
int32_t _id;
|
||||
AudioLayer _platformAudioLayer;
|
||||
int64_t _lastProcessTime;
|
||||
PlatformType _platformType;
|
||||
bool _initialized;
|
||||
mutable ErrorCode _lastError;
|
||||
|
|
|
@ -158,21 +158,5 @@ int32_t AudioDeviceDummy::PlayoutDelay(uint16_t& delayMS) const { return -1; }
|
|||
|
||||
int32_t AudioDeviceDummy::RecordingDelay(uint16_t& delayMS) const { return -1; }
|
||||
|
||||
bool AudioDeviceDummy::PlayoutWarning() const { return false; }
|
||||
|
||||
bool AudioDeviceDummy::PlayoutError() const { return false; }
|
||||
|
||||
bool AudioDeviceDummy::RecordingWarning() const { return false; }
|
||||
|
||||
bool AudioDeviceDummy::RecordingError() const { return false; }
|
||||
|
||||
void AudioDeviceDummy::ClearPlayoutWarning() {}
|
||||
|
||||
void AudioDeviceDummy::ClearPlayoutError() {}
|
||||
|
||||
void AudioDeviceDummy::ClearRecordingWarning() {}
|
||||
|
||||
void AudioDeviceDummy::ClearRecordingError() {}
|
||||
|
||||
void AudioDeviceDummy::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {}
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -111,15 +111,6 @@ class AudioDeviceDummy : public AudioDeviceGeneric {
|
|||
int32_t PlayoutDelay(uint16_t& delayMS) const override;
|
||||
int32_t RecordingDelay(uint16_t& delayMS) const override;
|
||||
|
||||
bool PlayoutWarning() const override;
|
||||
bool PlayoutError() const override;
|
||||
bool RecordingWarning() const override;
|
||||
bool RecordingError() const override;
|
||||
void ClearPlayoutWarning() override;
|
||||
void ClearPlayoutError() override;
|
||||
void ClearRecordingWarning() override;
|
||||
void ClearRecordingError() override;
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -398,22 +398,6 @@ int32_t FileAudioDevice::PlayoutDelay(uint16_t& delayMS) const {
|
|||
|
||||
int32_t FileAudioDevice::RecordingDelay(uint16_t& delayMS) const { return -1; }
|
||||
|
||||
bool FileAudioDevice::PlayoutWarning() const { return false; }
|
||||
|
||||
bool FileAudioDevice::PlayoutError() const { return false; }
|
||||
|
||||
bool FileAudioDevice::RecordingWarning() const { return false; }
|
||||
|
||||
bool FileAudioDevice::RecordingError() const { return false; }
|
||||
|
||||
void FileAudioDevice::ClearPlayoutWarning() {}
|
||||
|
||||
void FileAudioDevice::ClearPlayoutError() {}
|
||||
|
||||
void FileAudioDevice::ClearRecordingWarning() {}
|
||||
|
||||
void FileAudioDevice::ClearRecordingError() {}
|
||||
|
||||
void FileAudioDevice::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
|
||||
|
|
|
@ -132,15 +132,6 @@ class FileAudioDevice : public AudioDeviceGeneric {
|
|||
int32_t PlayoutDelay(uint16_t& delayMS) const override;
|
||||
int32_t RecordingDelay(uint16_t& delayMS) const override;
|
||||
|
||||
bool PlayoutWarning() const override;
|
||||
bool PlayoutError() const override;
|
||||
bool RecordingWarning() const override;
|
||||
bool RecordingError() const override;
|
||||
void ClearPlayoutWarning() override;
|
||||
void ClearPlayoutError() override;
|
||||
void ClearRecordingWarning() override;
|
||||
void ClearRecordingError() override;
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
#define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_
|
||||
|
||||
#include "modules/audio_device/include/audio_device_defines.h"
|
||||
#include "modules/include/module.h"
|
||||
#include "rtc_base/scoped_ref_ptr.h"
|
||||
#include "rtc_base/refcount.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class AudioDeviceModule : public RefCountedModule {
|
||||
class AudioDeviceModule : public rtc::RefCountInterface {
|
||||
public:
|
||||
enum ErrorCode {
|
||||
kAdmErrNone = 0,
|
||||
|
@ -52,21 +52,11 @@ class AudioDeviceModule : public RefCountedModule {
|
|||
const int32_t id,
|
||||
const AudioLayer audio_layer);
|
||||
|
||||
// TODO(solenberg): Remove temporary implementation of Module interface.
|
||||
int64_t TimeUntilNextProcess() override {
|
||||
// Make sure Process() isn't called very often.
|
||||
return 1000000;
|
||||
}
|
||||
void Process() override {}
|
||||
|
||||
// Retrieve the currently utilized audio layer
|
||||
virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const = 0;
|
||||
|
||||
// Error handling
|
||||
virtual ErrorCode LastError() const = 0;
|
||||
virtual int32_t RegisterEventObserver(AudioDeviceObserver* eventCallback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Full-duplex transportation of PCM audio
|
||||
virtual int32_t RegisterAudioCallback(AudioTransport* audioCallback) = 0;
|
||||
|
|
|
@ -24,22 +24,6 @@ static const int kAdmMaxGuidSize = 128;
|
|||
static const int kAdmMinPlayoutBufferSizeMs = 10;
|
||||
static const int kAdmMaxPlayoutBufferSizeMs = 250;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AudioDeviceObserver
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class AudioDeviceObserver {
|
||||
public:
|
||||
enum ErrorCode { kRecordingError = 0, kPlayoutError = 1 };
|
||||
enum WarningCode { kRecordingWarning = 0, kPlayoutWarning = 1 };
|
||||
|
||||
virtual void OnErrorIsReported(const ErrorCode error) = 0;
|
||||
virtual void OnWarningIsReported(const WarningCode warning) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~AudioDeviceObserver() {}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AudioTransport
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -23,9 +23,6 @@ class FakeAudioDeviceModule : public AudioDeviceModule {
|
|||
virtual int32_t Release() const { return 0; }
|
||||
|
||||
private:
|
||||
virtual int32_t RegisterEventObserver(AudioDeviceObserver* eventCallback) {
|
||||
return 0;
|
||||
}
|
||||
virtual int32_t RegisterAudioCallback(AudioTransport* audioCallback) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,18 +21,12 @@ namespace test {
|
|||
|
||||
class MockAudioDeviceModule : public AudioDeviceModule {
|
||||
public:
|
||||
// Module.
|
||||
MOCK_METHOD0(TimeUntilNextProcess, int64_t());
|
||||
MOCK_METHOD0(Process, void());
|
||||
MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*));
|
||||
// RefCountedModule.
|
||||
// RefCounted
|
||||
MOCK_CONST_METHOD0(AddRef, int32_t());
|
||||
MOCK_CONST_METHOD0(Release, int32_t());
|
||||
// AudioDeviceModule.
|
||||
MOCK_CONST_METHOD1(ActiveAudioLayer, int32_t(AudioLayer* audioLayer));
|
||||
MOCK_CONST_METHOD0(LastError, ErrorCode());
|
||||
MOCK_METHOD1(RegisterEventObserver,
|
||||
int32_t(AudioDeviceObserver* eventCallback));
|
||||
MOCK_METHOD1(RegisterAudioCallback, int32_t(AudioTransport* audioCallback));
|
||||
MOCK_METHOD0(Init, int32_t());
|
||||
MOCK_METHOD0(Terminate, int32_t());
|
||||
|
|
|
@ -139,14 +139,6 @@ class AudioDeviceIOS : public AudioDeviceGeneric,
|
|||
int32_t StereoRecordingIsAvailable(bool& available) override;
|
||||
int32_t SetStereoRecording(bool enable) override;
|
||||
int32_t StereoRecording(bool& enabled) const override;
|
||||
bool PlayoutWarning() const override;
|
||||
bool PlayoutError() const override;
|
||||
bool RecordingWarning() const override;
|
||||
bool RecordingError() const override;
|
||||
void ClearPlayoutWarning() override {}
|
||||
void ClearPlayoutError() override {}
|
||||
void ClearRecordingWarning() override {}
|
||||
void ClearRecordingError() override {}
|
||||
|
||||
// AudioSessionObserver methods. May be called from any thread.
|
||||
void OnInterruptionBegin() override;
|
||||
|
|
|
@ -91,22 +91,6 @@ int32_t AudioDeviceIOS::SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool AudioDeviceIOS::PlayoutWarning() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AudioDeviceIOS::PlayoutError() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AudioDeviceIOS::RecordingWarning() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AudioDeviceIOS::RecordingError() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t AudioDeviceIOS::InitMicrophone() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -89,11 +89,7 @@ AudioDeviceLinuxALSA::AudioDeviceLinuxALSA() :
|
|||
_playIsInitialized(false),
|
||||
_AGC(false),
|
||||
_recordingDelay(0),
|
||||
_playoutDelay(0),
|
||||
_playWarning(0),
|
||||
_playError(0),
|
||||
_recWarning(0),
|
||||
_recError(0)
|
||||
_playoutDelay(0)
|
||||
{
|
||||
memset(_oldKeyState, 0, sizeof(_oldKeyState));
|
||||
LOG(LS_INFO) << __FUNCTION__ << " created";
|
||||
|
@ -166,10 +162,6 @@ AudioDeviceGeneric::InitStatus AudioDeviceLinuxALSA::Init() {
|
|||
<< "failed to open X display, typing detection will not work";
|
||||
}
|
||||
#endif
|
||||
_playWarning = 0;
|
||||
_playError = 0;
|
||||
_recWarning = 0;
|
||||
_recError = 0;
|
||||
|
||||
_initialized = true;
|
||||
|
||||
|
@ -1014,8 +1006,6 @@ int32_t AudioDeviceLinuxALSA::InitPlayout()
|
|||
_handlePlayout, _playoutFramesIn10MS);
|
||||
|
||||
// Init varaibles used for play
|
||||
_playWarning = 0;
|
||||
_playError = 0;
|
||||
|
||||
if (_handlePlayout != NULL)
|
||||
{
|
||||
|
@ -1447,54 +1437,6 @@ bool AudioDeviceLinuxALSA::Playing() const
|
|||
return (_playing);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxALSA::PlayoutWarning() const
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_playWarning > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxALSA::PlayoutError() const
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_playError > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxALSA::RecordingWarning() const
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_recWarning > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxALSA::RecordingError() const
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_recError > 0);
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxALSA::ClearPlayoutWarning()
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_playWarning = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxALSA::ClearPlayoutError()
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_playError = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxALSA::ClearRecordingWarning()
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_recWarning = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxALSA::ClearRecordingError()
|
||||
{
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_recError = 0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Private Methods
|
||||
// ============================================================================
|
||||
|
|
|
@ -125,15 +125,6 @@ public:
|
|||
int32_t PlayoutDelay(uint16_t& delayMS) const override;
|
||||
int32_t RecordingDelay(uint16_t& delayMS) const override;
|
||||
|
||||
bool PlayoutWarning() const override;
|
||||
bool PlayoutError() const override;
|
||||
bool RecordingWarning() const override;
|
||||
bool RecordingError() const override;
|
||||
void ClearPlayoutWarning() override;
|
||||
void ClearPlayoutError() override;
|
||||
void ClearRecordingWarning() override;
|
||||
void ClearRecordingError() override;
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
|
||||
|
||||
private:
|
||||
|
@ -206,11 +197,6 @@ private:
|
|||
snd_pcm_sframes_t _recordingDelay;
|
||||
snd_pcm_sframes_t _playoutDelay;
|
||||
|
||||
uint16_t _playWarning;
|
||||
uint16_t _playError;
|
||||
uint16_t _recWarning;
|
||||
uint16_t _recError;
|
||||
|
||||
char _oldKeyState[32];
|
||||
#if defined(USE_X11)
|
||||
Display* _XDisplay;
|
||||
|
|
|
@ -54,10 +54,6 @@ AudioDeviceLinuxPulse::AudioDeviceLinuxPulse()
|
|||
_sndCardPlayDelay(0),
|
||||
_sndCardRecDelay(0),
|
||||
_writeErrors(0),
|
||||
_playWarning(0),
|
||||
_playError(0),
|
||||
_recWarning(0),
|
||||
_recError(0),
|
||||
_deviceIndex(-1),
|
||||
_numPlayDevices(0),
|
||||
_numRecDevices(0),
|
||||
|
@ -160,11 +156,6 @@ AudioDeviceGeneric::InitStatus AudioDeviceLinuxPulse::Init() {
|
|||
return InitStatus::OTHER_ERROR;
|
||||
}
|
||||
|
||||
_playWarning = 0;
|
||||
_playError = 0;
|
||||
_recWarning = 0;
|
||||
_recError = 0;
|
||||
|
||||
// Get X display handle for typing detection
|
||||
_XDisplay = XOpenDisplay(NULL);
|
||||
if (!_XDisplay) {
|
||||
|
@ -1292,46 +1283,6 @@ bool AudioDeviceLinuxPulse::Playing() const {
|
|||
return (_playing);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxPulse::PlayoutWarning() const {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_playWarning > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxPulse::PlayoutError() const {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_playError > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxPulse::RecordingWarning() const {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_recWarning > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceLinuxPulse::RecordingError() const {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
return (_recError > 0);
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxPulse::ClearPlayoutWarning() {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_playWarning = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxPulse::ClearPlayoutError() {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_playError = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxPulse::ClearRecordingWarning() {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_recWarning = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceLinuxPulse::ClearRecordingError() {
|
||||
rtc::CritScope lock(&_critSect);
|
||||
_recError = 0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Private Methods
|
||||
// ============================================================================
|
||||
|
@ -2191,12 +2142,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() {
|
|||
NULL, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) {
|
||||
_writeErrors++;
|
||||
if (_writeErrors > 10) {
|
||||
if (_playError == 1) {
|
||||
LOG(LS_WARNING) << "pending playout error exists";
|
||||
}
|
||||
// Triggers callback from module process thread.
|
||||
_playError = 1;
|
||||
LOG(LS_ERROR) << "kPlayoutError message posted: _writeErrors="
|
||||
LOG(LS_ERROR) << "Playout error: _writeErrors="
|
||||
<< _writeErrors
|
||||
<< ", error=" << LATE(pa_context_errno)(_paContext);
|
||||
_writeErrors = 0;
|
||||
|
@ -2240,12 +2186,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() {
|
|||
NULL, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) {
|
||||
_writeErrors++;
|
||||
if (_writeErrors > 10) {
|
||||
if (_playError == 1) {
|
||||
LOG(LS_WARNING) << "pending playout error exists";
|
||||
}
|
||||
// Triggers callback from module process thread.
|
||||
_playError = 1;
|
||||
LOG(LS_ERROR) << "kPlayoutError message posted: _writeErrors="
|
||||
LOG(LS_ERROR) << "Playout error: _writeErrors="
|
||||
<< _writeErrors
|
||||
<< ", error=" << LATE(pa_context_errno)(_paContext);
|
||||
_writeErrors = 0;
|
||||
|
@ -2358,8 +2299,7 @@ bool AudioDeviceLinuxPulse::RecThreadProcess() {
|
|||
size_t sampleDataSize;
|
||||
|
||||
if (LATE(pa_stream_peek)(_recStream, &sampleData, &sampleDataSize) != 0) {
|
||||
_recError = 1; // triggers callback from module process thread
|
||||
LOG(LS_ERROR) << "RECORD_ERROR message posted, error = "
|
||||
LOG(LS_ERROR) << "RECORD_ERROR, error = "
|
||||
<< LATE(pa_context_errno)(_paContext);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -187,15 +187,6 @@ public:
|
|||
int32_t PlayoutDelay(uint16_t& delayMS) const override;
|
||||
int32_t RecordingDelay(uint16_t& delayMS) const override;
|
||||
|
||||
bool PlayoutWarning() const override;
|
||||
bool PlayoutError() const override;
|
||||
bool RecordingWarning() const override;
|
||||
bool RecordingError() const override;
|
||||
void ClearPlayoutWarning() override;
|
||||
void ClearPlayoutError() override;
|
||||
void ClearRecordingWarning() override;
|
||||
void ClearRecordingError() override;
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
|
||||
|
||||
private:
|
||||
|
@ -306,10 +297,6 @@ private:
|
|||
uint32_t _sndCardRecDelay;
|
||||
|
||||
int32_t _writeErrors;
|
||||
uint16_t _playWarning;
|
||||
uint16_t _playError;
|
||||
uint16_t _recWarning;
|
||||
uint16_t _recError;
|
||||
|
||||
uint16_t _deviceIndex;
|
||||
int16_t _numPlayDevices;
|
||||
|
|
|
@ -144,10 +144,6 @@ AudioDeviceMac::AudioDeviceMac()
|
|||
_captureDelayUs(0),
|
||||
_renderDelayUs(0),
|
||||
_renderDelayOffsetSamples(0),
|
||||
_playWarning(0),
|
||||
_playError(0),
|
||||
_recWarning(0),
|
||||
_recError(0),
|
||||
_paCaptureBuffer(NULL),
|
||||
_paRenderBuffer(NULL),
|
||||
_captureBufSizeSamples(0),
|
||||
|
@ -340,11 +336,6 @@ AudioDeviceGeneric::InitStatus AudioDeviceMac::Init() {
|
|||
}
|
||||
}
|
||||
|
||||
_playWarning = 0;
|
||||
_playError = 0;
|
||||
_recWarning = 0;
|
||||
_recError = 0;
|
||||
|
||||
get_mic_volume_counter_ms_ = 0;
|
||||
|
||||
_initialized = true;
|
||||
|
@ -1573,38 +1564,6 @@ bool AudioDeviceMac::Playing() const {
|
|||
return (_playing);
|
||||
}
|
||||
|
||||
bool AudioDeviceMac::PlayoutWarning() const {
|
||||
return (_playWarning > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceMac::PlayoutError() const {
|
||||
return (_playError > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceMac::RecordingWarning() const {
|
||||
return (_recWarning > 0);
|
||||
}
|
||||
|
||||
bool AudioDeviceMac::RecordingError() const {
|
||||
return (_recError > 0);
|
||||
}
|
||||
|
||||
void AudioDeviceMac::ClearPlayoutWarning() {
|
||||
_playWarning = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceMac::ClearPlayoutError() {
|
||||
_playError = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceMac::ClearRecordingWarning() {
|
||||
_recWarning = 0;
|
||||
}
|
||||
|
||||
void AudioDeviceMac::ClearRecordingError() {
|
||||
_recError = 0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Private Methods
|
||||
// ============================================================================
|
||||
|
@ -2017,10 +1976,6 @@ int32_t AudioDeviceMac::HandleDeviceChange() {
|
|||
LOG(LS_WARNING) << "Capture device is not alive (probably removed)";
|
||||
AtomicSet32(&_captureDeviceIsAlive, 0);
|
||||
_mixerManager.CloseMicrophone();
|
||||
if (_recError == 1) {
|
||||
LOG(LS_WARNING) << "pending recording error exists";
|
||||
}
|
||||
_recError = 1; // triggers callback from module process thread
|
||||
} else if (err != noErr) {
|
||||
logCAMsg(rtc::LS_ERROR,
|
||||
"Error in AudioDeviceGetProperty()", (const char*)&err);
|
||||
|
@ -2040,10 +1995,6 @@ int32_t AudioDeviceMac::HandleDeviceChange() {
|
|||
LOG(LS_WARNING) << "Render device is not alive (probably removed)";
|
||||
AtomicSet32(&_renderDeviceIsAlive, 0);
|
||||
_mixerManager.CloseSpeaker();
|
||||
if (_playError == 1) {
|
||||
LOG(LS_WARNING) << "pending playout error exists";
|
||||
}
|
||||
_playError = 1; // triggers callback from module process thread
|
||||
} else if (err != noErr) {
|
||||
logCAMsg(rtc::LS_ERROR,
|
||||
"Error in AudioDeviceGetProperty()", (const char*)&err);
|
||||
|
|
|
@ -153,15 +153,6 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
|||
virtual int32_t PlayoutDelay(uint16_t& delayMS) const;
|
||||
virtual int32_t RecordingDelay(uint16_t& delayMS) const;
|
||||
|
||||
virtual bool PlayoutWarning() const;
|
||||
virtual bool PlayoutError() const;
|
||||
virtual bool RecordingWarning() const;
|
||||
virtual bool RecordingError() const;
|
||||
virtual void ClearPlayoutWarning();
|
||||
virtual void ClearPlayoutError();
|
||||
virtual void ClearRecordingWarning();
|
||||
virtual void ClearRecordingError();
|
||||
|
||||
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
|
||||
|
||||
private:
|
||||
|
@ -333,11 +324,6 @@ class AudioDeviceMac : public AudioDeviceGeneric {
|
|||
|
||||
int32_t _renderDelayOffsetSamples;
|
||||
|
||||
uint16_t _playWarning;
|
||||
uint16_t _playError;
|
||||
uint16_t _recWarning;
|
||||
uint16_t _recError;
|
||||
|
||||
PaUtilRingBuffer* _paCaptureBuffer;
|
||||
PaUtilRingBuffer* _paRenderBuffer;
|
||||
|
||||
|
|
|
@ -464,10 +464,6 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore()
|
|||
_speakerIsInitialized(false),
|
||||
_microphoneIsInitialized(false),
|
||||
_AGC(false),
|
||||
_playWarning(0),
|
||||
_playError(0),
|
||||
_recWarning(0),
|
||||
_recError(0),
|
||||
_playBufDelay(80),
|
||||
_usingInputDeviceIndex(false),
|
||||
_usingOutputDeviceIndex(false),
|
||||
|
@ -685,11 +681,6 @@ AudioDeviceGeneric::InitStatus AudioDeviceWindowsCore::Init() {
|
|||
return InitStatus::OK;
|
||||
}
|
||||
|
||||
_playWarning = 0;
|
||||
_playError = 0;
|
||||
_recWarning = 0;
|
||||
_recError = 0;
|
||||
|
||||
// Enumerate all audio rendering and capturing endpoint devices.
|
||||
// Note that, some of these will not be able to select by the user.
|
||||
// The complete collection is for internal use only.
|
||||
|
@ -3061,78 +3052,6 @@ bool AudioDeviceWindowsCore::Playing() const
|
|||
return (_playing);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PlayoutWarning
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool AudioDeviceWindowsCore::PlayoutWarning() const
|
||||
{
|
||||
return ( _playWarning > 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PlayoutError
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool AudioDeviceWindowsCore::PlayoutError() const
|
||||
{
|
||||
return ( _playError > 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// RecordingWarning
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool AudioDeviceWindowsCore::RecordingWarning() const
|
||||
{
|
||||
return ( _recWarning > 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// RecordingError
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool AudioDeviceWindowsCore::RecordingError() const
|
||||
{
|
||||
return ( _recError > 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ClearPlayoutWarning
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AudioDeviceWindowsCore::ClearPlayoutWarning()
|
||||
{
|
||||
_playWarning = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ClearPlayoutError
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AudioDeviceWindowsCore::ClearPlayoutError()
|
||||
{
|
||||
_playError = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ClearRecordingWarning
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AudioDeviceWindowsCore::ClearRecordingWarning()
|
||||
{
|
||||
_recWarning = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ClearRecordingError
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AudioDeviceWindowsCore::ClearRecordingError()
|
||||
{
|
||||
_recError = 0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Private Methods
|
||||
// ============================================================================
|
||||
|
@ -3522,11 +3441,8 @@ Exit:
|
|||
_TraceCOMError(hr);
|
||||
}
|
||||
}
|
||||
// Trigger callback from module process thread
|
||||
_playError = 1;
|
||||
LOG(LS_ERROR)
|
||||
<< "kPlayoutError message posted: rendering thread has ended"
|
||||
<< " pre-maturely";
|
||||
<< "Playout error: rendering thread has ended pre-maturely";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3709,10 +3625,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO()
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// Trigger callback from module process thread
|
||||
_recError = 1;
|
||||
LOG(LS_ERROR) << "kRecordingError message posted: capturing thread has"
|
||||
<< " ended prematurely";
|
||||
LOG(LS_ERROR)
|
||||
<< "Recording error: capturing thread has ended prematurely";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4012,11 +3926,8 @@ Exit:
|
|||
}
|
||||
}
|
||||
|
||||
// Trigger callback from module process thread
|
||||
_recError = 1;
|
||||
LOG(LS_ERROR)
|
||||
<< "kRecordingError message posted: capturing thread has ended"
|
||||
<< " pre-maturely";
|
||||
<< "Recording error: capturing thread has ended pre-maturely";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -177,16 +177,6 @@ public:
|
|||
|
||||
virtual int32_t EnableBuiltInAEC(bool enable);
|
||||
|
||||
public:
|
||||
virtual bool PlayoutWarning() const;
|
||||
virtual bool PlayoutError() const;
|
||||
virtual bool RecordingWarning() const;
|
||||
virtual bool RecordingError() const;
|
||||
virtual void ClearPlayoutWarning();
|
||||
virtual void ClearPlayoutError();
|
||||
virtual void ClearRecordingWarning();
|
||||
virtual void ClearRecordingError();
|
||||
|
||||
public:
|
||||
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
|
||||
|
||||
|
@ -332,11 +322,6 @@ private:
|
|||
|
||||
bool _AGC;
|
||||
|
||||
uint16_t _playWarning;
|
||||
uint16_t _playError;
|
||||
uint16_t _recWarning;
|
||||
uint16_t _recError;
|
||||
|
||||
uint16_t _playBufDelay;
|
||||
|
||||
uint16_t _newMicLevel;
|
||||
|
|
|
@ -58,24 +58,6 @@ class Module {
|
|||
protected:
|
||||
virtual ~Module() {}
|
||||
};
|
||||
|
||||
// Reference counted version of the Module interface.
|
||||
class RefCountedModule : public Module {
|
||||
public:
|
||||
// Increase the reference count by one.
|
||||
// Returns the incremented reference count.
|
||||
virtual int32_t AddRef() const = 0;
|
||||
|
||||
// Decrease the reference count by one.
|
||||
// Returns the decreased reference count.
|
||||
// Returns 0 if the last reference was just released.
|
||||
// When the reference count reaches 0 the object will self-destruct.
|
||||
virtual int32_t Release() const = 0;
|
||||
|
||||
protected:
|
||||
~RefCountedModule() override = default;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_INCLUDE_MODULE_H_
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
// Even simpler buffers would likely just contain audio sample values of 0.
|
||||
static const int kHighSampleValue = 10000;
|
||||
|
||||
// Same value as src/modules/audio_device/main/source/audio_device_config.h in
|
||||
// https://code.google.com/p/webrtc/
|
||||
static const int kAdmMaxIdleTimeProcess = 1000;
|
||||
|
||||
// Constants here are derived by running VoE using a real ADM.
|
||||
// The constants correspond to 10ms of mono audio at 44kHz.
|
||||
static const int kTimePerFrameMs = 10;
|
||||
|
@ -40,8 +36,7 @@ enum {
|
|||
};
|
||||
|
||||
FakeAudioCaptureModule::FakeAudioCaptureModule()
|
||||
: last_process_time_ms_(0),
|
||||
audio_callback_(nullptr),
|
||||
: audio_callback_(nullptr),
|
||||
recording_(false),
|
||||
playing_(false),
|
||||
play_is_initialized_(false),
|
||||
|
@ -72,23 +67,6 @@ int FakeAudioCaptureModule::frames_received() const {
|
|||
return frames_received_;
|
||||
}
|
||||
|
||||
int64_t FakeAudioCaptureModule::TimeUntilNextProcess() {
|
||||
const int64_t current_time = rtc::TimeMillis();
|
||||
if (current_time < last_process_time_ms_) {
|
||||
// TODO: wraparound could be handled more gracefully.
|
||||
return 0;
|
||||
}
|
||||
const int64_t elapsed_time = current_time - last_process_time_ms_;
|
||||
if (kAdmMaxIdleTimeProcess < elapsed_time) {
|
||||
return 0;
|
||||
}
|
||||
return kAdmMaxIdleTimeProcess - elapsed_time;
|
||||
}
|
||||
|
||||
void FakeAudioCaptureModule::Process() {
|
||||
last_process_time_ms_ = rtc::TimeMillis();
|
||||
}
|
||||
|
||||
int32_t FakeAudioCaptureModule::ActiveAudioLayer(
|
||||
AudioLayer* /*audio_layer*/) const {
|
||||
RTC_NOTREACHED();
|
||||
|
@ -100,13 +78,6 @@ webrtc::AudioDeviceModule::ErrorCode FakeAudioCaptureModule::LastError() const {
|
|||
return webrtc::AudioDeviceModule::kAdmErrNone;
|
||||
}
|
||||
|
||||
int32_t FakeAudioCaptureModule::RegisterEventObserver(
|
||||
webrtc::AudioDeviceObserver* /*event_callback*/) {
|
||||
// Only used to report warnings and errors. This fake implementation won't
|
||||
// generate any so discard this callback.
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t FakeAudioCaptureModule::RegisterAudioCallback(
|
||||
webrtc::AudioTransport* audio_callback) {
|
||||
rtc::CritScope cs(&crit_callback_);
|
||||
|
@ -505,7 +476,6 @@ bool FakeAudioCaptureModule::Initialize() {
|
|||
// sent to it. Note that the audio processing pipeline will likely distort the
|
||||
// original signal.
|
||||
SetSendBuffer(kHighSampleValue);
|
||||
last_process_time_ms_ = rtc::TimeMillis();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,18 +52,9 @@ class FakeAudioCaptureModule
|
|||
// pulled frame was generated/pushed from a FakeAudioCaptureModule.
|
||||
int frames_received() const;
|
||||
|
||||
// Following functions are inherited from webrtc::AudioDeviceModule.
|
||||
// Only functions called by PeerConnection are implemented, the rest do
|
||||
// nothing and return success. If a function is not expected to be called by
|
||||
// PeerConnection an assertion is triggered if it is in fact called.
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
void Process() override;
|
||||
|
||||
int32_t ActiveAudioLayer(AudioLayer* audio_layer) const override;
|
||||
|
||||
ErrorCode LastError() const override;
|
||||
int32_t RegisterEventObserver(
|
||||
webrtc::AudioDeviceObserver* event_callback) override;
|
||||
|
||||
// Note: Calling this method from a callback may result in deadlock.
|
||||
int32_t RegisterAudioCallback(
|
||||
|
@ -210,10 +201,6 @@ class FakeAudioCaptureModule
|
|||
// Pushes frames to the registered webrtc::AudioTransport.
|
||||
void SendFrameP();
|
||||
|
||||
// The time in milliseconds when Process() was last called or 0 if no call
|
||||
// has been made.
|
||||
int64_t last_process_time_ms_;
|
||||
|
||||
// Callback for playout and recording.
|
||||
webrtc::AudioTransport* audio_callback_;
|
||||
|
||||
|
|
|
@ -133,14 +133,6 @@ class FakeAdmTest : public testing::Test,
|
|||
size_t rec_buffer_bytes_;
|
||||
};
|
||||
|
||||
TEST_F(FakeAdmTest, TestProcess) {
|
||||
// Next process call must be some time in the future (or now).
|
||||
EXPECT_LE(0, fake_audio_capture_module_->TimeUntilNextProcess());
|
||||
// Process call updates TimeUntilNextProcess() but there are no guarantees on
|
||||
// timing so just check that Process can be called successfully.
|
||||
fake_audio_capture_module_->Process();
|
||||
}
|
||||
|
||||
TEST_F(FakeAdmTest, PlayoutTest) {
|
||||
EXPECT_EQ(0, fake_audio_capture_module_->RegisterAudioCallback(this));
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ class MockVoiceEngine : public VoiceEngineImpl {
|
|||
return proxy;
|
||||
}));
|
||||
|
||||
ON_CALL(mock_audio_device_, TimeUntilNextProcess())
|
||||
.WillByDefault(testing::Return(1000));
|
||||
ON_CALL(*this, audio_device_module())
|
||||
.WillByDefault(testing::Return(&mock_audio_device_));
|
||||
ON_CALL(*this, audio_transport())
|
||||
|
|
|
@ -41,22 +41,6 @@ VoEBaseImpl::~VoEBaseImpl() {
|
|||
TerminateInternal();
|
||||
}
|
||||
|
||||
void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) {
|
||||
if (error == AudioDeviceObserver::kRecordingError) {
|
||||
LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR";
|
||||
} else if (error == AudioDeviceObserver::kPlayoutError) {
|
||||
LOG_F(LS_ERROR) << "VE_RUNTIME_PLAY_ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) {
|
||||
if (warning == AudioDeviceObserver::kRecordingWarning) {
|
||||
LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING";
|
||||
} else if (warning == AudioDeviceObserver::kPlayoutWarning) {
|
||||
LOG_F(LS_WARNING) << "VE_RUNTIME_PLAY_WARNING";
|
||||
}
|
||||
}
|
||||
|
||||
int32_t VoEBaseImpl::RecordedDataIsAvailable(
|
||||
const void* audio_data,
|
||||
const size_t number_of_frames,
|
||||
|
@ -191,23 +175,11 @@ int VoEBaseImpl::Init(
|
|||
<< "An external ADM implementation will be used in VoiceEngine";
|
||||
}
|
||||
|
||||
// Register the ADM to the process thread, which will drive the error
|
||||
// callback mechanism
|
||||
if (shared_->process_thread()) {
|
||||
shared_->process_thread()->RegisterModule(shared_->audio_device(),
|
||||
RTC_FROM_HERE);
|
||||
}
|
||||
|
||||
bool available = false;
|
||||
|
||||
// --------------------
|
||||
// Reinitialize the ADM
|
||||
|
||||
// Register the AudioObserver implementation
|
||||
if (shared_->audio_device()->RegisterEventObserver(this) != 0) {
|
||||
LOG(LS_ERROR) << "Init() failed to register event observer for the ADM";
|
||||
}
|
||||
|
||||
// Register the AudioTransport implementation
|
||||
if (shared_->audio_device()->RegisterAudioCallback(this) != 0) {
|
||||
LOG(LS_ERROR) << "Init() failed to register audio callback for the ADM";
|
||||
|
@ -489,9 +461,6 @@ int32_t VoEBaseImpl::TerminateInternal() {
|
|||
shared_->channel_manager().DestroyAllChannels();
|
||||
|
||||
if (shared_->process_thread()) {
|
||||
if (shared_->audio_device()) {
|
||||
shared_->process_thread()->DeRegisterModule(shared_->audio_device());
|
||||
}
|
||||
shared_->process_thread()->Stop();
|
||||
}
|
||||
|
||||
|
@ -502,10 +471,6 @@ int32_t VoEBaseImpl::TerminateInternal() {
|
|||
if (shared_->audio_device()->StopRecording() != 0) {
|
||||
LOG(LS_ERROR) << "TerminateInternal() failed to stop recording";
|
||||
}
|
||||
if (shared_->audio_device()->RegisterEventObserver(nullptr) != 0) {
|
||||
LOG(LS_ERROR) << "TerminateInternal() failed to de-register event "
|
||||
"observer for the ADM";
|
||||
}
|
||||
if (shared_->audio_device()->RegisterAudioCallback(nullptr) != 0) {
|
||||
LOG(LS_ERROR) << "TerminateInternal() failed to de-register audio "
|
||||
"callback for the ADM";
|
||||
|
|
|
@ -22,8 +22,7 @@ namespace webrtc {
|
|||
class ProcessThread;
|
||||
|
||||
class VoEBaseImpl : public VoEBase,
|
||||
public AudioTransport,
|
||||
public AudioDeviceObserver {
|
||||
public AudioTransport {
|
||||
public:
|
||||
int Init(
|
||||
AudioDeviceModule* external_adm,
|
||||
|
@ -81,10 +80,6 @@ class VoEBaseImpl : public VoEBase,
|
|||
int64_t* elapsed_time_ms,
|
||||
int64_t* ntp_time_ms) override;
|
||||
|
||||
// AudioDeviceObserver
|
||||
void OnErrorIsReported(const ErrorCode error) override;
|
||||
void OnWarningIsReported(const WarningCode warning) override;
|
||||
|
||||
protected:
|
||||
VoEBaseImpl(voe::SharedData* shared);
|
||||
~VoEBaseImpl() override;
|
||||
|
|
Loading…
Reference in a new issue