History

implementation for WelsSleep on WP8.0 https://rbcommons.com/s/OpenH264/r/1315/

Sijia Chen committed 11 years ago

Commit ade32f51 parent a3f606e2 files · +24 −1Browse files

Showing the changes to codec/common/src/WelsThreadLib.cpp (1 of 2 files). Show all

Unified · Split

codec/common/src/WelsThreadLib.cpp+23−1
@@ -71,6 +71,7 @@ · 70 unmodified lines
7171
7272 #ifdef WINAPI_FAMILY
7373 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
74+#define WP80
7475 using namespace Platform;
7576 using namespace Windows::Foundation;
7677 using namespace Windows::System::Threading;
@@ -174,9 +175,30 @@ WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_n · 97 unmodified lines
174175 return WELS_THREAD_ERROR_OK;
175176 }
176177
178+#ifndef WP80
177179 void WelsSleep (uint32_t dwMilliSecond) {
178180 ::Sleep (dwMilliSecond);
179181 }
182+#else
183+void WelsSleep (uint32_t dwMilliSecond) {
184+ static WELS_EVENT hSleepEvent = NULL;
185+ if (!hSleepEvent) {
186+ WELS_EVENT hLocalSleepEvent = NULL;
187+ WELS_THREAD_ERROR_CODE ret = WelsEventOpen (&hLocalSleepEvent);
188+ if (WELS_THREAD_ERROR_OK != ret) {
189+ return;
190+ }
191+ WELS_EVENT hPreviousEvent = InterlockedCompareExchangePointerRelease (&hSleepEvent, hLocalSleepEvent, NULL);
192+ if (hPreviousEvent) {
193+ WelsEventClose (&hLocalSleepEvent);
194+ }
195+ //On this singleton usage idea of using InterlockedCompareExchangePointerRelease:
196+ // similar idea of can be found at msdn blog when introducing InterlockedCompareExchangePointerRelease
197+ }
198+
199+ WaitForSingleObject (hSleepEvent, dwMilliSecond);
200+}
201+#endif
180202
181203 WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
182204 void* arg, WELS_THREAD_ATTR attr) {
@@ -229,7 +251,7 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p · 46 unmodified lines
229251 return WELS_THREAD_ERROR_OK;
230252 }
231253
232−#else
254+#else //platform: #ifdef _WIN32
233255
234256 WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
235257 void* arg, WELS_THREAD_ATTR attr) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t