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:
Fredrik Solenberg
2017-10-02 14:55:33 +02:00
committed by Commit Bot
parent c007857ab9
commit 34cdd2d402
35 changed files with 14 additions and 698 deletions

View File

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