ref: ade32f5c488c2c56c376ffba114a0be79be2b630
parent: a3f606e58a09c371893a1ece7d5d6c5b9eeb10ba
author: Sijia Chen <sijchen@cisco.com>
date: Thu Oct 15 07:27:43 EDT 2015
implementation for WelsSleep on WP8.0 https://rbcommons.com/s/OpenH264/r/1315/
--- a/codec/common/src/WelsThreadLib.cpp
+++ b/codec/common/src/WelsThreadLib.cpp
@@ -71,6 +71,7 @@
#ifdef WINAPI_FAMILY
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define WP80
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::System::Threading;
@@ -174,10 +175,31 @@
return WELS_THREAD_ERROR_OK;
}
+#ifndef WP80
void WelsSleep (uint32_t dwMilliSecond) {
::Sleep (dwMilliSecond);
}
+#else
+void WelsSleep (uint32_t dwMilliSecond) {
+ static WELS_EVENT hSleepEvent = NULL;
+ if (!hSleepEvent) {
+ WELS_EVENT hLocalSleepEvent = NULL;
+ WELS_THREAD_ERROR_CODE ret = WelsEventOpen (&hLocalSleepEvent);
+ if (WELS_THREAD_ERROR_OK != ret) {
+ return;
+ }
+ WELS_EVENT hPreviousEvent = InterlockedCompareExchangePointerRelease (&hSleepEvent, hLocalSleepEvent, NULL);
+ if (hPreviousEvent) {
+ WelsEventClose (&hLocalSleepEvent);
+ }
+ //On this singleton usage idea of using InterlockedCompareExchangePointerRelease:
+ // similar idea of can be found at msdn blog when introducing InterlockedCompareExchangePointerRelease
+ }
+ WaitForSingleObject (hSleepEvent, dwMilliSecond);
+}
+#endif
+
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
void* arg, WELS_THREAD_ATTR attr) {
#ifdef USE_THREADPOOL
@@ -229,7 +251,7 @@
return WELS_THREAD_ERROR_OK;
}
-#else
+#else //platform: #ifdef _WIN32
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
void* arg, WELS_THREAD_ATTR attr) {
--- a/test/common/CWelsCircleQueue.cpp
+++ b/test/common/CWelsCircleQueue.cpp
@@ -193,3 +193,4 @@
delete pTaskThread3;
}
#endif
+