History

Unify ifdef conditions related to threading code

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.)

Martin Storsjö committed 12 years ago

Commit e0951591 parent c7d98a86 files · +19 −25Browse files

Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 6 files). Show all

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+10−12
@@ -41,13 +41,13 @@ · 40 unmodified lines
41#if defined(MT_ENABLED)41#if defined(MT_ENABLED)
42 42
43#include <assert.h>43#include <assert.h>
44#if defined(__GNUC__) && !defined(_WIN32)44#if !defined(_WIN32)
45#include <semaphore.h>45#include <semaphore.h>
46#ifndef SEM_NAME_MAX46#ifndef SEM_NAME_MAX
47// length of semaphore name should be system constrained at least on mac 10.747// length of semaphore name should be system constrained at least on mac 10.7
48#define SEM_NAME_MAX 3248#define SEM_NAME_MAX 32
49#endif//SEM_NAME_MAX49#endif//SEM_NAME_MAX
50#endif//__GNUC__50#endif//!_WIN32
51#include "slice_multi_threading.h"51#include "slice_multi_threading.h"
52#include "mt_defs.h"52#include "mt_defs.h"
53#include "nal_encap.h"53#include "nal_encap.h"
@@ -332,13 +332,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 278 unmodified lines
332 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pReadySliceCodingEvent), FreeMemorySvc (ppCtx))332 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pReadySliceCodingEvent), FreeMemorySvc (ppCtx))
333 pSmt->pFinSliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent");333 pSmt->pFinSliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent");
334 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx))334 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx))
335#endif//_WIN32335#else
336
337#if defined(__GNUC__)
338 pSmt->pUpdateMbListThrdHandles = (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,336 pSmt->pUpdateMbListThrdHandles = (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,
339 "pUpdateMbListThrdHandles");337 "pUpdateMbListThrdHandles");
340 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListThrdHandles), FreeMemorySvc (ppCtx))338 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListThrdHandles), FreeMemorySvc (ppCtx))
341#endif//__GNUC__339#endif//!_WIN32
342#ifdef _WIN32340#ifdef _WIN32
343 pSmt->pUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pUpdateMbListEvent");341 pSmt->pUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pUpdateMbListEvent");
344 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListEvent), FreeMemorySvc (ppCtx))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 iIdx = 0;385 iIdx = 0;
388 while (iIdx < iThreadNum) {386 while (iIdx < iThreadNum) {
389#if defined(__GNUC__) && !defined(_WIN32) // for posix threading387#if !defined(_WIN32) // for posix threading
390 char name[SEM_NAME_MAX] = {0};388 char name[SEM_NAME_MAX] = {0};
391 WELS_THREAD_ERROR_CODE err = 0;389 WELS_THREAD_ERROR_CODE err = 0;
392#endif//__GNUC__390#endif//!_WIN32
393 pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) (*ppCtx);391 pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) (*ppCtx);
394 pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx;392 pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx;
395 pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx;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 return iReturn;765 return iReturn;
768}766}
769 767
770#if defined(__GNUC__) && !defined(_WIN32)768#if !defined(_WIN32)
771WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) {769WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) {
772 SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;770 SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
773 sWelsEncCtx* pEncPEncCtx = NULL;771 sWelsEncCtx* pEncPEncCtx = NULL;
@@ -806,7 +804,7 @@ WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) { · 32 unmodified lines
806 804
807 WELS_THREAD_ROUTINE_RETURN (uiThrdRet);805 WELS_THREAD_ROUTINE_RETURN (uiThrdRet);
808}806}
809#endif//__GNUC__807#endif//!_WIN32
810 808
811// thread process for coding one pSlice809// thread process for coding one pSlice
812WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {810WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
@@ -1148,10 +1146,10 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 335 unmodified lines
1148 // We need extra threads for update_mb_list_proc on __GNUC__ like OS (mac/linux)1146 // We need extra threads for update_mb_list_proc on __GNUC__ like OS (mac/linux)
1149 // due to WelsMultipleEventsWaitSingleBlocking implememtation can not work well1147 // due to WelsMultipleEventsWaitSingleBlocking implememtation can not work well
1150 // in case waiting pUpdateMbListEvent and pReadySliceCodingEvent events at the same time1148 // in case waiting pUpdateMbListEvent and pReadySliceCodingEvent events at the same time
1151#if defined(__GNUC__) && !defined(_WIN32)1149#if !defined(_WIN32)
1152 WelsThreadCreate (&pCtx->pSliceThreading->pUpdateMbListThrdHandles[iIdx], UpdateMbListThreadProc,1150 WelsThreadCreate (&pCtx->pSliceThreading->pUpdateMbListThrdHandles[iIdx], UpdateMbListThreadProc,
1153 &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0);1151 &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0);
1154#endif//__GNUC__1152#endif//!_WIN32
1155 1153
1156 ++ iIdx;1154 ++ iIdx;
1157 }1155 }

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