Replace voice engine utility functions with system wrapper variants.

SLEEP -> SleepMs
GET_TIME_IN_MS -> TickTime::MillisecondTimestamp

These could cause unused function errors on some compilers.

BUG=1228

Review URL: https://webrtc-codereview.appspot.com/1013004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3326 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2013-01-02 16:06:39 +00:00
parent 943770b1ab
commit 00c7c4315b
8 changed files with 290 additions and 346 deletions

View File

@ -9,9 +9,9 @@
*/ */
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "modules/media_file/interface/media_file.h" #include "webrtc/modules/media_file/interface/media_file.h"
#include "testsupport/fileutils.h" #include "webrtc/system_wrappers/interface/sleep.h"
#include "voice_engine/voice_engine_defines.h" // defines SLEEP #include "webrtc/test/testsupport/fileutils.h"
class MediaFileTest : public testing::Test { class MediaFileTest : public testing::Test {
protected: protected:
@ -40,7 +40,7 @@ TEST_F(MediaFileTest, StartPlayingAudioFileWithoutError) {
ASSERT_EQ(true, media_file_->IsPlaying()); ASSERT_EQ(true, media_file_->IsPlaying());
SLEEP(1); webrtc::SleepMs(1);
ASSERT_EQ(0, media_file_->StopPlaying()); ASSERT_EQ(0, media_file_->StopPlaying());
} }

View File

@ -8,8 +8,9 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "monitor_module.h" #include "webrtc/system_wrappers/interface/tick_util.h"
#include "webrtc/voice_engine/monitor_module.h"
namespace webrtc { namespace webrtc {
@ -18,7 +19,7 @@ namespace voe {
MonitorModule::MonitorModule() : MonitorModule::MonitorModule() :
_observerPtr(NULL), _observerPtr(NULL),
_callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
_lastProcessTime(GET_TIME_IN_MS()) _lastProcessTime(TickTime::MillisecondTimestamp())
{ {
} }
@ -68,7 +69,7 @@ MonitorModule::ChangeUniqueId(const WebRtc_Word32 id)
WebRtc_Word32 WebRtc_Word32
MonitorModule::TimeUntilNextProcess() MonitorModule::TimeUntilNextProcess()
{ {
WebRtc_UWord32 now = GET_TIME_IN_MS(); WebRtc_UWord32 now = TickTime::MillisecondTimestamp();
WebRtc_Word32 timeToNext = WebRtc_Word32 timeToNext =
kAverageProcessUpdateTimeMs - (now - _lastProcessTime); kAverageProcessUpdateTimeMs - (now - _lastProcessTime);
return (timeToNext); return (timeToNext);
@ -77,7 +78,7 @@ MonitorModule::TimeUntilNextProcess()
WebRtc_Word32 WebRtc_Word32
MonitorModule::Process() MonitorModule::Process()
{ {
_lastProcessTime = GET_TIME_IN_MS(); _lastProcessTime = TickTime::MillisecondTimestamp();
if (_observerPtr) if (_observerPtr)
{ {
CriticalSectionScoped lock(&_callbackCritSect); CriticalSectionScoped lock(&_callbackCritSect);

View File

@ -8,12 +8,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "system_wrappers/interface/event_wrapper.h" #include "webrtc/system_wrappers/interface/event_wrapper.h"
#include "system_wrappers/interface/thread_wrapper.h" #include "webrtc/system_wrappers/interface/sleep.h"
#include "voice_engine/include/voe_network.h" #include "webrtc/system_wrappers/interface/thread_wrapper.h"
#include "voice_engine/voice_engine_defines.h" #include "webrtc/voice_engine/include/voe_network.h"
#include "voice_engine/test/auto_test/fakes/fake_external_transport.h" #include "webrtc/voice_engine/voice_engine_defines.h"
#include "webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.h"
FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr) FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr)
: my_network_(ptr), : my_network_(ptr),
@ -85,7 +86,7 @@ int FakeExternalTransport::SendRTCPPacket(int channel,
const void *data, const void *data,
int len) { int len) {
if (delay_is_enabled_) { if (delay_is_enabled_) {
Sleep(delay_time_in_ms_); webrtc::SleepMs(delay_time_in_ms_);
} }
my_network_->ReceivedRTCPPacket(channel, data, len); my_network_->ReceivedRTCPPacket(channel, data, len);
return len; return len;

View File

@ -8,9 +8,9 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "before_initialization_fixture.h" #include "webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"
#include "voice_engine_defines.h" #include "webrtc/system_wrappers/interface/sleep.h"
BeforeInitializationFixture::BeforeInitializationFixture() BeforeInitializationFixture::BeforeInitializationFixture()
: voice_engine_(webrtc::VoiceEngine::Create()) { : voice_engine_(webrtc::VoiceEngine::Create()) {
@ -52,7 +52,5 @@ BeforeInitializationFixture::~BeforeInitializationFixture() {
} }
void BeforeInitializationFixture::Sleep(long milliseconds) { void BeforeInitializationFixture::Sleep(long milliseconds) {
// Implementation note: This method is used to reduce usage of the macro and webrtc::SleepMs(milliseconds);
// avoid ugly errors in Eclipse (its parser can't deal with the sleep macro).
SLEEP(milliseconds);
} }

File diff suppressed because it is too large Load Diff

View File

@ -22,11 +22,12 @@
#include <conio.h> #include <conio.h>
#endif #endif
#include "voe_stress_test.h" #include "webrtc/voice_engine/test/auto_test/voe_stress_test.h"
#include "voe_standard_test.h" #include "webrtc/voice_engine/test/auto_test/voe_standard_test.h"
#include "voice_engine/voice_engine_defines.h" // defines build macros #include "webrtc/system_wrappers/interface/sleep.h"
#include "thread_wrapper.h" #include "webrtc/system_wrappers/interface/thread_wrapper.h"
#include "webrtc/voice_engine/voice_engine_defines.h" // defines build macros
using namespace webrtc; using namespace webrtc;
@ -44,7 +45,7 @@ namespace voetest {
#define PAUSE_OR_SLEEP(x) PAUSE; #define PAUSE_OR_SLEEP(x) PAUSE;
#else #else
// Sleep a bit instead if pause not supported // Sleep a bit instead if pause not supported
#define PAUSE_OR_SLEEP(x) SLEEP(x); #define PAUSE_OR_SLEEP(x) SleepMs(x);
#endif #endif
const char* VoEStressTest::_key = "====YUtFWRAAAAADBtIHgAAAAAEAAAAcAAAAAQBHU0ds" const char* VoEStressTest::_key = "====YUtFWRAAAAADBtIHgAAAAAEAAAAcAAAAAQBHU0ds"
@ -154,7 +155,7 @@ int VoEStressTest::StartStopTest() {
VALIDATE_STRESS(base->StartSend(0)); VALIDATE_STRESS(base->StartSend(0));
if (!(i % markInterval)) if (!(i % markInterval))
MARK(); MARK();
SLEEP(loopSleep); SleepMs(loopSleep);
VALIDATE_STRESS(base->StopSend(0)); VALIDATE_STRESS(base->StopSend(0));
VALIDATE_STRESS(base->StopPlayout(0)); VALIDATE_STRESS(base->StopPlayout(0));
VALIDATE_STRESS(base->StopReceive(0)); VALIDATE_STRESS(base->StopReceive(0));
@ -277,7 +278,7 @@ int VoEStressTest::CreateDeleteChannelsTest() {
if (!(i % markInterval)) if (!(i % markInterval))
MARK(); MARK();
SLEEP(loopSleep); SleepMs(loopSleep);
} }
ANL(); ANL();
@ -360,7 +361,7 @@ int VoEStressTest::MultipleThreadsTest() {
if (!(i % markInterval)) if (!(i % markInterval))
MARK(); MARK();
SLEEP(loopSleep); SleepMs(loopSleep);
} }
ANL(); ANL();

View File

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "voe_unit_test.h" #include "webrtc/voice_engine/test/auto_test/voe_unit_test.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -18,10 +18,11 @@
#include <conio.h> #include <conio.h>
#endif #endif
#include "system_wrappers/interface/thread_wrapper.h" #include "webrtc/system_wrappers/interface/thread_wrapper.h"
#include "testsupport/fileutils.h" #include "webrtc/system_wrappers/interface/sleep.h"
#include "voice_engine/voice_engine_defines.h" #include "webrtc/test/testsupport/fileutils.h"
#include "voice_engine/test/auto_test/fakes/fake_media_process.h" #include "webrtc/voice_engine/voice_engine_defines.h"
#include "webrtc/voice_engine/test/auto_test/fakes/fake_media_process.h"
using namespace webrtc; using namespace webrtc;
@ -320,7 +321,7 @@ void VoEUnitTest::Sleep(unsigned int timeMillisec, bool addMarker) {
printf("[dT=%.1f]", dtSec); printf("[dT=%.1f]", dtSec);
fflush(NULL); fflush(NULL);
} }
::Sleep(timeMillisec); webrtc::SleepMs(timeMillisec);
} }
void VoEUnitTest::Wait() { void VoEUnitTest::Wait() {

View File

@ -271,10 +271,7 @@ enum { kVoiceEngineMaxNumOfActiveChannels = 16 };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <windows.h> #include <windows.h>
#include <mmsystem.h> // timeGetTime
#define GET_TIME_IN_MS() ::timeGetTime()
#define SLEEP(x) ::Sleep(x)
// Comparison of two strings without regard to case // Comparison of two strings without regard to case
#define STR_CASE_CMP(x,y) ::_stricmp(x,y) #define STR_CASE_CMP(x,y) ::_stricmp(x,y)
// Compares characters of two strings without regard to case // Compares characters of two strings without regard to case
@ -338,31 +335,6 @@ enum { kVoiceEngineMaxNumOfActiveChannels = 16 };
#define __cdecl #define __cdecl
#define LPSOCKADDR struct sockaddr * #define LPSOCKADDR struct sockaddr *
namespace
{
void Sleep(unsigned long x)
{
timespec t;
t.tv_sec = x/1000;
t.tv_nsec = (x-(x/1000)*1000)*1000000;
nanosleep(&t,NULL);
}
DWORD timeGetTime()
{
struct timeval tv;
struct timezone tz;
unsigned long val;
gettimeofday(&tv, &tz);
val= tv.tv_sec*1000+ tv.tv_usec/1000;
return(val);
}
}
#define SLEEP(x) ::Sleep(x)
#define GET_TIME_IN_MS timeGetTime
// Default device for Linux and Android // Default device for Linux and Android
#define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0
@ -488,31 +460,6 @@ namespace webrtc
#define LPCSTR const char* #define LPCSTR const char*
#define ULONG unsigned long #define ULONG unsigned long
namespace
{
void Sleep(unsigned long x)
{
timespec t;
t.tv_sec = x/1000;
t.tv_nsec = (x-(x/1000)*1000)*1000000;
nanosleep(&t,NULL);
}
DWORD WebRtcTimeGetTime()
{
struct timeval tv;
struct timezone tz;
unsigned long val;
gettimeofday(&tv, &tz);
val= tv.tv_sec*1000+ tv.tv_usec/1000;
return(val);
}
}
#define SLEEP(x) ::Sleep(x)
#define GET_TIME_IN_MS WebRtcTimeGetTime
// Default device for Mac and iPhone // Default device for Mac and iPhone
#define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0