Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1693)

Unified Diff: webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
diff --git a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
index e408f22066f30c15eaf2352753cc2a43905e0e35..94111a2f6d4c4baf23844e6cab2352ee78c317e2 100644
--- a/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
+++ b/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
@@ -28,77 +28,75 @@ webrtc_adm_linux_pulse::PulseAudioSymbolTable PaSymbolTable;
namespace webrtc
{
-AudioDeviceLinuxPulse::AudioDeviceLinuxPulse(const int32_t id) :
- _ptrAudioBuffer(NULL),
- _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
- _timeEventRec(*EventWrapper::Create()),
- _timeEventPlay(*EventWrapper::Create()),
- _recStartEvent(*EventWrapper::Create()),
- _playStartEvent(*EventWrapper::Create()),
- _id(id),
- _mixerManager(id),
- _inputDeviceIndex(0),
- _outputDeviceIndex(0),
- _inputDeviceIsSpecified(false),
- _outputDeviceIsSpecified(false),
- sample_rate_hz_(0),
- _recChannels(1),
- _playChannels(1),
- _playBufType(AudioDeviceModule::kFixedBufferSize),
- _initialized(false),
- _recording(false),
- _playing(false),
- _recIsInitialized(false),
- _playIsInitialized(false),
- _startRec(false),
- _stopRec(false),
- _startPlay(false),
- _stopPlay(false),
- _AGC(false),
- update_speaker_volume_at_startup_(false),
- _playBufDelayFixed(20),
- _sndCardPlayDelay(0),
- _sndCardRecDelay(0),
- _writeErrors(0),
- _playWarning(0),
- _playError(0),
- _recWarning(0),
- _recError(0),
- _deviceIndex(-1),
- _numPlayDevices(0),
- _numRecDevices(0),
- _playDeviceName(NULL),
- _recDeviceName(NULL),
- _playDisplayDeviceName(NULL),
- _recDisplayDeviceName(NULL),
- _playBuffer(NULL),
- _playbackBufferSize(0),
- _playbackBufferUnused(0),
- _tempBufferSpace(0),
- _recBuffer(NULL),
- _recordBufferSize(0),
- _recordBufferUsed(0),
- _tempSampleData(NULL),
- _tempSampleDataSize(0),
- _configuredLatencyPlay(0),
- _configuredLatencyRec(0),
- _paDeviceIndex(-1),
- _paStateChanged(false),
- _paMainloop(NULL),
- _paMainloopApi(NULL),
- _paContext(NULL),
- _recStream(NULL),
- _playStream(NULL),
- _recStreamFlags(0),
- _playStreamFlags(0)
-{
- WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id,
- "%s created", __FUNCTION__);
-
- memset(_paServerVersion, 0, sizeof(_paServerVersion));
- memset(&_playBufferAttr, 0, sizeof(_playBufferAttr));
- memset(&_recBufferAttr, 0, sizeof(_recBufferAttr));
- memset(_oldKeyState, 0, sizeof(_oldKeyState));
+AudioDeviceLinuxPulse::AudioDeviceLinuxPulse(const int32_t id)
+ : _ptrAudioBuffer(nullptr),
+ _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
+ _timeEventRec(*EventWrapper::Create()),
+ _timeEventPlay(*EventWrapper::Create()),
+ _recStartEvent(*EventWrapper::Create()),
+ _playStartEvent(*EventWrapper::Create()),
+ _id(id),
+ _mixerManager(id),
+ _inputDeviceIndex(0),
+ _outputDeviceIndex(0),
+ _inputDeviceIsSpecified(false),
+ _outputDeviceIsSpecified(false),
+ sample_rate_hz_(0),
+ _recChannels(1),
+ _playChannels(1),
+ _playBufType(AudioDeviceModule::kFixedBufferSize),
+ _initialized(false),
+ _recording(false),
+ _playing(false),
+ _recIsInitialized(false),
+ _playIsInitialized(false),
+ _startRec(false),
+ _stopRec(false),
+ _startPlay(false),
+ _stopPlay(false),
+ _AGC(false),
+ update_speaker_volume_at_startup_(false),
+ _playBufDelayFixed(20),
+ _sndCardPlayDelay(0),
+ _sndCardRecDelay(0),
+ _writeErrors(0),
+ _playWarning(0),
+ _playError(0),
+ _recWarning(0),
+ _recError(0),
+ _deviceIndex(-1),
+ _numPlayDevices(0),
+ _numRecDevices(0),
+ _playDeviceName(nullptr),
+ _recDeviceName(nullptr),
+ _playDisplayDeviceName(nullptr),
+ _recDisplayDeviceName(nullptr),
+ _playBuffer(nullptr),
+ _playbackBufferSize(0),
+ _playbackBufferUnused(0),
+ _tempBufferSpace(0),
+ _recBuffer(nullptr),
+ _recordBufferSize(0),
+ _recordBufferUsed(0),
+ _tempSampleData(nullptr),
+ _tempSampleDataSize(0),
+ _configuredLatencyPlay(0),
+ _configuredLatencyRec(0),
+ _paDeviceIndex(-1),
+ _paStateChanged(false),
+ _paMainloop(nullptr),
+ _paMainloopApi(nullptr),
+ _paContext(nullptr),
+ _recStream(nullptr),
+ _playStream(nullptr),
+ _recStreamFlags(0),
+ _playStreamFlags(0) {
+ WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__);
+
+ memset(_paServerVersion, 0, sizeof(_paServerVersion));
+ memset(&_playBufferAttr, 0, sizeof(_playBufferAttr));
+ memset(&_recBufferAttr, 0, sizeof(_recBufferAttr));
+ memset(_oldKeyState, 0, sizeof(_oldKeyState));
}
AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse()
@@ -111,22 +109,22 @@ AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse()
if (_recBuffer)
{
delete [] _recBuffer;
- _recBuffer = NULL;
+ _recBuffer = nullptr;
}
if (_playBuffer)
{
delete [] _playBuffer;
- _playBuffer = NULL;
+ _playBuffer = nullptr;
}
if (_playDeviceName)
{
delete [] _playDeviceName;
- _playDeviceName = NULL;
+ _playDeviceName = nullptr;
}
if (_recDeviceName)
{
delete [] _recDeviceName;
- _recDeviceName = NULL;
+ _recDeviceName = nullptr;
}
delete &_recStartEvent;
@@ -183,7 +181,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceLinuxPulse::Init() {
_recError = 0;
// Get X display handle for typing detection
- _XDisplay = XOpenDisplay(NULL);
+ _XDisplay = XOpenDisplay(nullptr);
if (!_XDisplay) {
LOG(LS_WARNING)
<< "failed to open X display, typing detection will not work";
@@ -248,7 +246,7 @@ int32_t AudioDeviceLinuxPulse::Terminate()
if (_XDisplay)
{
XCloseDisplay(_XDisplay);
- _XDisplay = NULL;
+ _XDisplay = nullptr;
}
_initialized = false;
@@ -282,7 +280,7 @@ int32_t AudioDeviceLinuxPulse::InitSpeaker()
if (_outputDeviceIndex == 0)
{
uint16_t deviceIndex = 0;
- GetDefaultDeviceInfo(false, NULL, deviceIndex);
+ GetDefaultDeviceInfo(false, nullptr, deviceIndex);
_paDeviceIndex = deviceIndex;
} else
{
@@ -325,7 +323,7 @@ int32_t AudioDeviceLinuxPulse::InitMicrophone()
if (_inputDeviceIndex == 0)
{
uint16_t deviceIndex = 0;
- GetDefaultDeviceInfo(true, NULL, deviceIndex);
+ GetDefaultDeviceInfo(true, nullptr, deviceIndex);
_paDeviceIndex = deviceIndex;
} else
{
@@ -867,7 +865,7 @@ int16_t AudioDeviceLinuxPulse::PlayoutDevices()
{
PaLock();
- pa_operation* paOperation = NULL;
+ pa_operation* paOperation = nullptr;
_numPlayDevices = 1; // init to 1 to account for "default"
// get the whole list of devices and update _numPlayDevices
@@ -924,16 +922,14 @@ int32_t AudioDeviceLinuxPulse::PlayoutDeviceName(
RTC_DCHECK(thread_checker_.CalledOnValidThread());
const uint16_t nDevices = PlayoutDevices();
- if ((index > (nDevices - 1)) || (name == NULL))
- {
- return -1;
+ if ((index > (nDevices - 1)) || (name == nullptr)) {
+ return -1;
}
memset(name, 0, kAdmMaxDeviceNameSize);
- if (guid != NULL)
- {
- memset(guid, 0, kAdmMaxGuidSize);
+ if (guid != nullptr) {
+ memset(guid, 0, kAdmMaxGuidSize);
}
// Check if default device
@@ -952,7 +948,7 @@ int32_t AudioDeviceLinuxPulse::PlayoutDeviceName(
PlayoutDevices();
// clear device name and index
- _playDisplayDeviceName = NULL;
+ _playDisplayDeviceName = nullptr;
_deviceIndex = -1;
return 0;
@@ -966,16 +962,14 @@ int32_t AudioDeviceLinuxPulse::RecordingDeviceName(
RTC_DCHECK(thread_checker_.CalledOnValidThread());
const uint16_t nDevices(RecordingDevices());
- if ((index > (nDevices - 1)) || (name == NULL))
- {
- return -1;
+ if ((index > (nDevices - 1)) || (name == nullptr)) {
+ return -1;
}
memset(name, 0, kAdmMaxDeviceNameSize);
- if (guid != NULL)
- {
- memset(guid, 0, kAdmMaxGuidSize);
+ if (guid != nullptr) {
+ memset(guid, 0, kAdmMaxGuidSize);
}
// Check if default device
@@ -994,7 +988,7 @@ int32_t AudioDeviceLinuxPulse::RecordingDeviceName(
RecordingDevices();
// Clear device name and index
- _recDisplayDeviceName = NULL;
+ _recDisplayDeviceName = nullptr;
_deviceIndex = -1;
return 0;
@@ -1004,7 +998,7 @@ int16_t AudioDeviceLinuxPulse::RecordingDevices()
{
PaLock();
- pa_operation* paOperation = NULL;
+ pa_operation* paOperation = nullptr;
_numRecDevices = 1; // Init to 1 to account for "default"
// Get the whole list of devices and update _numRecDevices
@@ -1124,8 +1118,8 @@ int32_t AudioDeviceLinuxPulse::InitPlayout()
playSampleSpec.rate = sample_rate_hz_;
// Create a new play stream
- _playStream = LATE(pa_stream_new)(_paContext, "playStream",
- &playSampleSpec, NULL);
+ _playStream =
+ LATE(pa_stream_new)(_paContext, "playStream", &playSampleSpec, nullptr);
if (!_playStream)
{
@@ -1246,8 +1240,8 @@ int32_t AudioDeviceLinuxPulse::InitRecording()
recSampleSpec.rate = sample_rate_hz_;
// Create a new rec stream
- _recStream = LATE(pa_stream_new)(_paContext, "recStream", &recSampleSpec,
- NULL);
+ _recStream =
+ LATE(pa_stream_new)(_paContext, "recStream", &recSampleSpec, nullptr);
if (!_recStream)
{
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
@@ -1382,9 +1376,8 @@ int32_t AudioDeviceLinuxPulse::StopRecording()
return 0;
}
- if (_recStream == NULL)
- {
- return -1;
+ if (_recStream == nullptr) {
+ return -1;
}
_recIsInitialized = false;
@@ -1397,10 +1390,10 @@ int32_t AudioDeviceLinuxPulse::StopRecording()
PaLock();
DisableReadCallback();
- LATE(pa_stream_set_overflow_callback)(_recStream, NULL, NULL);
+ LATE(pa_stream_set_overflow_callback)(_recStream, nullptr, nullptr);
// Unset this here so that we don't get a TERMINATED callback
- LATE(pa_stream_set_state_callback)(_recStream, NULL, NULL);
+ LATE(pa_stream_set_state_callback)(_recStream, nullptr, nullptr);
if (LATE(pa_stream_get_state)(_recStream) != PA_STREAM_UNCONNECTED)
{
@@ -1419,7 +1412,7 @@ int32_t AudioDeviceLinuxPulse::StopRecording()
}
LATE(pa_stream_unref)(_recStream);
- _recStream = NULL;
+ _recStream = nullptr;
PaUnLock();
@@ -1429,7 +1422,7 @@ int32_t AudioDeviceLinuxPulse::StopRecording()
if (_recBuffer)
{
delete [] _recBuffer;
- _recBuffer = NULL;
+ _recBuffer = nullptr;
}
return 0;
@@ -1517,9 +1510,8 @@ int32_t AudioDeviceLinuxPulse::StopPlayout()
return 0;
}
- if (_playStream == NULL)
- {
- return -1;
+ if (_playStream == nullptr) {
+ return -1;
}
_playIsInitialized = false;
@@ -1534,10 +1526,10 @@ int32_t AudioDeviceLinuxPulse::StopPlayout()
PaLock();
DisableWriteCallback();
- LATE(pa_stream_set_underflow_callback)(_playStream, NULL, NULL);
+ LATE(pa_stream_set_underflow_callback)(_playStream, nullptr, nullptr);
// Unset this here so that we don't get a TERMINATED callback
- LATE(pa_stream_set_state_callback)(_playStream, NULL, NULL);
+ LATE(pa_stream_set_state_callback)(_playStream, nullptr, nullptr);
if (LATE(pa_stream_get_state)(_playStream) != PA_STREAM_UNCONNECTED)
{
@@ -1556,7 +1548,7 @@ int32_t AudioDeviceLinuxPulse::StopPlayout()
}
LATE(pa_stream_unref)(_playStream);
- _playStream = NULL;
+ _playStream = nullptr;
PaUnLock();
@@ -1566,7 +1558,7 @@ int32_t AudioDeviceLinuxPulse::StopPlayout()
if (_playBuffer)
{
delete [] _playBuffer;
- _playBuffer = NULL;
+ _playBuffer = nullptr;
}
return 0;
@@ -1889,7 +1881,7 @@ int32_t AudioDeviceLinuxPulse::CheckPulseAudioVersion()
{
PaLock();
- pa_operation* paOperation = NULL;
+ pa_operation* paOperation = nullptr;
// get the server info and update deviceName
paOperation = LATE(pa_context_get_server_info)(_paContext,
@@ -1910,7 +1902,7 @@ int32_t AudioDeviceLinuxPulse::InitSamplingFrequency()
{
PaLock();
- pa_operation* paOperation = NULL;
+ pa_operation* paOperation = nullptr;
// Get the server info and update sample_rate_hz_
paOperation = LATE(pa_context_get_server_info)(_paContext,
@@ -1931,7 +1923,7 @@ int32_t AudioDeviceLinuxPulse::GetDefaultDeviceInfo(bool recDevice,
char tmpName[kAdmMaxDeviceNameSize] = {0};
// subtract length of "default: "
uint16_t nameLen = kAdmMaxDeviceNameSize - 9;
- char* pName = NULL;
+ char* pName = nullptr;
if (name)
{
@@ -1958,7 +1950,7 @@ int32_t AudioDeviceLinuxPulse::GetDefaultDeviceInfo(bool recDevice,
PaLock();
- pa_operation* paOperation = NULL;
+ pa_operation* paOperation = nullptr;
// Get the server info and update deviceName
paOperation = LATE(pa_context_get_server_info)(_paContext,
@@ -1998,8 +1990,8 @@ int32_t AudioDeviceLinuxPulse::GetDefaultDeviceInfo(bool recDevice,
}
// Clear members
- _playDisplayDeviceName = NULL;
- _recDisplayDeviceName = NULL;
+ _playDisplayDeviceName = nullptr;
+ _recDisplayDeviceName = nullptr;
_paDeviceIndex = -1;
_deviceIndex = -1;
_numPlayDevices = 0;
@@ -2083,10 +2075,8 @@ int32_t AudioDeviceLinuxPulse::InitPulseAudio()
// Connect the context to a server (default)
_paStateChanged = false;
- retVal = LATE(pa_context_connect)(_paContext,
- NULL,
- PA_CONTEXT_NOAUTOSPAWN,
- NULL);
+ retVal = LATE(pa_context_connect)(_paContext, nullptr,
+ PA_CONTEXT_NOAUTOSPAWN, nullptr);
if (retVal != PA_OK)
{
@@ -2176,7 +2166,7 @@ int32_t AudioDeviceLinuxPulse::TerminatePulseAudio()
}
PaUnLock();
- _paContext = NULL;
+ _paContext = nullptr;
// Stop the threaded main loop
if (_paMainloop)
@@ -2190,7 +2180,7 @@ int32_t AudioDeviceLinuxPulse::TerminatePulseAudio()
LATE(pa_threaded_mainloop_free)(_paMainloop);
}
- _paMainloop = NULL;
+ _paMainloop = nullptr;
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id,
" PulseAudio terminated");
@@ -2213,9 +2203,9 @@ void AudioDeviceLinuxPulse::WaitForOperationCompletion(
{
if (!paOperation)
{
- WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
- "paOperation NULL in WaitForOperationCompletion");
- return;
+ WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
+ "paOperation null in WaitForOperationCompletion");
+ return;
}
while (LATE(pa_operation_get_state)(paOperation) == PA_OPERATION_RUNNING)
@@ -2252,7 +2242,7 @@ void AudioDeviceLinuxPulse::EnableWriteCallback()
void AudioDeviceLinuxPulse::DisableWriteCallback()
{
- LATE(pa_stream_set_write_callback)(_playStream, NULL, NULL);
+ LATE(pa_stream_set_write_callback)(_playStream, nullptr, nullptr);
}
void AudioDeviceLinuxPulse::PaStreamWriteCallback(pa_stream */*unused*/,
@@ -2314,9 +2304,8 @@ void AudioDeviceLinuxPulse::PaStreamUnderflowCallbackHandler()
_playBufferAttr.minreq = newLatency / WEBRTC_PA_PLAYBACK_REQUEST_FACTOR;
_playBufferAttr.prebuf = _playBufferAttr.tlength - _playBufferAttr.minreq;
- pa_operation *op = LATE(pa_stream_set_buffer_attr)(_playStream,
- &_playBufferAttr, NULL,
- NULL);
+ pa_operation* op = LATE(pa_stream_set_buffer_attr)(
+ _playStream, &_playBufferAttr, nullptr, nullptr);
if (!op)
{
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
@@ -2340,7 +2329,7 @@ void AudioDeviceLinuxPulse::EnableReadCallback()
void AudioDeviceLinuxPulse::DisableReadCallback()
{
- LATE(pa_stream_set_read_callback)(_recStream, NULL, NULL);
+ LATE(pa_stream_set_read_callback)(_recStream, nullptr, nullptr);
}
void AudioDeviceLinuxPulse::PaStreamReadCallback(pa_stream */*unused1*/,
@@ -2610,7 +2599,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess()
"_startPlay true, performing initial actions");
_startPlay = false;
- _playDeviceName = NULL;
+ _playDeviceName = nullptr;
// Set if not default device
if (_outputDeviceIndex > 0)
@@ -2642,8 +2631,8 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess()
PaLock();
- // NULL gives PA the choice of startup volume.
- pa_cvolume* ptr_cvolume = NULL;
+ // null gives PA the choice of startup volume.
+ pa_cvolume* ptr_cvolume = nullptr;
if (update_speaker_volume_at_startup_) {
pa_cvolume cVolumes;
ptr_cvolume = &cVolumes;
@@ -2657,15 +2646,12 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess()
// Connect the stream to a sink
if (LATE(pa_stream_connect_playback)(
- _playStream,
- _playDeviceName,
- &_playBufferAttr,
- (pa_stream_flags_t) _playStreamFlags,
- ptr_cvolume, NULL) != PA_OK)
- {
- WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
- " failed to connect play stream, err=%d",
- LATE(pa_context_errno)(_paContext));
+ _playStream, _playDeviceName, &_playBufferAttr,
+ (pa_stream_flags_t)_playStreamFlags, ptr_cvolume,
+ nullptr) != PA_OK) {
+ WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
+ " failed to connect play stream, err=%d",
+ LATE(pa_context_errno)(_paContext));
}
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id,
@@ -2689,7 +2675,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess()
if (_playDeviceName)
{
delete [] _playDeviceName;
- _playDeviceName = NULL;
+ _playDeviceName = nullptr;
}
_playing = true;
@@ -2718,32 +2704,22 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess()
PaLock();
if (LATE(pa_stream_write)(
- _playStream,
- (void *) &_playBuffer[_playbackBufferUnused],
- write, NULL, (int64_t) 0,
- PA_SEEK_RELATIVE) != PA_OK)
- {
- _writeErrors++;
- if (_writeErrors > 10)
- {
- if (_playError == 1)
- {
- WEBRTC_TRACE(kTraceWarning,
- kTraceUtility, _id,
- " pending playout error exists");
- }
- // Triggers callback from module process thread.
- _playError = 1;
- WEBRTC_TRACE(
- kTraceError,
- kTraceUtility,
- _id,
- " kPlayoutError message posted: "
- "_writeErrors=%u, error=%d",
- _writeErrors,
- LATE(pa_context_errno)(_paContext));
- _writeErrors = 0;
+ _playStream, (void*)&_playBuffer[_playbackBufferUnused],
+ write, nullptr, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) {
+ _writeErrors++;
+ if (_writeErrors > 10) {
+ if (_playError == 1) {
+ WEBRTC_TRACE(kTraceWarning, kTraceUtility, _id,
+ " pending playout error exists");
}
+ // Triggers callback from module process thread.
+ _playError = 1;
+ WEBRTC_TRACE(kTraceError, kTraceUtility, _id,
+ " kPlayoutError message posted: "
+ "_writeErrors=%u, error=%d",
+ _writeErrors, LATE(pa_context_errno)(_paContext));
+ _writeErrors = 0;
+ }
}
PaUnLock();
@@ -2788,31 +2764,23 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess()
WEBRTC_TRACE(kTraceDebug, kTraceAudioDevice, _id,
" will write");
PaLock();
- if (LATE(pa_stream_write)(_playStream, (void *) &_playBuffer[0],
- write, NULL, (int64_t) 0,
- PA_SEEK_RELATIVE) != PA_OK)
- {
- _writeErrors++;
- if (_writeErrors > 10)
- {
- if (_playError == 1)
- {
- WEBRTC_TRACE(kTraceWarning,
- kTraceUtility, _id,
- " pending playout error exists");
- }
- // Triggers callback from module process thread.
- _playError = 1;
- WEBRTC_TRACE(
- kTraceError,
- kTraceUtility,
- _id,
- " kPlayoutError message posted: "
- "_writeErrors=%u, error=%d",
- _writeErrors,
- LATE(pa_context_errno)(_paContext));
- _writeErrors = 0;
+ if (LATE(pa_stream_write)(_playStream, (void*)&_playBuffer[0],
+ write, nullptr, (int64_t)0,
+ PA_SEEK_RELATIVE) != PA_OK) {
+ _writeErrors++;
+ if (_writeErrors > 10) {
+ if (_playError == 1) {
+ WEBRTC_TRACE(kTraceWarning, kTraceUtility, _id,
+ " pending playout error exists");
}
+ // Triggers callback from module process thread.
+ _playError = 1;
+ WEBRTC_TRACE(kTraceError, kTraceUtility, _id,
+ " kPlayoutError message posted: "
+ "_writeErrors=%u, error=%d",
+ _writeErrors, LATE(pa_context_errno)(_paContext));
+ _writeErrors = 0;
+ }
}
PaUnLock();
@@ -2850,7 +2818,7 @@ bool AudioDeviceLinuxPulse::RecThreadProcess()
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
"_startRec true, performing initial actions");
- _recDeviceName = NULL;
+ _recDeviceName = nullptr;
// Set if not default device
if (_inputDeviceIndex > 0)
@@ -2898,7 +2866,7 @@ bool AudioDeviceLinuxPulse::RecThreadProcess()
if (_recDeviceName)
{
delete [] _recDeviceName;
- _recDeviceName = NULL;
+ _recDeviceName = nullptr;
}
_startRec = false;
@@ -2916,7 +2884,7 @@ bool AudioDeviceLinuxPulse::RecThreadProcess()
return true;
}
- _tempSampleData = NULL;
+ _tempSampleData = nullptr;
_tempSampleDataSize = 0;
PaLock();

Powered by Google App Engine
This is Rietveld 408576698