Go to the documentation of this file.
31 #include <android/log.h>
36 #define AK_THREAD_INIT_CODE(_threadProperties) syscall(__NR_sched_setaffinity, 0, sizeof(_threadProperties.dwAffinityMask), &_threadProperties.dwAffinityMask)
37 #define AK_SEC_TO_NANOSEC 1000000000ULL
44 struct timespec clockNow;
45 clock_gettime(CLOCK_MONOTONIC, &clockNow);
58 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
61 #define AkAlloca( _size_ ) __builtin_alloca( _size_ )
67 #if defined(AK_OPTIMIZED)
70 template <
int MaxSize = 0>
77 __android_log_print(ANDROID_LOG_INFO,
"AKDEBUG",
"%s", in_pszMsg);
81 template <
int MaxSize = 0>
85 va_start(args, in_pszFmt);
86 __android_log_vprint(ANDROID_LOG_INFO,
"AKDEBUG", in_pszFmt, args);
91 template<
class destType,
class srcType>
92 inline size_t AkSimpleConvertString( destType* in_pdDest,
const srcType* in_pSrc,
size_t in_MaxSize,
size_t destStrLen(
const destType *),
size_t srcStrLen(
const srcType *) )
95 size_t lenToCopy = srcStrLen(in_pSrc);
97 lenToCopy = (lenToCopy > in_MaxSize-1) ? in_MaxSize-1 : lenToCopy;
98 for(i = 0; i < lenToCopy; i++)
100 in_pdDest[i] = (destType) in_pSrc[i];
102 in_pdDest[lenToCopy] = (destType)0;
107 #define CONVERT_UTF16_TO_CHAR( _astring_, _charstring_ ) \
108 _charstring_ = (char*)AkAlloca( (1 + AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)) * sizeof(char) ); \
109 AK_UTF16_TO_CHAR( _charstring_, (const AkUtf16*)_astring_, AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)+1 )
111 #define AK_UTF8_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, strlen )
112 #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
113 #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
114 #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen)
115 #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen)
117 #if __BIGGEST_ALIGNMENT__ < AK_SIMD_ALIGNMENT
118 #define AkAllocaSIMD( _size_ ) __builtin_alloca_with_align( _size_, AK_SIMD_ALIGNMENT*8 )
134 AKVERIFY(!pthread_attr_init(&attr));
138 AKVERIFY(!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));
141 int threadError = pthread_create( out_pThread, &attr, pStartRoutine, pParams);
143 AKVERIFY(!pthread_attr_destroy(&attr));
145 if( threadError != 0 )
162 int minPriority, maxPriority;
163 minPriority = sched_get_priority_min(sched_policy);
164 maxPriority = sched_get_priority_max(sched_policy);
167 sched_param schedParam;
168 schedParam.sched_priority = in_threadProperties.
nPriority;
172 int err = pthread_setschedparam(*out_pThread, sched_policy, &schedParam);
176 sched_policy = SCHED_NORMAL;
177 minPriority = sched_get_priority_min(sched_policy);
178 maxPriority = sched_get_priority_max(sched_policy);
180 schedParam.sched_priority = maxPriority;
182 schedParam.sched_priority = minPriority;
184 schedParam.sched_priority = (maxPriority + minPriority) / 2;
185 err = pthread_setschedparam(*out_pThread, sched_policy, &schedParam);
190 #define AK_FILEHANDLE_TO_UINTPTR(_h) ((AkUIntPtr)_h)
191 #define AK_SET_FILEHANDLE_TO_UINTPTR(_h,_u) _h = (AkFileHandle)_u
int nPriority
Thread priority.
Platform-dependent helpers.
void OutputDebugMsg(const char *in_pszMsg)
Output a debug message on the console (Ansi string)
void AkCreateThread(AkThreadRoutine pStartRoutine, void *pParams, const AkThreadProperties &in_threadProperties, AkThread *out_pThread, const char *)
Platform Independent Helper.
void OutputDebugMsgV(const char *in_pszFmt,...)
Output a debug message on the console (variadic function).
void PerformanceCounter(AkInt64 *out_piLastTime)
Platform Independent Helper.
#define AKASSERT(Condition)
AkForceInline void AkClearThread(AkThread *in_pThread)
Platform Independent Helper.
int64_t AkInt64
Signed 64-bit integer.
size_t uStackSize
Thread stack size.
void PerformanceFrequency(AkInt64 *out_piFreq)
Platform Independent Helper.
int uSchedPolicy
Thread scheduling policy.
size_t AkSimpleConvertString(destType *in_pdDest, const srcType *in_pSrc, size_t in_MaxSize, size_t destStrLen(const destType *), size_t srcStrLen(const srcType *))
Tell us about your project. We're here to help.
Register your project and we'll help you get started with no strings attached!
Get started with Wwise