[Android] Fix multiple pause/resume issue

This commit is contained in:
zilmar 2017-04-29 15:42:02 +10:00
parent 03f7e4ac94
commit 40e6919c61
1 changed files with 10 additions and 10 deletions

View File

@ -9,9 +9,9 @@ SyncEvent::SyncEvent(bool bManualReset)
m_Event = CreateEvent(NULL, bManualReset, FALSE, NULL);
#else
m_signalled = false;
m_Event = new pthread_mutex_t;
m_Event = new pthread_mutex_t;
m_cond = new pthread_cond_t;
pthread_mutex_init((pthread_mutex_t*)m_Event,NULL);
pthread_mutex_init((pthread_mutex_t*)m_Event, NULL);
pthread_cond_init((pthread_cond_t*)m_cond, NULL);
#endif
}
@ -21,7 +21,7 @@ SyncEvent::~SyncEvent()
#ifdef _WIN32
CloseHandle(m_Event);
#else
pthread_mutex_destroy((pthread_mutex_t*)m_Event);
pthread_mutex_destroy((pthread_mutex_t*)m_Event);
pthread_cond_destroy((pthread_cond_t*)m_cond);
delete (pthread_mutex_t*)m_Event;
delete (pthread_cond_t*)m_cond;
@ -31,7 +31,7 @@ SyncEvent::~SyncEvent()
void SyncEvent::Trigger()
{
#ifdef _WIN32
SetEvent(m_Event);
SetEvent(m_Event);
#else
pthread_mutex_lock((pthread_mutex_t*)m_Event);
m_signalled = true;
@ -43,15 +43,15 @@ void SyncEvent::Trigger()
bool SyncEvent::IsTriggered(int32_t iWaitTime)
{
#ifdef _WIN32
return (WAIT_OBJECT_0 == WaitForSingleObject(m_Event,iWaitTime));
return (WAIT_OBJECT_0 == WaitForSingleObject(m_Event, iWaitTime));
#else
pthread_mutex_lock((pthread_mutex_t*)m_Event);
while (!m_signalled)
{
pthread_cond_wait((pthread_cond_t*)m_cond, (pthread_mutex_t*)m_Event);
}
m_signalled = false;
pthread_mutex_unlock((pthread_mutex_t*)m_Event);
Reset();
return true;
#endif
}
@ -59,11 +59,11 @@ bool SyncEvent::IsTriggered(int32_t iWaitTime)
void SyncEvent::Reset()
{
#ifdef _WIN32
ResetEvent(m_Event);
ResetEvent(m_Event);
#else
#ifdef tofix
pthread_mutex_unlock(&evt.m_mutex);
#endif
pthread_mutex_lock((pthread_mutex_t*)m_Event);
m_signalled = false;
pthread_mutex_unlock((pthread_mutex_t*)m_Event);
#endif
}