From bf478faebb93b98017a0e4798bb5357802558831 Mon Sep 17 00:00:00 2001 From: "henrika@webrtc.org" Date: Mon, 24 Oct 2011 10:31:02 +0000 Subject: [PATCH] Ensures that ADM unit tests builds on all platforms. Review URL: http://webrtc-codereview.appspot.com/240009 git-svn-id: http://webrtc.googlecode.com/svn/trunk@800 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/test/audio_device_test_api.cc | 69 +++++++++++-------- .../main/test/func_test_manager.cc | 17 +++-- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/modules/audio_device/main/test/audio_device_test_api.cc b/src/modules/audio_device/main/test/audio_device_test_api.cc index cc9a1e410..5f5ce26ba 100644 --- a/src/modules/audio_device/main/test/audio_device_test_api.cc +++ b/src/modules/audio_device/main/test/audio_device_test_api.cc @@ -14,6 +14,7 @@ #include "audio_device_test_defines.h" #include "../source/audio_device_config.h" +#include "../source/audio_device_impl.h" #include "../source/audio_device_utility.h" // Helper functions @@ -213,7 +214,7 @@ int api_test() processThread->Start(); // ======================================================= - // AudioDeviceModule::Create + // AudioDeviceModuleImpl::Create // // Windows: // if (WEBRTC_WINDOWS_CORE_AUDIO_BUILD) @@ -226,74 +227,78 @@ int api_test() AudioDeviceModule* audioDevice(NULL); #if defined(_WIN32) - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kLinuxAlsaAudio)) == NULL); #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) TEST_LOG("WEBRTC_WINDOWS_CORE_AUDIO_BUILD is defined!\n\n"); // create default implementation (=Core Audio) instance - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kPlatformDefaultAudio)) != NULL); - AudioDeviceModule::Destroy(audioDevice); + audioDevice->AddRef(); + TEST(audioDevice->Release() == 0); // create non-default (=Wave Audio) instance - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsWaveAudio)) != NULL); - AudioDeviceModule::Destroy(audioDevice); + audioDevice->AddRef(); + TEST(audioDevice->Release() == 0); // explicitly specify usage of Core Audio (same as default) - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsCoreAudio)) != NULL); #else - // TEST_LOG("WEBRTC_WINDOWS_CORE_AUDIO_BUILD is *not* defined!\n"); - TEST((audioDevice = AudioDeviceModule::Create( + TEST_LOG("WEBRTC_WINDOWS_CORE_AUDIO_BUILD is *not* defined!\n"); + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsCoreAudio)) == NULL); // create default implementation (=Wave Audio) instance - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kPlatformDefaultAudio)) != NULL); - AudioDeviceModule::Destroy(audioDevice); + audioDevice->AddRef(); + TEST(audioDevice->Release() == 0); // explicitly specify usage of Wave Audio (same as default) - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsWaveAudio)) != NULL); #endif #endif #if defined(ANDROID) // Fails tests - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsWaveAudio)) == NULL); - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsCoreAudio)) == NULL); - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kLinuxAlsaAudio)) == NULL); - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kLinuxPulseAudio)) == NULL); // Create default implementation instance - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kPlatformDefaultAudio)) != NULL); #elif defined(WEBRTC_LINUX) - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsWaveAudio)) == NULL); - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsCoreAudio)) == NULL); // create default implementation (=ALSA Audio) instance - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kPlatformDefaultAudio)) != NULL); - AudioDeviceModule::Destroy(audioDevice); + audioDevice->AddRef(); + TEST(audioDevice->Release() == 0); // explicitly specify usage of Pulse Audio (same as default) - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kLinuxPulseAudio)) != NULL); #endif #if defined(WEBRTC_MAC) // Fails tests - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsWaveAudio)) == NULL); - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kWindowsCoreAudio)) == NULL); - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kLinuxAlsaAudio)) == NULL); - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kLinuxPulseAudio)) == NULL); // Create default implementation instance - TEST((audioDevice = AudioDeviceModule::Create( + TEST((audioDevice = AudioDeviceModuleImpl::Create( myId, AudioDeviceModule::kPlatformDefaultAudio)) != NULL); #endif @@ -307,6 +312,9 @@ int api_test() #endif } + // The ADM is reference counted. + audioDevice->AddRef(); + processThread->RegisterModule(audioDevice); // =============== @@ -2201,7 +2209,7 @@ int api_test() // ------------------------------------------------------------------------ // =================================================== - // AudioDeviceModule::Destroy + // AudioDeviceModuleImpl::Destroy // =================================================== @@ -2228,8 +2236,9 @@ int api_test() } // release the AudioDeviceModule object - if (audioDevice) - AudioDeviceModule::Destroy(audioDevice); + if (audioDevice) { + TEST(audioDevice->Release() == 0); + } TEST_LOG("\n"); PRINT_TEST_RESULTS; diff --git a/src/modules/audio_device/main/test/func_test_manager.cc b/src/modules/audio_device/main/test/func_test_manager.cc index 2edc67762..5646b846d 100644 --- a/src/modules/audio_device/main/test/func_test_manager.cc +++ b/src/modules/audio_device/main/test/func_test_manager.cc @@ -16,6 +16,7 @@ #include "func_test_manager.h" #include "../source/audio_device_config.h" +#include "../source/audio_device_impl.h" #ifndef __GNUC__ // Disable warning message ('sprintf': name was marked as #pragma deprecated) @@ -597,11 +598,13 @@ WebRtc_Word32 FuncTestManager::Init() _processThread->Start(); // create the Audio Device module - TEST((_audioDevice = AudioDeviceModule::Create(555, ADM_AUDIO_LAYER)) != NULL); + TEST((_audioDevice = AudioDeviceModuleImpl::Create( + 555, ADM_AUDIO_LAYER)) != NULL); if (_audioDevice == NULL) { return -1; } + TEST(_audioDevice->AddRef() == 1); // register the Audio Device module _processThread->RegisterModule(_audioDevice); @@ -656,7 +659,7 @@ WebRtc_Word32 FuncTestManager::Close() // release the AudioDeviceModule object if (_audioDevice) { - AudioDeviceModule::Destroy(_audioDevice); + TEST(_audioDevice->Release() == 0); _audioDevice = NULL; } @@ -826,7 +829,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() // release the AudioDeviceModule object if (_audioDevice) { - AudioDeviceModule::Destroy(_audioDevice); + TEST(_audioDevice->Release() == 0); _audioDevice = NULL; } @@ -843,12 +846,12 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() // create the Audio Device module based on selected audio layer if (tryWinWave) { - _audioDevice = AudioDeviceModule::Create( + _audioDevice = AudioDeviceModuleImpl::Create( 555, AudioDeviceModule::kWindowsWaveAudio); } else if (tryWinCore) { - _audioDevice = AudioDeviceModule::Create( + _audioDevice = AudioDeviceModuleImpl::Create( 555, AudioDeviceModule::kWindowsCoreAudio); } @@ -857,7 +860,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() { TEST_LOG("\nERROR: Switch of audio layer failed!\n"); // restore default audio layer instead - TEST((_audioDevice = AudioDeviceModule::Create( + TEST((_audioDevice = AudioDeviceModuleImpl::Create( 555, AudioDeviceModule::kPlatformDefaultAudio)) != NULL); } @@ -867,6 +870,8 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() return -1; } + TEST(_audioDevice->AddRef() == 1); + // register the Audio Device module _processThread->RegisterModule(_audioDevice);