The two different variants of the threadlib basically are win32 and unix - use _WIN32 to check for this consistently, instead of occasionally using __GNUC__ to enable the unix codepath. (__GNUC__ is also defined on mingw, which still is a windows platform and should use the _WIN32 code.)
Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 6 files). Show all
Unified · Split
| @@ -41,13 +41,13 @@ · 40 unmodified lines | ||
| 41 | 41 | #if defined(MT_ENABLED) |
| 42 | 42 | |
| 43 | 43 | #include <assert.h> |
| 44 | −#if defined(__GNUC__) && !defined(_WIN32) | |
| 44 | +#if !defined(_WIN32) | |
| 45 | 45 | #include <semaphore.h> |
| 46 | 46 | #ifndef SEM_NAME_MAX |
| 47 | 47 | // length of semaphore name should be system constrained at least on mac 10.7 |
| 48 | 48 | #define SEM_NAME_MAX 32 |
| 49 | 49 | #endif//SEM_NAME_MAX |
| 50 | −#endif//__GNUC__ | |
| 50 | +#endif//!_WIN32 | |
| 51 | 51 | #include "slice_multi_threading.h" |
| 52 | 52 | #include "mt_defs.h" |
| 53 | 53 | #include "nal_encap.h" |
| @@ -332,13 +332,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 278 unmodified lines | ||
| 332 | 332 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pReadySliceCodingEvent), FreeMemorySvc (ppCtx)) |
| 333 | 333 | pSmt->pFinSliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent"); |
| 334 | 334 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx)) |
| 335 | −#endif//_WIN32 | |
| 336 | − | |
| 337 | −#if defined(__GNUC__) | |
| 335 | +#else | |
| 338 | 336 | pSmt->pUpdateMbListThrdHandles = (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum, |
| 339 | 337 | "pUpdateMbListThrdHandles"); |
| 340 | 338 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListThrdHandles), FreeMemorySvc (ppCtx)) |
| 341 | −#endif//__GNUC__ | |
| 339 | +#endif//!_WIN32 | |
| 342 | 340 | #ifdef _WIN32 |
| 343 | 341 | pSmt->pUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pUpdateMbListEvent"); |
| 344 | 342 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListEvent), FreeMemorySvc (ppCtx)) |
| @@ -386,10 +384,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 41 unmodified lines | ||
| 386 | 384 | |
| 387 | 385 | iIdx = 0; |
| 388 | 386 | while (iIdx < iThreadNum) { |
| 389 | −#if defined(__GNUC__) && !defined(_WIN32) // for posix threading | |
| 387 | +#if !defined(_WIN32) // for posix threading | |
| 390 | 388 | char name[SEM_NAME_MAX] = {0}; |
| 391 | 389 | WELS_THREAD_ERROR_CODE err = 0; |
| 392 | −#endif//__GNUC__ | |
| 390 | +#endif//!_WIN32 | |
| 393 | 391 | pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) (*ppCtx); |
| 394 | 392 | pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx; |
| 395 | 393 | pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; |
| @@ -767,7 +765,7 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl · 371 unmodified lines | ||
| 767 | 765 | return iReturn; |
| 768 | 766 | } |
| 769 | 767 | |
| 770 | −#if defined(__GNUC__) && !defined(_WIN32) | |
| 768 | +#if !defined(_WIN32) | |
| 771 | 769 | WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) { |
| 772 | 770 | SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg; |
| 773 | 771 | sWelsEncCtx* pEncPEncCtx = NULL; |
| @@ -806,7 +804,7 @@ WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) { · 32 unmodified lines | ||
| 806 | 804 | |
| 807 | 805 | WELS_THREAD_ROUTINE_RETURN (uiThrdRet); |
| 808 | 806 | } |
| 809 | −#endif//__GNUC__ | |
| 807 | +#endif//!_WIN32 | |
| 810 | 808 | |
| 811 | 809 | // thread process for coding one pSlice |
| 812 | 810 | WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { |
| @@ -1148,10 +1146,10 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 335 unmodified lines | ||
| 1148 | 1146 | // We need extra threads for update_mb_list_proc on __GNUC__ like OS (mac/linux) |
| 1149 | 1147 | // due to WelsMultipleEventsWaitSingleBlocking implememtation can not work well |
| 1150 | 1148 | // in case waiting pUpdateMbListEvent and pReadySliceCodingEvent events at the same time |
| 1151 | −#if defined(__GNUC__) && !defined(_WIN32) | |
| 1149 | +#if !defined(_WIN32) | |
| 1152 | 1150 | WelsThreadCreate (&pCtx->pSliceThreading->pUpdateMbListThrdHandles[iIdx], UpdateMbListThreadProc, |
| 1153 | 1151 | &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0); |
| 1154 | −#endif//__GNUC__ | |
| 1152 | +#endif//!_WIN32 | |
| 1155 | 1153 | |
| 1156 | 1154 | ++ iIdx; |
| 1157 | 1155 | } |