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.)
This commit is contained in:
parent
c7d98a8fa3
commit
e0951599ea
@ -184,7 +184,7 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p
|
||||
return WELS_THREAD_ERROR_OK;
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
#else
|
||||
|
||||
void WelsSleep (uint32_t dwMilliseconds) {
|
||||
usleep (dwMilliseconds * 1000); // microseconds
|
||||
|
@ -62,8 +62,6 @@ typedef HANDLE WELS_EVENT;
|
||||
|
||||
#else // NON-WINDOWS
|
||||
|
||||
#if defined(__GNUC__) // LINUX, MACOS etc
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
@ -86,8 +84,6 @@ typedef sem_t WELS_EVENT;
|
||||
#define WELS_THREAD_ROUTINE_TYPE void *
|
||||
#define WELS_THREAD_ROUTINE_RETURN(rc) return (void*)(intptr_t)rc;
|
||||
|
||||
#endif//__GNUC__
|
||||
|
||||
#endif//_WIN32
|
||||
|
||||
typedef int32_t WELS_THREAD_ERROR_CODE;
|
||||
@ -109,10 +105,10 @@ WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex);
|
||||
WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex);
|
||||
WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifndef _WIN32
|
||||
WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT** p_event, const char* event_name);
|
||||
WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name);
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
WELS_THREAD_ERROR_CODE WelsEventInit (WELS_EVENT* event);
|
||||
WELS_THREAD_ERROR_CODE WelsEventDestroy (WELS_EVENT* event);
|
||||
WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event);
|
||||
|
@ -102,9 +102,9 @@ WELS_EVENT* pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded stat
|
||||
WELS_EVENT* pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx]
|
||||
#endif//_WIN32
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if !defined(_WIN32)
|
||||
WELS_THREAD_HANDLE* pUpdateMbListThrdHandles; // thread handles for update mb list thread, [iThreadIdx]
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
#ifdef _WIN32
|
||||
WELS_EVENT* pUpdateMbListEvent; // signal to update mb list neighbor for various slices
|
||||
WELS_EVENT* pFinUpdateMbListEvent; // signal to indicate finish updating mb list
|
||||
|
@ -75,9 +75,9 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx);
|
||||
int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t kiSliceCount);
|
||||
int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, int32_t& iSliceSize);
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if !defined(_WIN32)
|
||||
WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg);
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
|
||||
WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg);
|
||||
|
||||
|
@ -2171,7 +2171,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
|
||||
WelsMultipleEventsWaitAllBlocking (iThreadCount, & (*ppCtx)->pSliceThreading->pFinSliceCodingEvent[0]);
|
||||
|
||||
}
|
||||
#elif defined(__GNUC__)
|
||||
#else
|
||||
while (iThreadIdx < iThreadCount) {
|
||||
int res = 0;
|
||||
if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) {
|
||||
@ -3300,7 +3300,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou
|
||||
} else {
|
||||
WelsSleep (1);
|
||||
}
|
||||
#else//__GNUC__
|
||||
#else
|
||||
// TODO for pthread platforms
|
||||
// alternate implementation using blocking due non-blocking with timeout mode not support at wels thread lib, tune back if available
|
||||
WelsMultipleEventsWaitAllBlocking (iNumThreadsRunning, &pCtx->pSliceThreading->pSliceCodedEvent[0]);
|
||||
|
@ -41,13 +41,13 @@
|
||||
#if defined(MT_ENABLED)
|
||||
|
||||
#include <assert.h>
|
||||
#if defined(__GNUC__) && !defined(_WIN32)
|
||||
#if !defined(_WIN32)
|
||||
#include <semaphore.h>
|
||||
#ifndef SEM_NAME_MAX
|
||||
// length of semaphore name should be system constrained at least on mac 10.7
|
||||
#define SEM_NAME_MAX 32
|
||||
#endif//SEM_NAME_MAX
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
#include "slice_multi_threading.h"
|
||||
#include "mt_defs.h"
|
||||
#include "nal_encap.h"
|
||||
@ -332,13 +332,11 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pReadySliceCodingEvent), FreeMemorySvc (ppCtx))
|
||||
pSmt->pFinSliceCodingEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinSliceCodingEvent");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx))
|
||||
#endif//_WIN32
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#else
|
||||
pSmt->pUpdateMbListThrdHandles = (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,
|
||||
"pUpdateMbListThrdHandles");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListThrdHandles), FreeMemorySvc (ppCtx))
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
#ifdef _WIN32
|
||||
pSmt->pUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pUpdateMbListEvent");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pUpdateMbListEvent), FreeMemorySvc (ppCtx))
|
||||
@ -386,10 +384,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
|
||||
iIdx = 0;
|
||||
while (iIdx < iThreadNum) {
|
||||
#if defined(__GNUC__) && !defined(_WIN32) // for posix threading
|
||||
#if !defined(_WIN32) // for posix threading
|
||||
char name[SEM_NAME_MAX] = {0};
|
||||
WELS_THREAD_ERROR_CODE err = 0;
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) (*ppCtx);
|
||||
pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx;
|
||||
pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx;
|
||||
@ -767,7 +765,7 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && !defined(_WIN32)
|
||||
#if !defined(_WIN32)
|
||||
WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) {
|
||||
SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
|
||||
sWelsEncCtx* pEncPEncCtx = NULL;
|
||||
@ -806,7 +804,7 @@ WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) {
|
||||
|
||||
WELS_THREAD_ROUTINE_RETURN (uiThrdRet);
|
||||
}
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
|
||||
// thread process for coding one pSlice
|
||||
WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
@ -1148,10 +1146,10 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) {
|
||||
// We need extra threads for update_mb_list_proc on __GNUC__ like OS (mac/linux)
|
||||
// due to WelsMultipleEventsWaitSingleBlocking implememtation can not work well
|
||||
// in case waiting pUpdateMbListEvent and pReadySliceCodingEvent events at the same time
|
||||
#if defined(__GNUC__) && !defined(_WIN32)
|
||||
#if !defined(_WIN32)
|
||||
WelsThreadCreate (&pCtx->pSliceThreading->pUpdateMbListThrdHandles[iIdx], UpdateMbListThreadProc,
|
||||
&pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0);
|
||||
#endif//__GNUC__
|
||||
#endif//!_WIN32
|
||||
|
||||
++ iIdx;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user