Get rid of the ADM test warnings.

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@375 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
xians@google.com 2011-08-16 09:30:51 +00:00
parent e66a0c0ce7
commit 0134facd53
4 changed files with 121 additions and 126 deletions

View File

@ -484,8 +484,6 @@ int api_test()
nDevices = audioDevice->RecordingDevices(); nDevices = audioDevice->RecordingDevices();
WebRtc_UWord16 nRecordingDevices(audioDevice->RecordingDevices());
// fail tests // fail tests
TEST(audioDevice->SetRecordingDevice(-1) == -1); TEST(audioDevice->SetRecordingDevice(-1) == -1);
TEST(audioDevice->SetRecordingDevice(nDevices) == -1); TEST(audioDevice->SetRecordingDevice(nDevices) == -1);
@ -811,7 +809,7 @@ int api_test()
} }
} }
int vol(0); WebRtc_UWord32 vol(0);
#if defined(_WIN32) && !defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) #if defined(_WIN32) && !defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD)
@ -1332,7 +1330,7 @@ int api_test()
TEST(audioDevice->MaxMicrophoneVolume(&maxVolume) == 0); TEST(audioDevice->MaxMicrophoneVolume(&maxVolume) == 0);
TEST(audioDevice->MinMicrophoneVolume(&minVolume) == 0); TEST(audioDevice->MinMicrophoneVolume(&minVolume) == 0);
TEST(audioDevice->MicrophoneVolumeStepSize(&stepSize) == 0); TEST(audioDevice->MicrophoneVolumeStepSize(&stepSize) == 0);
for (vol = minVolume; vol < (int) maxVolume; vol += 10 * stepSize) for (vol = minVolume; vol < maxVolume; vol += 10 * stepSize)
{ {
TEST(audioDevice->SetMicrophoneVolume(vol) == 0); TEST(audioDevice->SetMicrophoneVolume(vol) == 0);
TEST(audioDevice->MicrophoneVolume(&volume) == 0); TEST(audioDevice->MicrophoneVolume(&volume) == 0);
@ -1352,7 +1350,7 @@ int api_test()
TEST(audioDevice->MaxMicrophoneVolume(&maxVolume) == 0); TEST(audioDevice->MaxMicrophoneVolume(&maxVolume) == 0);
TEST(audioDevice->MinMicrophoneVolume(&minVolume) == 0); TEST(audioDevice->MinMicrophoneVolume(&minVolume) == 0);
TEST(audioDevice->MicrophoneVolumeStepSize(&stepSize) == 0); TEST(audioDevice->MicrophoneVolumeStepSize(&stepSize) == 0);
for (vol = minVolume; vol < (int) maxVolume; vol += 20 * stepSize) for (vol = minVolume; vol < maxVolume; vol += 20 * stepSize)
{ {
TEST(audioDevice->SetMicrophoneVolume(vol) == 0); TEST(audioDevice->SetMicrophoneVolume(vol) == 0);
TEST(audioDevice->MicrophoneVolume(&volume) == 0); TEST(audioDevice->MicrophoneVolume(&volume) == 0);
@ -2192,7 +2190,9 @@ int api_test()
#endif #endif
TEST(audioDevice->StopPlayout() == 0); TEST(audioDevice->StopPlayout() == 0);
#ifdef _WIN32
Exit: Exit:
#endif
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Terminate the module when all tests are done: // Terminate the module when all tests are done:

View File

@ -38,12 +38,12 @@ static int testCount = 0;
static int errorCount = 0; static int errorCount = 0;
static int warningCount = 0; static int warningCount = 0;
#define RESET_TEST \ #define RESET_TEST \
do { \ do { \
testCount = 0; \ testCount = 0; \
errorCount = 0; \ errorCount = 0; \
warningCount = 0; \ warningCount = 0; \
} while(0) \ } while(0) \
#define PRINT_ERR_MSG(msg) \ #define PRINT_ERR_MSG(msg) \
do { \ do { \
@ -102,7 +102,6 @@ static int warningCount = 0;
} \ } \
} while(0) } while(0)
// Helper functions // Helper functions
// For iPhone, they are defined in iPhone specific test code. // For iPhone, they are defined in iPhone specific test code.
// For Android, they are defined in API test only (since both // For Android, they are defined in API test only (since both

View File

@ -12,8 +12,10 @@
#include "audio_device_test_defines.h" #include "audio_device_test_defines.h"
#include "func_test_manager.h" #include "func_test_manager.h"
#ifndef __GNUC__
// Disable warning message 4996 ('scanf': This function or variable may be unsafe) // Disable warning message 4996 ('scanf': This function or variable may be unsafe)
#pragma warning( disable : 4996 ) #pragma warning( disable : 4996 )
#endif
using namespace webrtc; using namespace webrtc;
@ -36,43 +38,48 @@ int main(int /*argc*/, char* /*argv*/[])
int func_test(int sel) int func_test(int sel)
{ {
TEST_LOG("=========================================\n"); TEST_LOG("=========================================\n");
TEST_LOG("Func Test of the WebRtcAudioDevice Module\n"); TEST_LOG("Func Test of the WebRtcAudioDevice Module\n");
TEST_LOG("=========================================\n\n"); TEST_LOG("=========================================\n\n");
FuncTestManager funcMgr; // Initialize the counters here to get rid of "unused variables" warnings.
testCount = 0;
errorCount = 0;
warningCount = 0;
funcMgr.Init(); FuncTestManager funcMgr;
bool quit(false); funcMgr.Init();
while (!quit) bool quit(false);
{
TEST_LOG("---------------------------------------\n"); while (!quit)
TEST_LOG("Select type of test\n\n"); {
TEST_LOG(" (0) Quit\n"); TEST_LOG("---------------------------------------\n");
TEST_LOG(" (1) All\n"); TEST_LOG("Select type of test\n\n");
TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n"); TEST_LOG(" (0) Quit\n");
TEST_LOG(" (2) Audio-layer selection\n"); TEST_LOG(" (1) All\n");
TEST_LOG(" (3) Device enumeration\n"); TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n");
TEST_LOG(" (4) Device selection\n"); TEST_LOG(" (2) Audio-layer selection\n");
TEST_LOG(" (5) Audio transport\n"); TEST_LOG(" (3) Device enumeration\n");
TEST_LOG(" (6) Speaker volume\n"); TEST_LOG(" (4) Device selection\n");
TEST_LOG(" (7) Microphone volume\n"); TEST_LOG(" (5) Audio transport\n");
TEST_LOG(" (8) Speaker mute\n"); TEST_LOG(" (6) Speaker volume\n");
TEST_LOG(" (9) Microphone mute\n"); TEST_LOG(" (7) Microphone volume\n");
TEST_LOG(" (10) Microphone boost\n"); TEST_LOG(" (8) Speaker mute\n");
TEST_LOG(" (11) Microphone AGC\n"); TEST_LOG(" (9) Microphone mute\n");
TEST_LOG(" (12) Loopback measurements\n"); TEST_LOG(" (10) Microphone boost\n");
TEST_LOG(" (11) Microphone AGC\n");
TEST_LOG(" (12) Loopback measurements\n");
TEST_LOG(" (13) Device removal\n"); TEST_LOG(" (13) Device removal\n");
TEST_LOG(" (14) Advanced mobile device API\n"); TEST_LOG(" (14) Advanced mobile device API\n");
TEST_LOG(" (66) XTEST\n"); TEST_LOG(" (66) XTEST\n");
TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n"); TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n");
TEST_LOG("\n: "); TEST_LOG("\n: ");
int dummy(0); int dummy(0);
int selection(0); int selection(0);
enum TestType testType(TTInvalid); enum TestType testType(TTInvalid);
SHOW_MENU: SHOW_MENU:
@ -85,72 +92,72 @@ SHOW_MENU:
dummy = scanf("%d", &selection); dummy = scanf("%d", &selection);
} }
switch (selection) switch (selection)
{ {
case 0: case 0:
quit = true; quit = true;
break; break;
case 1: case 1:
testType = TTAll; testType = TTAll;
break; break;
case 2: case 2:
testType = TTAudioLayerSelection; testType = TTAudioLayerSelection;
break; break;
case 3: case 3:
testType = TTDeviceEnumeration; testType = TTDeviceEnumeration;
break; break;
case 4: case 4:
testType = TTDeviceSelection; testType = TTDeviceSelection;
break; break;
case 5: case 5:
testType = TTAudioTransport; testType = TTAudioTransport;
break; break;
case 6: case 6:
testType = TTSpeakerVolume; testType = TTSpeakerVolume;
break; break;
case 7: case 7:
testType = TTMicrophoneVolume; testType = TTMicrophoneVolume;
break; break;
case 8: case 8:
testType = TTSpeakerMute; testType = TTSpeakerMute;
break; break;
case 9: case 9:
testType = TTMicrophoneMute; testType = TTMicrophoneMute;
break; break;
case 10: case 10:
testType = TTMicrophoneBoost; testType = TTMicrophoneBoost;
break; break;
case 11: case 11:
testType = TTMicrophoneAGC; testType = TTMicrophoneAGC;
break; break;
case 12: case 12:
testType = TTLoopback; testType = TTLoopback;
break; break;
case 13: case 13:
testType = TTDeviceRemoval; testType = TTDeviceRemoval;
break; break;
case 14: case 14:
testType = TTMobileAPI; testType = TTMobileAPI;
break; break;
case 66: case 66:
testType = TTTest; testType = TTTest;
break; break;
default: default:
testType = TTInvalid; testType = TTInvalid;
TEST_LOG(": "); TEST_LOG(": ");
goto SHOW_MENU; goto SHOW_MENU;
break; break;
} }
WebRtc_Word32 ret = funcMgr.DoTest(testType); funcMgr.DoTest(testType);
if (sel > 0) if (sel > 0)
{ {
quit = true; quit = true;
} }
} }
funcMgr.Close(); funcMgr.Close();
return 0; return 0;
} }

