Changing to use SleepMs throughout audio_device module.
Tested: Build audio_device_test_api and audio_device_test_func Ran audio_device_test_api. Executed a random set of functions in audio_device_test_func. BUG=603 Review URL: https://webrtc-codereview.appspot.com/756008 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2664 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
f7884f9900
commit
4368c26b1a
@ -27,11 +27,6 @@
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
void AudioDeviceUtility::Sleep(WebRtc_UWord32 milliseconds)
|
||||
{
|
||||
return ::Sleep(milliseconds);
|
||||
}
|
||||
|
||||
void AudioDeviceUtility::WaitForKey()
|
||||
{
|
||||
_getch();
|
||||
@ -58,7 +53,7 @@ bool AudioDeviceUtility::StringCompare(
|
||||
// ============================================================================
|
||||
|
||||
#include <sys/time.h> // gettimeofday
|
||||
#include <time.h> // nanosleep, gettimeofday
|
||||
#include <time.h> // gettimeofday
|
||||
#include <string.h> // strncasecmp
|
||||
#include <stdio.h> // getchar
|
||||
#include <termios.h> // tcgetattr
|
||||
@ -106,14 +101,6 @@ WebRtc_UWord32 AudioDeviceUtility::GetTimeInMS()
|
||||
return val;
|
||||
}
|
||||
|
||||
void AudioDeviceUtility::Sleep(WebRtc_UWord32 milliseconds)
|
||||
{
|
||||
timespec t;
|
||||
t.tv_sec = milliseconds/1000;
|
||||
t.tv_nsec = (milliseconds-(milliseconds/1000)*1000)*1000000;
|
||||
nanosleep(&t,NULL);
|
||||
}
|
||||
|
||||
bool AudioDeviceUtility::StringCompare(
|
||||
const char* str1 , const char* str2, const WebRtc_UWord32 length)
|
||||
{
|
||||
|
@ -20,7 +20,6 @@ class AudioDeviceUtility
|
||||
{
|
||||
public:
|
||||
static WebRtc_UWord32 GetTimeInMS();
|
||||
static void Sleep(WebRtc_UWord32 milliseconds);
|
||||
static void WaitForKey();
|
||||
static bool StringCompare(const char* str1,
|
||||
const char* str2,
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "audio_device_config.h"
|
||||
|
||||
#include "event_wrapper.h"
|
||||
#include "system_wrappers/interface/sleep.h"
|
||||
#include "trace.h"
|
||||
#include "thread_wrapper.h"
|
||||
|
||||
@ -1141,7 +1142,7 @@ WebRtc_Word32 AudioDeviceLinuxALSA::InitPlayout()
|
||||
{
|
||||
for (int i=0; i < 5; i++)
|
||||
{
|
||||
sleep(1);
|
||||
SleepMs(1000);
|
||||
errVal = LATE(snd_pcm_open)
|
||||
(&_handlePlayout,
|
||||
deviceName,
|
||||
@ -1298,7 +1299,7 @@ WebRtc_Word32 AudioDeviceLinuxALSA::InitRecording()
|
||||
{
|
||||
for (int i=0; i < 5; i++)
|
||||
{
|
||||
sleep(1);
|
||||
SleepMs(1000);
|
||||
errVal = LATE(snd_pcm_open)
|
||||
(&_handleRecord,
|
||||
deviceName,
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <uuids.h>
|
||||
|
||||
#include "audio_device_utility.h"
|
||||
#include "system_wrappers/interface/sleep.h"
|
||||
#include "trace.h"
|
||||
|
||||
// Macro that calls a COM method returning HRESULT value.
|
||||
@ -3667,7 +3668,7 @@ DWORD AudioDeviceWindowsCore::DoRenderThread()
|
||||
|
||||
// ------------------ THREAD LOOP ------------------ <<
|
||||
|
||||
Sleep(static_cast<DWORD>(endpointBufferSizeMS+0.5));
|
||||
SleepMs(static_cast<DWORD>(endpointBufferSizeMS+0.5));
|
||||
hr = _ptrClientOut->Stop();
|
||||
|
||||
Exit:
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "../source/audio_device_config.h"
|
||||
#include "../source/audio_device_impl.h"
|
||||
#include "../source/audio_device_utility.h"
|
||||
#include "system_wrappers/interface/sleep.h"
|
||||
|
||||
// Helper functions
|
||||
#if defined(ANDROID)
|
||||
@ -531,7 +532,7 @@ TEST_F(AudioDeviceAPITest, InitPlayout) {
|
||||
EXPECT_EQ(0, audio_device_->InitPlayout());
|
||||
// Sleep is needed for e.g. iPhone since we after stopping then starting may
|
||||
// have a hangover time of a couple of ms before initialized.
|
||||
AudioDeviceUtility::Sleep(50);
|
||||
SleepMs(50);
|
||||
EXPECT_TRUE(audio_device_->PlayoutIsInitialized());
|
||||
}
|
||||
|
||||
@ -580,7 +581,7 @@ TEST_F(AudioDeviceAPITest, InitRecording) {
|
||||
EXPECT_EQ(0, audio_device_->RecordingIsAvailable(&available));
|
||||
if (available) {
|
||||
EXPECT_EQ(0, audio_device_->InitRecording());
|
||||
AudioDeviceUtility::Sleep(50);
|
||||
SleepMs(50);
|
||||
EXPECT_TRUE(audio_device_->RecordingIsInitialized());
|
||||
}
|
||||
|
||||
@ -1704,7 +1705,7 @@ TEST_F(AudioDeviceAPITest, StartAndStopRawOutputFileRecording) {
|
||||
|
||||
EXPECT_EQ(0, audio_device_->StartRawOutputFileRecording(
|
||||
GetFilename("raw_output_playing.pcm")));
|
||||
AudioDeviceUtility::Sleep(100);
|
||||
SleepMs(100);
|
||||
EXPECT_EQ(0, audio_device_->StopRawOutputFileRecording());
|
||||
EXPECT_EQ(0, audio_device_->StopPlayout());
|
||||
EXPECT_EQ(0, audio_device_->StartRawOutputFileRecording(
|
||||
@ -1738,7 +1739,7 @@ TEST_F(AudioDeviceAPITest, StartAndStopRawInputFileRecording) {
|
||||
#endif
|
||||
EXPECT_EQ(0, audio_device_->StartRawInputFileRecording(
|
||||
GetFilename("raw_input_recording.pcm")));
|
||||
AudioDeviceUtility::Sleep(100);
|
||||
SleepMs(100);
|
||||
EXPECT_EQ(0, audio_device_->StopRawInputFileRecording());
|
||||
EXPECT_EQ(0, audio_device_->StopRecording());
|
||||
EXPECT_EQ(0, audio_device_->StartRawInputFileRecording(
|
||||
@ -1806,7 +1807,7 @@ TEST_F(AudioDeviceAPITest, ResetAudioDevice) {
|
||||
{
|
||||
TEST_LOG("Resetting sound device several time with pause %d ms\n", l);
|
||||
EXPECT_EQ(0, audio_device_->ResetAudioDevice());
|
||||
AudioDeviceUtility::Sleep(l);
|
||||
SleepMs(l);
|
||||
}
|
||||
#else
|
||||
// Fail tests
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "func_test_manager.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "system_wrappers/interface/sleep.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
#include "../source/audio_device_config.h"
|
||||
@ -1301,7 +1302,7 @@ WebRtc_Word32 FuncTestManager::TestAudioTransport()
|
||||
EXPECT_EQ(0, audioDevice->SetRecordingChannel(AudioDeviceModule::kChannelLeft));
|
||||
}
|
||||
EXPECT_EQ(0, audioDevice->StartRecording());
|
||||
AudioDeviceUtility::Sleep(100);
|
||||
SleepMs(100);
|
||||
|
||||
EXPECT_TRUE(audioDevice->Recording());
|
||||
if (audioDevice->Recording())
|
||||
@ -1337,7 +1338,7 @@ WebRtc_Word32 FuncTestManager::TestAudioTransport()
|
||||
{
|
||||
EXPECT_EQ(0, audioDevice->InitPlayout());
|
||||
EXPECT_EQ(0, audioDevice->StartPlayout());
|
||||
AudioDeviceUtility::Sleep(100);
|
||||
SleepMs(100);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(audioDevice->Playing());
|
||||
@ -1392,7 +1393,7 @@ WebRtc_Word32 FuncTestManager::TestAudioTransport()
|
||||
|
||||
EXPECT_EQ(0, audioDevice->StartRecording());
|
||||
EXPECT_EQ(0, audioDevice->StartPlayout());
|
||||
AudioDeviceUtility::Sleep(100);
|
||||
SleepMs(100);
|
||||
|
||||
if (audioDevice->Playing() && audioDevice->Recording())
|
||||
{
|
||||
@ -2426,7 +2427,7 @@ WebRtc_Word32 FuncTestManager::TestDeviceRemoval()
|
||||
while (_audioEventObserver->_error
|
||||
== (AudioDeviceObserver::ErrorCode) (-1))
|
||||
{
|
||||
SLEEP(500);
|
||||
SleepMs(500);
|
||||
}
|
||||
} else
|
||||
{
|
||||
@ -2680,10 +2681,10 @@ WebRtc_Word32 FuncTestManager::TestAdvancedMBAPI()
|
||||
for (int l=0; l<20; ++l)
|
||||
{
|
||||
EXPECT_EQ(0, audioDevice->ResetAudioDevice());
|
||||
AudioDeviceUtility::Sleep(p);
|
||||
SleepMs(p);
|
||||
}
|
||||
TEST_LOG("\n> Speak into the microphone and verify that the audio is good.\n");
|
||||
AudioDeviceUtility::Sleep(2000);
|
||||
SleepMs(2000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -32,13 +32,11 @@
|
||||
#define DEFAULT_PAUSE_TIME 5000
|
||||
|
||||
#if defined(USE_SLEEP_AS_PAUSE)
|
||||
#define PAUSE(a) AudioDeviceUtility::Sleep(a);
|
||||
#define PAUSE(a) SleepMs(a);
|
||||
#else
|
||||
#define PAUSE(a) AudioDeviceUtility::WaitForKey();
|
||||
#endif
|
||||
|
||||
#define SLEEP(a) AudioDeviceUtility::Sleep(a);
|
||||
|
||||
#define ADM_AUDIO_LAYER AudioDeviceModule::kPlatformDefaultAudio
|
||||
//#define ADM_AUDIO_LAYER AudioDeviceModule::kLinuxPulseAudio
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user