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 9a467caa36..cc9a1e4106 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 @@ -484,8 +484,6 @@ int api_test() nDevices = audioDevice->RecordingDevices(); - WebRtc_UWord16 nRecordingDevices(audioDevice->RecordingDevices()); - // fail tests TEST(audioDevice->SetRecordingDevice(-1) == -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) @@ -1332,7 +1330,7 @@ int api_test() TEST(audioDevice->MaxMicrophoneVolume(&maxVolume) == 0); TEST(audioDevice->MinMicrophoneVolume(&minVolume) == 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->MicrophoneVolume(&volume) == 0); @@ -1352,7 +1350,7 @@ int api_test() TEST(audioDevice->MaxMicrophoneVolume(&maxVolume) == 0); TEST(audioDevice->MinMicrophoneVolume(&minVolume) == 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->MicrophoneVolume(&volume) == 0); @@ -2192,7 +2190,9 @@ int api_test() #endif TEST(audioDevice->StopPlayout() == 0); +#ifdef _WIN32 Exit: +#endif // ------------------------------------------------------------------------ // Terminate the module when all tests are done: diff --git a/src/modules/audio_device/main/test/audio_device_test_defines.h b/src/modules/audio_device/main/test/audio_device_test_defines.h index 6ed26059ff..5c5f4e28e8 100644 --- a/src/modules/audio_device/main/test/audio_device_test_defines.h +++ b/src/modules/audio_device/main/test/audio_device_test_defines.h @@ -38,12 +38,12 @@ static int testCount = 0; static int errorCount = 0; static int warningCount = 0; -#define RESET_TEST \ - do { \ - testCount = 0; \ - errorCount = 0; \ - warningCount = 0; \ - } while(0) \ +#define RESET_TEST \ + do { \ + testCount = 0; \ + errorCount = 0; \ + warningCount = 0; \ + } while(0) \ #define PRINT_ERR_MSG(msg) \ do { \ @@ -102,7 +102,6 @@ static int warningCount = 0; } \ } while(0) - // Helper functions // For iPhone, they are defined in iPhone specific test code. // For Android, they are defined in API test only (since both diff --git a/src/modules/audio_device/main/test/audio_device_test_func.cc b/src/modules/audio_device/main/test/audio_device_test_func.cc index d8b3582d3b..f8fb010706 100644 --- a/src/modules/audio_device/main/test/audio_device_test_func.cc +++ b/src/modules/audio_device/main/test/audio_device_test_func.cc @@ -12,8 +12,10 @@ #include "audio_device_test_defines.h" #include "func_test_manager.h" +#ifndef __GNUC__ // Disable warning message 4996 ('scanf': This function or variable may be unsafe) #pragma warning( disable : 4996 ) +#endif using namespace webrtc; @@ -36,43 +38,48 @@ int main(int /*argc*/, char* /*argv*/[]) int func_test(int sel) { - TEST_LOG("=========================================\n"); - TEST_LOG("Func Test of the WebRtcAudioDevice Module\n"); + TEST_LOG("=========================================\n"); + TEST_LOG("Func Test of the WebRtcAudioDevice Module\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) - { - TEST_LOG("---------------------------------------\n"); - TEST_LOG("Select type of test\n\n"); - TEST_LOG(" (0) Quit\n"); - TEST_LOG(" (1) All\n"); - TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n"); - TEST_LOG(" (2) Audio-layer selection\n"); - TEST_LOG(" (3) Device enumeration\n"); - TEST_LOG(" (4) Device selection\n"); - TEST_LOG(" (5) Audio transport\n"); - TEST_LOG(" (6) Speaker volume\n"); - TEST_LOG(" (7) Microphone volume\n"); - TEST_LOG(" (8) Speaker mute\n"); - TEST_LOG(" (9) Microphone mute\n"); - TEST_LOG(" (10) Microphone boost\n"); - TEST_LOG(" (11) Microphone AGC\n"); - TEST_LOG(" (12) Loopback measurements\n"); + bool quit(false); + + while (!quit) + { + TEST_LOG("---------------------------------------\n"); + TEST_LOG("Select type of test\n\n"); + TEST_LOG(" (0) Quit\n"); + TEST_LOG(" (1) All\n"); + TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n"); + TEST_LOG(" (2) Audio-layer selection\n"); + TEST_LOG(" (3) Device enumeration\n"); + TEST_LOG(" (4) Device selection\n"); + TEST_LOG(" (5) Audio transport\n"); + TEST_LOG(" (6) Speaker volume\n"); + TEST_LOG(" (7) Microphone volume\n"); + TEST_LOG(" (8) Speaker mute\n"); + TEST_LOG(" (9) Microphone mute\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(" (14) Advanced mobile device API\n"); TEST_LOG(" (66) XTEST\n"); - TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n"); - TEST_LOG("\n: "); + TEST_LOG("- - - - - - - - - - - - - - - - - - - -\n"); + TEST_LOG("\n: "); - int dummy(0); - int selection(0); - enum TestType testType(TTInvalid); + int dummy(0); + int selection(0); + enum TestType testType(TTInvalid); SHOW_MENU: @@ -85,72 +92,72 @@ SHOW_MENU: dummy = scanf("%d", &selection); } - switch (selection) - { - case 0: - quit = true; - break; - case 1: - testType = TTAll; - break; - case 2: - testType = TTAudioLayerSelection; - break; - case 3: - testType = TTDeviceEnumeration; - break; - case 4: - testType = TTDeviceSelection; - break; - case 5: - testType = TTAudioTransport; - break; - case 6: - testType = TTSpeakerVolume; - break; - case 7: - testType = TTMicrophoneVolume; - break; - case 8: - testType = TTSpeakerMute; - break; - case 9: - testType = TTMicrophoneMute; - break; - case 10: - testType = TTMicrophoneBoost; - break; - case 11: - testType = TTMicrophoneAGC; - break; - case 12: - testType = TTLoopback; - break; - case 13: - testType = TTDeviceRemoval; - break; - case 14: - testType = TTMobileAPI; - break; - case 66: - testType = TTTest; - break; - default: - testType = TTInvalid; - TEST_LOG(": "); - goto SHOW_MENU; - break; - } + switch (selection) + { + case 0: + quit = true; + break; + case 1: + testType = TTAll; + break; + case 2: + testType = TTAudioLayerSelection; + break; + case 3: + testType = TTDeviceEnumeration; + break; + case 4: + testType = TTDeviceSelection; + break; + case 5: + testType = TTAudioTransport; + break; + case 6: + testType = TTSpeakerVolume; + break; + case 7: + testType = TTMicrophoneVolume; + break; + case 8: + testType = TTSpeakerMute; + break; + case 9: + testType = TTMicrophoneMute; + break; + case 10: + testType = TTMicrophoneBoost; + break; + case 11: + testType = TTMicrophoneAGC; + break; + case 12: + testType = TTLoopback; + break; + case 13: + testType = TTDeviceRemoval; + break; + case 14: + testType = TTMobileAPI; + break; + case 66: + testType = TTTest; + break; + default: + testType = TTInvalid; + TEST_LOG(": "); + goto SHOW_MENU; + break; + } - WebRtc_Word32 ret = funcMgr.DoTest(testType); + funcMgr.DoTest(testType); if (sel > 0) { quit = true; } - } + } - funcMgr.Close(); + funcMgr.Close(); - return 0; + return 0; } 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 a37c45bcab..2edc67762c 100644 --- a/src/modules/audio_device/main/test/func_test_manager.cc +++ b/src/modules/audio_device/main/test/func_test_manager.cc @@ -17,10 +17,12 @@ #include "../source/audio_device_config.h" +#ifndef __GNUC__ // Disable warning message ('sprintf': name was marked as #pragma deprecated) #pragma warning( disable : 4995 ) // Disable warning message 4996 ('scanf': This function or variable may be unsafe) #pragma warning( disable : 4996 ) +#endif const WebRtc_Word8 PlayoutFile48[] = "audio_short48.pcm"; const WebRtc_Word8 PlayoutFile44[] = "audio_short44.pcm"; @@ -192,9 +194,6 @@ WebRtc_Word32 AudioTransportImpl::RecordedDataIsAvailable( const WebRtc_UWord32 currentMicLevel, WebRtc_UWord32& newMicLevel) { - WebRtc_UWord32 samples(nSamples); - WebRtc_UWord32 fs(samplesPerSec); - if (_fullDuplex && _audioList.GetSize() < 15) { AudioPacket* packet = new AudioPacket(); @@ -356,8 +355,6 @@ WebRtc_Word32 AudioTransportImpl::NeedMorePlayData( WebRtc_Word16* ptr16Out = NULL; const WebRtc_UWord16 nSamplesIn = packet->nSamples; - const WebRtc_UWord16 nBytesIn = nSamplesIn - * packet->nBytesPerSample; const WebRtc_UWord8 nChannelsIn = packet->nChannels; const WebRtc_UWord32 samplesPerSecIn = packet->samplesPerSec; const WebRtc_UWord16 nBytesPerSampleIn = @@ -619,7 +616,6 @@ WebRtc_Word32 FuncTestManager::Init() WebRtc_Word8 version[256]; WebRtc_UWord32 remainingBufferInBytes = 256; - WebRtc_UWord32 tooFewBytes = 10; WebRtc_UWord32 position = 0; // log version @@ -771,7 +767,6 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() } char ch; - int dummy(0); bool tryWinWave(false); bool tryWinCore(false); @@ -779,7 +774,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() { TEST_LOG("Would you like to try kWindowsCoreAudio instead " "[requires Win Vista or Win 7] (Y/N)?\n: "); - dummy = scanf(" %c", &ch); + scanf(" %c", &ch); ch = toupper(ch); if (ch == 'Y') { @@ -788,7 +783,7 @@ WebRtc_Word32 FuncTestManager::TestAudioLayerSelection() } else if (audioLayer == AudioDeviceModule::kWindowsCoreAudio) { TEST_LOG("Would you like to try kWindowsWaveAudio instead (Y/N)?\n: "); - int dummy = scanf(" %c", &ch); + scanf(" %c", &ch); ch = toupper(ch); if (ch == 'Y') { @@ -1007,9 +1002,9 @@ WebRtc_Word32 FuncTestManager::TestDeviceSelection() #define PRINT_STR(a, b) \ { \ - char str[128]; \ - (b == true) ? (sprintf(str, " %-17s: available\n", #a)) : (sprintf(str, " %-17s: NA\n", #a)); \ - TEST_LOG(str); \ + char str[128]; \ + (b == true) ? (sprintf(str, " %-17s: available\n", #a)) : (sprintf(str, " %-17s: NA\n", #a)); \ + TEST_LOG("%s", str); \ } \ AudioDeviceModule* audioDevice = _audioDevice; @@ -1690,7 +1685,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneVolume() RecordedMicrophoneVolumeFile); char ch; bool fileRecording(false); - int dummy = scanf(" %c", &ch); + scanf(" %c", &ch); ch = toupper(ch); if (ch == 'Y') { @@ -1829,7 +1824,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneMute() RecordedMicrophoneMuteFile); char ch; bool fileRecording(false); - int dummy = scanf(" %c", &ch); + scanf(" %c", &ch); ch = toupper(ch); if (ch == 'Y') { @@ -1965,7 +1960,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneBoost() RecordedMicrophoneBoostFile); char ch; bool fileRecording(false); - int dummy = scanf(" %c", &ch); + scanf(" %c", &ch); ch = toupper(ch); if (ch == 'Y') { @@ -2102,7 +2097,7 @@ WebRtc_Word32 FuncTestManager::TestMicrophoneAGC() RecordedMicrophoneAGCFile); char ch; bool fileRecording(false); - int dummy = scanf(" %c", &ch); + scanf(" %c", &ch); ch = toupper(ch); if (ch == 'Y') { @@ -2367,13 +2362,11 @@ WebRtc_Word32 FuncTestManager::TestDeviceRemoval() bool available(false); bool enabled(false); - WebRtc_UWord32 samplesPerSec(0); if (recIsAvailable && playIsAvailable) { WebRtc_UWord32 playSamplesPerSec(0); WebRtc_UWord32 recSamplesPerSecRec(0); - WebRtc_UWord32 maxVolume(0); TEST(audioDevice->RegisterAudioCallback(_audioTransport) == 0); @@ -2535,10 +2528,9 @@ WebRtc_Word32 FuncTestManager::SelectRecordingDevice() } TEST_LOG("\n: "); - int dummy(0); int sel(0); - dummy = scanf("%u", &sel); + scanf("%u", &sel); if (sel == 0) { @@ -2566,10 +2558,9 @@ WebRtc_Word32 FuncTestManager::SelectRecordingDevice() } TEST_LOG("\n: "); - int dummy(0); int sel(0); - dummy = scanf("%u", &sel); + scanf("%u", &sel); if (sel < (nDevices)) { @@ -2601,10 +2592,9 @@ WebRtc_Word32 FuncTestManager::SelectPlayoutDevice() } TEST_LOG("\n: "); - int dummy(0); int sel(0); - dummy = scanf("%u", &sel); + scanf("%u", &sel); WebRtc_Word32 ret(0); @@ -2635,10 +2625,9 @@ WebRtc_Word32 FuncTestManager::SelectPlayoutDevice() } TEST_LOG("\n: "); - int dummy(0); int sel(0); - dummy = scanf("%u", &sel); + scanf("%u", &sel); WebRtc_Word32 ret(0);