Revert "Split EventWrapper in twain."
This reverts commit 9509fbfc301dd5412804ce5731afedc81480f2f8. This is to debug a Chromium issue that WebRTC hangs if there is > 1 PeerConnection active in the browser on Win XP. BUG= TBR=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/43019004 Cr-Commit-Position: refs/heads/master@{#8912}
This commit is contained in:
parent
31331cfd2d
commit
cf3c83e76c
@ -247,14 +247,14 @@ int16_t APITest::SetUp() {
|
|||||||
|
|
||||||
//--- EVENT TIMERS
|
//--- EVENT TIMERS
|
||||||
// A
|
// A
|
||||||
_pullEventA = EventTimerWrapper::Create();
|
_pullEventA = EventWrapper::Create();
|
||||||
_pushEventA = EventTimerWrapper::Create();
|
_pushEventA = EventWrapper::Create();
|
||||||
_processEventA = EventTimerWrapper::Create();
|
_processEventA = EventWrapper::Create();
|
||||||
_apiEventA = EventWrapper::Create();
|
_apiEventA = EventWrapper::Create();
|
||||||
// B
|
// B
|
||||||
_pullEventB = EventTimerWrapper::Create();
|
_pullEventB = EventWrapper::Create();
|
||||||
_pushEventB = EventTimerWrapper::Create();
|
_pushEventB = EventWrapper::Create();
|
||||||
_processEventB = EventTimerWrapper::Create();
|
_processEventB = EventWrapper::Create();
|
||||||
_apiEventB = EventWrapper::Create();
|
_apiEventB = EventWrapper::Create();
|
||||||
|
|
||||||
//--- I/O params
|
//--- I/O params
|
||||||
@ -682,7 +682,7 @@ void APITest::TestDelay(char side) {
|
|||||||
AudioCodingModule* myACM;
|
AudioCodingModule* myACM;
|
||||||
Channel* myChannel;
|
Channel* myChannel;
|
||||||
int32_t* myMinDelay;
|
int32_t* myMinDelay;
|
||||||
EventTimerWrapper* myEvent = EventTimerWrapper::Create();
|
EventWrapper* myEvent = EventWrapper::Create();
|
||||||
|
|
||||||
uint32_t inTimestamp = 0;
|
uint32_t inTimestamp = 0;
|
||||||
uint32_t outTimestamp = 0;
|
uint32_t outTimestamp = 0;
|
||||||
|
@ -109,14 +109,14 @@ class APITest : public ACMTest {
|
|||||||
bool _writeToFile;
|
bool _writeToFile;
|
||||||
//--- Events
|
//--- Events
|
||||||
// A
|
// A
|
||||||
EventTimerWrapper* _pullEventA; // pulling data from ACM
|
EventWrapper* _pullEventA; // pulling data from ACM
|
||||||
EventTimerWrapper* _pushEventA; // pushing data to ACM
|
EventWrapper* _pushEventA; // pushing data to ACM
|
||||||
EventTimerWrapper* _processEventA; // process
|
EventWrapper* _processEventA; // process
|
||||||
EventWrapper* _apiEventA; // API calls
|
EventWrapper* _apiEventA; // API calls
|
||||||
// B
|
// B
|
||||||
EventTimerWrapper* _pullEventB; // pulling data from ACM
|
EventWrapper* _pullEventB; // pulling data from ACM
|
||||||
EventTimerWrapper* _pushEventB; // pushing data to ACM
|
EventWrapper* _pushEventB; // pushing data to ACM
|
||||||
EventTimerWrapper* _processEventB; // process
|
EventWrapper* _processEventB; // process
|
||||||
EventWrapper* _apiEventB; // API calls
|
EventWrapper* _apiEventB; // API calls
|
||||||
|
|
||||||
// keep track of the codec in either side.
|
// keep track of the codec in either side.
|
||||||
|
@ -292,7 +292,7 @@ void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
|
|||||||
|
|
||||||
char currentTime[500];
|
char currentTime[500];
|
||||||
CodecInst sendCodec;
|
CodecInst sendCodec;
|
||||||
EventTimerWrapper* myEvent = EventTimerWrapper::Create();
|
EventWrapper* myEvent = EventWrapper::Create();
|
||||||
EXPECT_TRUE(myEvent->StartTimer(true, 10));
|
EXPECT_TRUE(myEvent->StartTimer(true, 10));
|
||||||
while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
|
while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
|
||||||
Run10ms();
|
Run10ms();
|
||||||
|
@ -47,7 +47,7 @@ namespace webrtc {
|
|||||||
AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id) :
|
AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id) :
|
||||||
_ptrAudioBuffer(NULL),
|
_ptrAudioBuffer(NULL),
|
||||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_timeEvent(*EventTimerWrapper::Create()),
|
_timeEvent(*EventWrapper::Create()),
|
||||||
_recStartEvent(*EventWrapper::Create()),
|
_recStartEvent(*EventWrapper::Create()),
|
||||||
_playStartEvent(*EventWrapper::Create()),
|
_playStartEvent(*EventWrapper::Create()),
|
||||||
_hGetCaptureVolumeThread(NULL),
|
_hGetCaptureVolumeThread(NULL),
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#pragma comment( lib, "winmm.lib" )
|
#pragma comment( lib, "winmm.lib" )
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class EventTimerWrapper;
|
|
||||||
class EventWrapper;
|
class EventWrapper;
|
||||||
|
|
||||||
const uint32_t TIMER_PERIOD_MS = 2;
|
const uint32_t TIMER_PERIOD_MS = 2;
|
||||||
@ -212,7 +211,7 @@ private:
|
|||||||
AudioDeviceBuffer* _ptrAudioBuffer;
|
AudioDeviceBuffer* _ptrAudioBuffer;
|
||||||
|
|
||||||
CriticalSectionWrapper& _critSect;
|
CriticalSectionWrapper& _critSect;
|
||||||
EventTimerWrapper& _timeEvent;
|
EventWrapper& _timeEvent;
|
||||||
EventWrapper& _recStartEvent;
|
EventWrapper& _recStartEvent;
|
||||||
EventWrapper& _playStartEvent;
|
EventWrapper& _playStartEvent;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ IncomingVideoStream::IncomingVideoStream(const int32_t module_id,
|
|||||||
thread_critsect_(*CriticalSectionWrapper::CreateCriticalSection()),
|
thread_critsect_(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
buffer_critsect_(*CriticalSectionWrapper::CreateCriticalSection()),
|
buffer_critsect_(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
incoming_render_thread_(),
|
incoming_render_thread_(),
|
||||||
deliver_buffer_event_(*EventTimerWrapper::Create()),
|
deliver_buffer_event_(*EventWrapper::Create()),
|
||||||
running_(false),
|
running_(false),
|
||||||
external_callback_(NULL),
|
external_callback_(NULL),
|
||||||
render_callback_(NULL),
|
render_callback_(NULL),
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class EventTimerWrapper;
|
class EventWrapper;
|
||||||
class ThreadWrapper;
|
class ThreadWrapper;
|
||||||
class VideoRenderCallback;
|
class VideoRenderCallback;
|
||||||
class VideoRenderFrames;
|
class VideoRenderFrames;
|
||||||
@ -73,7 +73,7 @@ class IncomingVideoStream : public VideoRenderCallback {
|
|||||||
CriticalSectionWrapper& thread_critsect_;
|
CriticalSectionWrapper& thread_critsect_;
|
||||||
CriticalSectionWrapper& buffer_critsect_;
|
CriticalSectionWrapper& buffer_critsect_;
|
||||||
rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_;
|
rtc::scoped_ptr<ThreadWrapper> incoming_render_thread_;
|
||||||
EventTimerWrapper& deliver_buffer_event_;
|
EventWrapper& deliver_buffer_event_;
|
||||||
bool running_;
|
bool running_;
|
||||||
|
|
||||||
VideoRenderCallback* external_callback_;
|
VideoRenderCallback* external_callback_;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class EventTimerWrapper;
|
class EventWrapper;
|
||||||
|
|
||||||
class VideoRenderIosGles20 {
|
class VideoRenderIosGles20 {
|
||||||
public:
|
public:
|
||||||
@ -63,7 +63,7 @@ class VideoRenderIosGles20 {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::scoped_ptr<CriticalSectionWrapper> gles_crit_sec_;
|
rtc::scoped_ptr<CriticalSectionWrapper> gles_crit_sec_;
|
||||||
EventTimerWrapper* screen_update_event_;
|
EventWrapper* screen_update_event_;
|
||||||
rtc::scoped_ptr<ThreadWrapper> screen_update_thread_;
|
rtc::scoped_ptr<ThreadWrapper> screen_update_thread_;
|
||||||
|
|
||||||
VideoRenderIosView* view_;
|
VideoRenderIosView* view_;
|
||||||
|
@ -34,7 +34,7 @@ VideoRenderIosGles20::VideoRenderIosGles20(VideoRenderIosView* view,
|
|||||||
is_rendering_(true) {
|
is_rendering_(true) {
|
||||||
screen_update_thread_ = ThreadWrapper::CreateThread(
|
screen_update_thread_ = ThreadWrapper::CreateThread(
|
||||||
ScreenUpdateThreadProc, this, "ScreenUpdateGles20");
|
ScreenUpdateThreadProc, this, "ScreenUpdateGles20");
|
||||||
screen_update_event_ = EventTimerWrapper::Create();
|
screen_update_event_ = EventWrapper::Create();
|
||||||
GetWindowRect(window_rect_);
|
GetWindowRect(window_rect_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +31,16 @@
|
|||||||
class Trace;
|
class Trace;
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class EventTimerWrapper;
|
class EventWrapper;
|
||||||
class ThreadWrapper;
|
class ThreadWrapper;
|
||||||
class VideoRenderNSOpenGL;
|
class VideoRenderNSOpenGL;
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
|
|
||||||
class VideoChannelNSOpenGL : public VideoRenderCallback {
|
class VideoChannelNSOpenGL : public VideoRenderCallback
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VideoChannelNSOpenGL(NSOpenGLContext *nsglContext, int iId, VideoRenderNSOpenGL* owner);
|
VideoChannelNSOpenGL(NSOpenGLContext *nsglContext, int iId, VideoRenderNSOpenGL* owner);
|
||||||
virtual ~VideoChannelNSOpenGL();
|
virtual ~VideoChannelNSOpenGL();
|
||||||
|
|
||||||
@ -167,7 +170,7 @@ private: // variables
|
|||||||
int _id;
|
int _id;
|
||||||
CriticalSectionWrapper& _nsglContextCritSec;
|
CriticalSectionWrapper& _nsglContextCritSec;
|
||||||
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
|
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
|
||||||
EventTimerWrapper* _screenUpdateEvent;
|
EventWrapper* _screenUpdateEvent;
|
||||||
NSOpenGLContext* _nsglContext;
|
NSOpenGLContext* _nsglContext;
|
||||||
NSOpenGLContext* _nsglFullScreenContext;
|
NSOpenGLContext* _nsglFullScreenContext;
|
||||||
CocoaFullScreenWindow* _fullScreenWindow;
|
CocoaFullScreenWindow* _fullScreenWindow;
|
||||||
|
@ -367,7 +367,7 @@ _windowRef( (CocoaRenderView*)windowRef),
|
|||||||
_fullScreen( fullScreen),
|
_fullScreen( fullScreen),
|
||||||
_id( iId),
|
_id( iId),
|
||||||
_nsglContextCritSec( *CriticalSectionWrapper::CreateCriticalSection()),
|
_nsglContextCritSec( *CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_screenUpdateEvent(EventTimerWrapper::Create()),
|
_screenUpdateEvent( 0),
|
||||||
_nsglContext( 0),
|
_nsglContext( 0),
|
||||||
_nsglFullScreenContext( 0),
|
_nsglFullScreenContext( 0),
|
||||||
_fullScreenWindow( nil),
|
_fullScreenWindow( nil),
|
||||||
@ -382,6 +382,7 @@ _windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
|
|||||||
{
|
{
|
||||||
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc,
|
_screenUpdateThread = ThreadWrapper::CreateThread(ScreenUpdateThreadProc,
|
||||||
this, "ScreenUpdateNSOpenGL");
|
this, "ScreenUpdateNSOpenGL");
|
||||||
|
_screenUpdateEvent = EventWrapper::Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
int VideoRenderNSOpenGL::ChangeWindow(CocoaRenderView* newWindowRef)
|
int VideoRenderNSOpenGL::ChangeWindow(CocoaRenderView* newWindowRef)
|
||||||
|
@ -297,7 +297,7 @@ VideoRenderDirect3D9::VideoRenderDirect3D9(Trace* trace,
|
|||||||
{
|
{
|
||||||
_screenUpdateThread = ThreadWrapper::CreateThread(
|
_screenUpdateThread = ThreadWrapper::CreateThread(
|
||||||
ScreenUpdateThreadProc, this, "ScreenUpdateThread");
|
ScreenUpdateThreadProc, this, "ScreenUpdateThread");
|
||||||
_screenUpdateEvent = EventTimerWrapper::Create();
|
_screenUpdateEvent = EventWrapper::Create();
|
||||||
SetRect(&_originalHwndRect, 0, 0, 0, 0);
|
SetRect(&_originalHwndRect, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class EventTimerWrapper;
|
class EventWrapper;
|
||||||
class Trace;
|
class Trace;
|
||||||
|
|
||||||
class D3D9Channel: public VideoRenderCallback
|
class D3D9Channel: public VideoRenderCallback
|
||||||
@ -205,7 +205,7 @@ private:
|
|||||||
CriticalSectionWrapper& _refD3DCritsect;
|
CriticalSectionWrapper& _refD3DCritsect;
|
||||||
Trace* _trace;
|
Trace* _trace;
|
||||||
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
|
rtc::scoped_ptr<ThreadWrapper> _screenUpdateThread;
|
||||||
EventTimerWrapper* _screenUpdateEvent;
|
EventWrapper* _screenUpdateEvent;
|
||||||
|
|
||||||
HWND _hWnd;
|
HWND _hWnd;
|
||||||
bool _fullScreen;
|
bool _fullScreen;
|
||||||
|
@ -65,11 +65,11 @@ static_library("system_wrappers") {
|
|||||||
"source/critical_section_win.h",
|
"source/critical_section_win.h",
|
||||||
"source/data_log_c.cc",
|
"source/data_log_c.cc",
|
||||||
"source/event.cc",
|
"source/event.cc",
|
||||||
"source/event_timer_posix.cc",
|
"source/event_posix.cc",
|
||||||
"source/event_timer_posix.h",
|
"source/event_posix.h",
|
||||||
"source/event_timer_win.cc",
|
|
||||||
"source/event_timer_win.h",
|
|
||||||
"source/event_tracer.cc",
|
"source/event_tracer.cc",
|
||||||
|
"source/event_win.cc",
|
||||||
|
"source/event_win.h",
|
||||||
"source/file_impl.cc",
|
"source/file_impl.cc",
|
||||||
"source/file_impl.h",
|
"source/file_impl.h",
|
||||||
"source/logging.cc",
|
"source/logging.cc",
|
||||||
|
@ -18,15 +18,13 @@ enum EventTypeWrapper {
|
|||||||
kEventTimeout = 3
|
kEventTimeout = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define WEBRTC_EVENT_10_SEC 10000
|
||||||
#define WEBRTC_EVENT_INFINITE 0xffffffff
|
#define WEBRTC_EVENT_INFINITE 0xffffffff
|
||||||
|
|
||||||
class EventTimerWrapper;
|
|
||||||
|
|
||||||
class EventWrapper {
|
class EventWrapper {
|
||||||
public:
|
public:
|
||||||
// Factory method. Constructor disabled.
|
// Factory method. Constructor disabled.
|
||||||
static EventWrapper* Create();
|
static EventWrapper* Create();
|
||||||
|
|
||||||
virtual ~EventWrapper() {}
|
virtual ~EventWrapper() {}
|
||||||
|
|
||||||
// Releases threads who are calling Wait() and has started waiting. Please
|
// Releases threads who are calling Wait() and has started waiting. Please
|
||||||
@ -45,11 +43,6 @@ class EventWrapper {
|
|||||||
// be released. It is possible that multiple (random) threads are released
|
// be released. It is possible that multiple (random) threads are released
|
||||||
// Depending on timing.
|
// Depending on timing.
|
||||||
virtual EventTypeWrapper Wait(unsigned long max_time) = 0;
|
virtual EventTypeWrapper Wait(unsigned long max_time) = 0;
|
||||||
};
|
|
||||||
|
|
||||||
class EventTimerWrapper : public EventWrapper {
|
|
||||||
public:
|
|
||||||
static EventTimerWrapper* Create();
|
|
||||||
|
|
||||||
// Starts a timer that will call a non-sticky version of Set() either once
|
// Starts a timer that will call a non-sticky version of Set() either once
|
||||||
// or periodically. If the timer is periodic it ensures that there is no
|
// or periodically. If the timer is periodic it ensures that there is no
|
||||||
@ -59,7 +52,6 @@ class EventTimerWrapper : public EventWrapper {
|
|||||||
virtual bool StopTimer() = 0;
|
virtual bool StopTimer() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_WRAPPER_H_
|
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_EVENT_WRAPPER_H_
|
||||||
|
@ -12,43 +12,22 @@
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "webrtc/system_wrappers/source/event_timer_win.h"
|
#include "webrtc/system_wrappers/source/event_win.h"
|
||||||
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "webrtc/system_wrappers/source/event_timer_posix.h"
|
#include "webrtc/system_wrappers/source/event_posix.h"
|
||||||
#else
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "webrtc/system_wrappers/source/event_timer_posix.h"
|
#include "webrtc/system_wrappers/source/event_posix.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "webrtc/base/event.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class EventWrapperImpl : public EventWrapper {
|
|
||||||
public:
|
|
||||||
EventWrapperImpl() : event_(false, false) {}
|
|
||||||
~EventWrapperImpl() override {}
|
|
||||||
|
|
||||||
bool Set() override {
|
|
||||||
event_.Set();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
EventTypeWrapper Wait(unsigned long max_time) override {
|
|
||||||
int to_wait = max_time == WEBRTC_EVENT_INFINITE ?
|
|
||||||
rtc::Event::kForever : static_cast<int>(max_time);
|
|
||||||
return event_.Wait(to_wait) ? kEventSignaled : kEventTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
rtc::Event event_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// static
|
|
||||||
EventWrapper* EventWrapper::Create() {
|
EventWrapper* EventWrapper::Create() {
|
||||||
return new EventWrapperImpl();
|
#if defined(_WIN32)
|
||||||
|
return new EventWindows();
|
||||||
|
#else
|
||||||
|
return EventPosix::Create();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -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 "webrtc/system_wrappers/source/event_timer_posix.h"
|
#include "webrtc/system_wrappers/source/event_posix.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -22,17 +22,17 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// static
|
|
||||||
EventTimerWrapper* EventTimerWrapper::Create() {
|
|
||||||
return new EventTimerPosix();
|
|
||||||
}
|
|
||||||
|
|
||||||
const long int E6 = 1000000;
|
const long int E6 = 1000000;
|
||||||
const long int E9 = 1000 * E6;
|
const long int E9 = 1000 * E6;
|
||||||
|
|
||||||
EventTimerPosix::EventTimerPosix()
|
EventWrapper* EventPosix::Create() {
|
||||||
|
return new EventPosix();
|
||||||
|
}
|
||||||
|
|
||||||
|
EventPosix::EventPosix()
|
||||||
: event_set_(false),
|
: event_set_(false),
|
||||||
timer_thread_(nullptr),
|
timer_thread_(nullptr),
|
||||||
|
timer_event_(0),
|
||||||
created_at_(),
|
created_at_(),
|
||||||
periodic_(false),
|
periodic_(false),
|
||||||
time_(0),
|
time_(0),
|
||||||
@ -52,14 +52,14 @@ EventTimerPosix::EventTimerPosix()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTimerPosix::~EventTimerPosix() {
|
EventPosix::~EventPosix() {
|
||||||
StopTimer();
|
StopTimer();
|
||||||
pthread_cond_destroy(&cond_);
|
pthread_cond_destroy(&cond_);
|
||||||
pthread_mutex_destroy(&mutex_);
|
pthread_mutex_destroy(&mutex_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(pbos): Make this void.
|
// TODO(pbos): Make this void.
|
||||||
bool EventTimerPosix::Set() {
|
bool EventPosix::Set() {
|
||||||
CHECK_EQ(0, pthread_mutex_lock(&mutex_));
|
CHECK_EQ(0, pthread_mutex_lock(&mutex_));
|
||||||
event_set_ = true;
|
event_set_ = true;
|
||||||
pthread_cond_signal(&cond_);
|
pthread_cond_signal(&cond_);
|
||||||
@ -67,7 +67,7 @@ bool EventTimerPosix::Set() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTypeWrapper EventTimerPosix::Wait(unsigned long timeout) {
|
EventTypeWrapper EventPosix::Wait(unsigned long timeout) {
|
||||||
int ret_val = 0;
|
int ret_val = 0;
|
||||||
CHECK_EQ(0, pthread_mutex_lock(&mutex_));
|
CHECK_EQ(0, pthread_mutex_lock(&mutex_));
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ EventTypeWrapper EventTimerPosix::Wait(unsigned long timeout) {
|
|||||||
return ret_val == 0 ? kEventSignaled : kEventTimeout;
|
return ret_val == 0 ? kEventSignaled : kEventTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTypeWrapper EventTimerPosix::Wait(timespec* end_at) {
|
EventTypeWrapper EventPosix::Wait(timespec* end_at) {
|
||||||
int ret_val = 0;
|
int ret_val = 0;
|
||||||
CHECK_EQ(0, pthread_mutex_lock(&mutex_));
|
CHECK_EQ(0, pthread_mutex_lock(&mutex_));
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ EventTypeWrapper EventTimerPosix::Wait(timespec* end_at) {
|
|||||||
return ret_val == 0 ? kEventSignaled : kEventTimeout;
|
return ret_val == 0 ? kEventSignaled : kEventTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventTimerPosix::StartTimer(bool periodic, unsigned long time) {
|
bool EventPosix::StartTimer(bool periodic, unsigned long time) {
|
||||||
pthread_mutex_lock(&mutex_);
|
pthread_mutex_lock(&mutex_);
|
||||||
if (timer_thread_) {
|
if (timer_thread_) {
|
||||||
if (periodic_) {
|
if (periodic_) {
|
||||||
@ -152,7 +152,7 @@ bool EventTimerPosix::StartTimer(bool periodic, unsigned long time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start the timer thread
|
// Start the timer thread
|
||||||
timer_event_.reset(new EventTimerPosix());
|
timer_event_ = static_cast<EventPosix*>(EventWrapper::Create());
|
||||||
const char* thread_name = "WebRtc_event_timer_thread";
|
const char* thread_name = "WebRtc_event_timer_thread";
|
||||||
timer_thread_ = ThreadWrapper::CreateThread(Run, this, thread_name);
|
timer_thread_ = ThreadWrapper::CreateThread(Run, this, thread_name);
|
||||||
periodic_ = periodic;
|
periodic_ = periodic;
|
||||||
@ -164,11 +164,11 @@ bool EventTimerPosix::StartTimer(bool periodic, unsigned long time) {
|
|||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventTimerPosix::Run(void* obj) {
|
bool EventPosix::Run(void* obj) {
|
||||||
return static_cast<EventTimerPosix*>(obj)->Process();
|
return static_cast<EventPosix*>(obj)->Process();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventTimerPosix::Process() {
|
bool EventPosix::Process() {
|
||||||
pthread_mutex_lock(&mutex_);
|
pthread_mutex_lock(&mutex_);
|
||||||
if (created_at_.tv_sec == 0) {
|
if (created_at_.tv_sec == 0) {
|
||||||
#ifndef WEBRTC_MAC
|
#ifndef WEBRTC_MAC
|
||||||
@ -210,7 +210,7 @@ bool EventTimerPosix::Process() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventTimerPosix::StopTimer() {
|
bool EventPosix::StopTimer() {
|
||||||
if (timer_event_) {
|
if (timer_event_) {
|
||||||
timer_event_->Set();
|
timer_event_->Set();
|
||||||
}
|
}
|
||||||
@ -220,7 +220,10 @@ bool EventTimerPosix::StopTimer() {
|
|||||||
}
|
}
|
||||||
timer_thread_.reset();
|
timer_thread_.reset();
|
||||||
}
|
}
|
||||||
timer_event_.reset();
|
if (timer_event_) {
|
||||||
|
delete timer_event_;
|
||||||
|
timer_event_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Set time to zero to force new reference time for the timer.
|
// Set time to zero to force new reference time for the timer.
|
||||||
memset(&created_at_, 0, sizeof(created_at_));
|
memset(&created_at_, 0, sizeof(created_at_));
|
@ -25,10 +25,11 @@ enum State {
|
|||||||
kDown = 2
|
kDown = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventTimerPosix : public EventTimerWrapper {
|
class EventPosix : public EventWrapper {
|
||||||
public:
|
public:
|
||||||
EventTimerPosix();
|
static EventWrapper* Create();
|
||||||
~EventTimerPosix() override;
|
|
||||||
|
~EventPosix() override;
|
||||||
|
|
||||||
EventTypeWrapper Wait(unsigned long max_time) override;
|
EventTypeWrapper Wait(unsigned long max_time) override;
|
||||||
bool Set() override;
|
bool Set() override;
|
||||||
@ -37,6 +38,8 @@ class EventTimerPosix : public EventTimerWrapper {
|
|||||||
bool StopTimer() override;
|
bool StopTimer() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
EventPosix();
|
||||||
|
|
||||||
static bool Run(void* obj);
|
static bool Run(void* obj);
|
||||||
bool Process();
|
bool Process();
|
||||||
EventTypeWrapper Wait(timespec* end_at);
|
EventTypeWrapper Wait(timespec* end_at);
|
||||||
@ -47,7 +50,7 @@ class EventTimerPosix : public EventTimerWrapper {
|
|||||||
bool event_set_;
|
bool event_set_;
|
||||||
|
|
||||||
rtc::scoped_ptr<ThreadWrapper> timer_thread_;
|
rtc::scoped_ptr<ThreadWrapper> timer_thread_;
|
||||||
rtc::scoped_ptr<EventTimerPosix> timer_event_;
|
EventPosix* timer_event_;
|
||||||
timespec created_at_;
|
timespec created_at_;
|
||||||
|
|
||||||
bool periodic_;
|
bool periodic_;
|
@ -8,18 +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 "webrtc/system_wrappers/source/event_timer_win.h"
|
#include "webrtc/system_wrappers/source/event_win.h"
|
||||||
|
|
||||||
#include "Mmsystem.h"
|
#include "Mmsystem.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// static
|
EventWindows::EventWindows()
|
||||||
EventTimerWrapper* EventTimerWrapper::Create() {
|
|
||||||
return new EventTimerWin();
|
|
||||||
}
|
|
||||||
|
|
||||||
EventTimerWin::EventTimerWin()
|
|
||||||
: event_(::CreateEvent(NULL, // security attributes
|
: event_(::CreateEvent(NULL, // security attributes
|
||||||
FALSE, // manual reset
|
FALSE, // manual reset
|
||||||
FALSE, // initial state
|
FALSE, // initial state
|
||||||
@ -27,17 +22,17 @@ EventTimerWin::EventTimerWin()
|
|||||||
timerID_(NULL) {
|
timerID_(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTimerWin::~EventTimerWin() {
|
EventWindows::~EventWindows() {
|
||||||
StopTimer();
|
StopTimer();
|
||||||
CloseHandle(event_);
|
CloseHandle(event_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventTimerWin::Set() {
|
bool EventWindows::Set() {
|
||||||
// Note: setting an event that is already set has no effect.
|
// Note: setting an event that is already set has no effect.
|
||||||
return SetEvent(event_) == 1;
|
return SetEvent(event_) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTypeWrapper EventTimerWin::Wait(unsigned long max_time) {
|
EventTypeWrapper EventWindows::Wait(unsigned long max_time) {
|
||||||
unsigned long res = WaitForSingleObject(event_, max_time);
|
unsigned long res = WaitForSingleObject(event_, max_time);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
@ -49,7 +44,7 @@ EventTypeWrapper EventTimerWin::Wait(unsigned long max_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventTimerWin::StartTimer(bool periodic, unsigned long time) {
|
bool EventWindows::StartTimer(bool periodic, unsigned long time) {
|
||||||
if (timerID_ != NULL) {
|
if (timerID_ != NULL) {
|
||||||
timeKillEvent(timerID_);
|
timeKillEvent(timerID_);
|
||||||
timerID_ = NULL;
|
timerID_ = NULL;
|
||||||
@ -66,7 +61,7 @@ bool EventTimerWin::StartTimer(bool periodic, unsigned long time) {
|
|||||||
return timerID_ != NULL;
|
return timerID_ != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventTimerWin::StopTimer() {
|
bool EventWindows::StopTimer() {
|
||||||
if (timerID_ != NULL) {
|
if (timerID_ != NULL) {
|
||||||
timeKillEvent(timerID_);
|
timeKillEvent(timerID_);
|
||||||
timerID_ = NULL;
|
timerID_ = NULL;
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class EventTimerWin : public EventTimerWrapper {
|
class EventWindows : public EventWrapper {
|
||||||
public:
|
public:
|
||||||
EventTimerWin();
|
EventWindows();
|
||||||
virtual ~EventTimerWin();
|
virtual ~EventWindows();
|
||||||
|
|
||||||
virtual EventTypeWrapper Wait(unsigned long max_time);
|
virtual EventTypeWrapper Wait(unsigned long max_time);
|
||||||
virtual bool Set();
|
virtual bool Set();
|
@ -75,11 +75,11 @@
|
|||||||
'source/data_log_c.cc',
|
'source/data_log_c.cc',
|
||||||
'source/data_log_no_op.cc',
|
'source/data_log_no_op.cc',
|
||||||
'source/event.cc',
|
'source/event.cc',
|
||||||
'source/event_timer_posix.cc',
|
'source/event_posix.cc',
|
||||||
'source/event_timer_posix.h',
|
'source/event_posix.h',
|
||||||
'source/event_timer_win.cc',
|
|
||||||
'source/event_timer_win.h',
|
|
||||||
'source/event_tracer.cc',
|
'source/event_tracer.cc',
|
||||||
|
'source/event_win.cc',
|
||||||
|
'source/event_win.h',
|
||||||
'source/file_impl.cc',
|
'source/file_impl.cc',
|
||||||
'source/file_impl.h',
|
'source/file_impl.h',
|
||||||
'source/logcat_trace_context.cc',
|
'source/logcat_trace_context.cc',
|
||||||
|
@ -30,7 +30,7 @@ FakeAudioDevice::FakeAudioDevice(Clock* clock, const std::string& filename)
|
|||||||
playout_buffer_(),
|
playout_buffer_(),
|
||||||
last_playout_ms_(-1),
|
last_playout_ms_(-1),
|
||||||
clock_(clock),
|
clock_(clock),
|
||||||
tick_(EventTimerWrapper::Create()),
|
tick_(EventWrapper::Create()),
|
||||||
lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
file_utility_(new ModuleFileUtility(0)),
|
file_utility_(new ModuleFileUtility(0)),
|
||||||
input_stream_(FileWrapper::Create()) {
|
input_stream_(FileWrapper::Create()) {
|
||||||
|
@ -20,7 +20,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
class Clock;
|
class Clock;
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class EventTimerWrapper;
|
class EventWrapper;
|
||||||
class FileWrapper;
|
class FileWrapper;
|
||||||
class ModuleFileUtility;
|
class ModuleFileUtility;
|
||||||
class ThreadWrapper;
|
class ThreadWrapper;
|
||||||
@ -57,7 +57,7 @@ class FakeAudioDevice : public FakeAudioDeviceModule {
|
|||||||
int64_t last_playout_ms_;
|
int64_t last_playout_ms_;
|
||||||
|
|
||||||
Clock* clock_;
|
Clock* clock_;
|
||||||
rtc::scoped_ptr<EventTimerWrapper> tick_;
|
rtc::scoped_ptr<EventWrapper> tick_;
|
||||||
rtc::scoped_ptr<CriticalSectionWrapper> lock_;
|
rtc::scoped_ptr<CriticalSectionWrapper> lock_;
|
||||||
rtc::scoped_ptr<ThreadWrapper> thread_;
|
rtc::scoped_ptr<ThreadWrapper> thread_;
|
||||||
rtc::scoped_ptr<ModuleFileUtility> file_utility_;
|
rtc::scoped_ptr<ModuleFileUtility> file_utility_;
|
||||||
|
@ -65,7 +65,7 @@ FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock,
|
|||||||
: VideoCapturer(input),
|
: VideoCapturer(input),
|
||||||
clock_(clock),
|
clock_(clock),
|
||||||
sending_(false),
|
sending_(false),
|
||||||
tick_(EventTimerWrapper::Create()),
|
tick_(EventWrapper::Create()),
|
||||||
lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
frame_generator_(frame_generator),
|
frame_generator_(frame_generator),
|
||||||
target_fps_(target_fps),
|
target_fps_(target_fps),
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class EventTimerWrapper;
|
class EventWrapper;
|
||||||
class ThreadWrapper;
|
class ThreadWrapper;
|
||||||
|
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -60,7 +60,7 @@ class FrameGeneratorCapturer : public VideoCapturer {
|
|||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
bool sending_;
|
bool sending_;
|
||||||
|
|
||||||
rtc::scoped_ptr<EventTimerWrapper> tick_;
|
rtc::scoped_ptr<EventWrapper> tick_;
|
||||||
rtc::scoped_ptr<CriticalSectionWrapper> lock_;
|
rtc::scoped_ptr<CriticalSectionWrapper> lock_;
|
||||||
rtc::scoped_ptr<ThreadWrapper> thread_;
|
rtc::scoped_ptr<ThreadWrapper> thread_;
|
||||||
rtc::scoped_ptr<FrameGenerator> frame_generator_;
|
rtc::scoped_ptr<FrameGenerator> frame_generator_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user