View File

@ -17,10 +17,12 @@
#include "../source/audio_device_config.h" #include "../source/audio_device_config.h"
#ifndef __GNUC__
// Disable warning message ('sprintf': name was marked as #pragma deprecated) // Disable warning message ('sprintf': name was marked as #pragma deprecated)
#pragma warning( disable : 4995 ) #pragma warning( disable : 4995 )
// Disable warning message 4996 ('scanf': This function or variable may be unsafe) // Disable warning message 4996 ('scanf': This function or variable may be unsafe)
#pragma warning( disable : 4996 ) #pragma warning( disable : 4996 )
#endif
const WebRtc_Word8 PlayoutFile48[] = "audio_short48.pcm"; const WebRtc_Word8 PlayoutFile48[] = "audio_short48.pcm";
const WebRtc_Word8 PlayoutFile44[] = "audio_short44.pcm"; const WebRtc_Word8 PlayoutFile44[] = "audio_short44.pcm";
@ -192,9 +194,6 @@ WebRtc_Word32 AudioTransportImpl::RecordedDataIsAvailable(
const WebRtc_UWord32 currentMicLevel, const WebRtc_UWord32 currentMicLevel,
WebRtc_UWord32& newMicLevel) WebRtc_UWord32& newMicLevel)
{ {
WebRtc_UWord32 samples(nSamples);
WebRtc_UWord32 fs(samplesPerSec);
if (_fullDuplex && _audioList.GetSize() < 15) if (_fullDuplex && _audioList.GetSize() < 15)
{ {
AudioPacket* packet = new AudioPacket(); AudioPacket* packet = new AudioPacket();
@ -356,8 +355,6 @@ WebRtc_Word32 AudioTransportImpl::NeedMorePlayData(
WebRtc_Word16* ptr16Out = NULL; WebRtc_Word16* ptr16Out = NULL;
const WebRtc_UWord16 nSamplesIn = packet->nSamples; const WebRtc_UWord16 nSamplesIn = packet->nSamples;
const WebRtc_UWord16 nBytesIn = nSamplesIn
* packet->nBytesPerSample;
const WebRtc_UWord8 nChannelsIn = packet->nChannels; const WebRtc_UWord8 nChannelsIn = packet->nChannels;
const WebRtc_UWord32 samplesPerSecIn = packet->samplesPerSec; const WebRtc_UWord32 samplesPerSecIn = packet->samplesPerSec;
const WebRtc_UWord16 nBytesPerSampleIn = const WebRtc_UWord16 nBytesPerSampleIn =
@ -619,7 +616,6 @@ WebRtc_Word32 FuncTestManager::Init()
WebRtc_Word8 version[256]; WebRtc_Word8 version[256];
WebRtc_UWord32 remainingBufferInBytes = 256; WebRtc_UWord32 remainingBufferInBytes = 256;
WebRtc_UWord32 tooFewBytes = 10;
WebRtc_UWord32 position = 0; WebRtc_UWord32 position = 0;
// log version // log version
@ -771,7 +767,6 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection()
} }
char ch; char ch;
int dummy(0);
bool tryWinWave(false); bool tryWinWave(false);
bool tryWinCore(false); bool tryWinCore(false);
@ -779,7 +774,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection()
{ {
TEST_LOG("Would you like to try kWindowsCoreAudio instead " TEST_LOG("Would you like to try kWindowsCoreAudio instead "
"[requires Win Vista or Win 7] (Y/N)?\n: "); "[requires Win Vista or Win 7] (Y/N)?\n: ");
dummy = scanf(" %c", &ch); scanf(" %c", &ch);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@ -788,7 +783,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection()
} else if (audioLayer == AudioDeviceModule::kWindowsCoreAudio) } else if (audioLayer == AudioDeviceModule::kWindowsCoreAudio)
{ {
TEST_LOG("Would you like to try kWindowsWaveAudio instead (Y/N)?\n: "); TEST_LOG("Would you like to try kWindowsWaveAudio instead (Y/N)?\n: ");
int dummy = scanf(" %c", &ch); scanf(" %c", &ch);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@ -1007,9 +1002,9 @@ WebRtc_Word32 FuncTestManager::TestDeviceSelection()
#define PRINT_STR(a, b) \ #define PRINT_STR(a, b) \
{ \ { \
char str[128]; \ char str[128]; \
(b == true) ? (sprintf(str, " %-17s: available\n", #a)) : (sprintf(str, " %-17s: NA\n", #a)); \ (b == true) ? (sprintf(str, " %-17s: available\n", #a)) : (sprintf(str, " %-17s: NA\n", #a)); \
TEST_LOG(str); \ TEST_LOG("%s", str); \
} \ } \
AudioDeviceModule* audioDevice = _audioDevice; AudioDeviceModule* audioDevice = _audioDevice;
@ -1690,7 +1685,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneVolume()
RecordedMicrophoneVolumeFile); RecordedMicrophoneVolumeFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
int dummy = scanf(" %c", &ch); scanf(" %c", &ch);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@ -1829,7 +1824,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneMute()
RecordedMicrophoneMuteFile); RecordedMicrophoneMuteFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
int dummy = scanf(" %c", &ch); scanf(" %c", &ch);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@ -1965,7 +1960,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneBoost()
RecordedMicrophoneBoostFile); RecordedMicrophoneBoostFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
int dummy = scanf(" %c", &ch); scanf(" %c", &ch);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@ -2102,7 +2097,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneAGC()
RecordedMicrophoneAGCFile); RecordedMicrophoneAGCFile);
char ch; char ch;
bool fileRecording(false); bool fileRecording(false);
int dummy = scanf(" %c", &ch); scanf(" %c", &ch);
ch = toupper(ch); ch = toupper(ch);
if (ch == 'Y') if (ch == 'Y')
{ {
@ -2367,13 +2362,11 @@ WebRtc_Word32 FuncTestManager::TestDeviceRemoval()
bool available(false); bool available(false);
bool enabled(false); bool enabled(false);
WebRtc_UWord32 samplesPerSec(0);
if (recIsAvailable && playIsAvailable) if (recIsAvailable && playIsAvailable)
{ {
WebRtc_UWord32 playSamplesPerSec(0); WebRtc_UWord32 playSamplesPerSec(0);
WebRtc_UWord32 recSamplesPerSecRec(0); WebRtc_UWord32 recSamplesPerSecRec(0);
WebRtc_UWord32 maxVolume(0);
TEST(audioDevice->RegisterAudioCallback(_audioTransport) == 0); TEST(audioDevice->RegisterAudioCallback(_audioTransport) == 0);
@ -2535,10 +2528,9 @@ WebRtc_Word32 FuncTestManager::SelectRecordingDevice()
} }
TEST_LOG("\n: "); TEST_LOG("\n: ");
int dummy(0);
int sel(0); int sel(0);
dummy = scanf("%u", &sel); scanf("%u", &sel);
if (sel == 0) if (sel == 0)
{ {
@ -2566,10 +2558,9 @@ WebRtc_Word32 FuncTestManager::SelectRecordingDevice()
} }
TEST_LOG("\n: "); TEST_LOG("\n: ");
int dummy(0);
int sel(0); int sel(0);
dummy = scanf("%u", &sel); scanf("%u", &sel);
if (sel < (nDevices)) if (sel < (nDevices))
{ {
@ -2601,10 +2592,9 @@ WebRtc_Word32 FuncTestManager::SelectPlayoutDevice()
} }
TEST_LOG("\n: "); TEST_LOG("\n: ");
int dummy(0);
int sel(0); int sel(0);
dummy = scanf("%u", &sel); scanf("%u", &sel);
WebRtc_Word32 ret(0); WebRtc_Word32 ret(0);
@ -2635,10 +2625,9 @@ WebRtc_Word32 FuncTestManager::SelectPlayoutDevice()
} }
TEST_LOG("\n: "); TEST_LOG("\n: ");
int dummy(0);
int sel(0); int sel(0);
dummy = scanf("%u", &sel); scanf("%u", &sel);
WebRtc_Word32 ret(0); WebRtc_Word32 ret(0);