Revert "Remove AudioDeviceObserver and make ADM not inherit from the Module interface."

This reverts commit 34cdd2d402b08aee4e17a6fd38c87e0e5cd7aa30.

Reason for revert: Breaks Chromium

Original change's description:
> 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}

TBR=solenberg@webrtc.org,henrika@webrtc.org

Change-Id: Iad03cafb7865f5a22394c3d4d1d3ff3e0fccd4ff
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:4690, webrtc:7306
Reviewed-on: https://webrtc-review.googlesource.com/5402
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20085}
This commit is contained in:
Fredrik Solenberg
2017-10-02 15:08:56 +00:00
committed by Commit Bot
parent bee50d90fc
commit d4404c232d
35 changed files with 698 additions and 14 deletions

View File

@ -54,6 +54,10 @@ AudioDeviceLinuxPulse::AudioDeviceLinuxPulse()
_sndCardPlayDelay(0),
_sndCardRecDelay(0),
_writeErrors(0),
_playWarning(0),
_playError(0),
_recWarning(0),
_recError(0),
_deviceIndex(-1),
_numPlayDevices(0),
_numRecDevices(0),
@ -156,6 +160,11 @@ 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) {
@ -1283,6 +1292,46 @@ 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
// ============================================================================
@ -2142,7 +2191,12 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() {
NULL, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) {
_writeErrors++;
if (_writeErrors > 10) {
LOG(LS_ERROR) << "Playout error: _writeErrors="
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="
<< _writeErrors
<< ", error=" << LATE(pa_context_errno)(_paContext);
_writeErrors = 0;
@ -2186,7 +2240,12 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() {
NULL, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) {
_writeErrors++;
if (_writeErrors > 10) {
LOG(LS_ERROR) << "Playout error: _writeErrors="
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="
<< _writeErrors
<< ", error=" << LATE(pa_context_errno)(_paContext);
_writeErrors = 0;
@ -2299,7 +2358,8 @@ bool AudioDeviceLinuxPulse::RecThreadProcess() {
size_t sampleDataSize;
if (LATE(pa_stream_peek)(_recStream, &sampleData, &sampleDataSize) != 0) {
LOG(LS_ERROR) << "RECORD_ERROR, error = "
_recError = 1; // triggers callback from module process thread
LOG(LS_ERROR) << "RECORD_ERROR message posted, error = "
<< LATE(pa_context_errno)(_paContext);
break;
}