this patch fixes the valgrind warnings in the adm api test for pulseaudio in linux.

Review URL: http://webrtc-codereview.appspot.com/301012

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1108 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
xians@webrtc.org 2011-12-06 10:02:56 +00:00
parent cae01010bd
commit eff3c8905f
3 changed files with 22 additions and 4 deletions

View File

@ -55,6 +55,8 @@ AudioDeviceBuffer::AudioDeviceBuffer() :
{
// valid ID will be set later by SetId, use -1 for now
WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s created", __FUNCTION__);
memset(_recBuffer, 0, kMaxBufferSizeBytes);
memset(_playBuffer, 0, kMaxBufferSizeBytes);
}
// ----------------------------------------------------------------------------

View File

@ -133,6 +133,8 @@ AudioDeviceLinuxPulse::AudioDeviceLinuxPulse(const WebRtc_Word32 id) :
"%s created", __FUNCTION__);
memset(_paServerVersion, 0, sizeof(_paServerVersion));
memset(&_playBufferAttr, 0, sizeof(_playBufferAttr));
memset(&_recBufferAttr, 0, sizeof(_recBufferAttr));
}
AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse()
@ -1115,7 +1117,7 @@ WebRtc_Word32 AudioDeviceLinuxPulse::SetPlayoutDevice(WebRtc_UWord16 index)
return -1;
}
const WebRtc_UWord16 nDevices(PlayoutDevices());
const WebRtc_UWord16 nDevices = PlayoutDevices();
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
" number of availiable output devices is %u", nDevices);
@ -1149,7 +1151,7 @@ WebRtc_Word32 AudioDeviceLinuxPulse::PlayoutDeviceName(
WEBRTC_TRACE(kTraceModuleCall, kTraceAudioDevice, _id,
"AudioDeviceLinuxPulse::PlayoutDeviceName(index=%u)", index);
const WebRtc_UWord16 nDevices(PlayoutDevices());
const WebRtc_UWord16 nDevices = PlayoutDevices();
if ((index > (nDevices - 1)) || (name == NULL))
{
@ -2239,7 +2241,7 @@ WebRtc_Word32 AudioDeviceLinuxPulse::GetDefaultDeviceInfo(bool recDevice,
WebRtc_Word8* name,
WebRtc_UWord16& index)
{
WebRtc_Word8 tmpName[kAdmMaxDeviceNameSize];
WebRtc_Word8 tmpName[kAdmMaxDeviceNameSize] = {0};
// subtract length of "default: "
WebRtc_UWord16 nameLen = kAdmMaxDeviceNameSize - 9;
WebRtc_Word8* pName = NULL;
@ -2333,6 +2335,11 @@ WebRtc_Word32 AudioDeviceLinuxPulse::InitPulseAudio()
// Create a mainloop API and connection to the default server
// the mainloop is the internal asynchronous API event loop
if (_paMainloop) {
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
" PA mainloop has already existed");
return -1;
}
_paMainloop = LATE(pa_threaded_mainloop_new)();
if (!_paMainloop)
{
@ -2365,6 +2372,12 @@ WebRtc_Word32 AudioDeviceLinuxPulse::InitPulseAudio()
}
// Create a new PulseAudio context
if (_paContext){
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
" PA context has already existed");
PaUnLock();
return -1;
}
_paContext = LATE(pa_context_new)(_paMainloopApi, "WEBRTC VoiceEngine");
if (!_paContext)

View File

@ -83,6 +83,8 @@ class AudioEventObserverAPI: public AudioDeviceObserver
{
public:
AudioEventObserverAPI(AudioDeviceModule* audioDevice) :
_error(kRecordingError),
_warning(kRecordingWarning),
_audioDevice(audioDevice)
{
}
@ -277,10 +279,11 @@ int api_test()
myId, AudioDeviceModule::kWindowsWaveAudio)) == NULL);
TEST((audioDevice = AudioDeviceModuleImpl::Create(
myId, AudioDeviceModule::kWindowsCoreAudio)) == NULL);
// create default implementation (=ALSA Audio) instance
// create default implementation instance
TEST((audioDevice = AudioDeviceModuleImpl::Create(
myId, AudioDeviceModule::kPlatformDefaultAudio)) != NULL);
audioDevice->AddRef();
TEST(audioDevice->Terminate() == 0);
TEST(audioDevice->Release() == 0);
// explicitly specify usage of Pulse Audio (same as default)
TEST((audioDevice = AudioDeviceModuleImpl::Create(