Table of Contents

Wwise SDK 2019.1.7
AkPlatformFuncs.h
Go to the documentation of this file.
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12 Apache License Usage
13 
14 Alternatively, this file may be used under the Apache License, Version 2.0 (the
15 "Apache License"); you may not use this file except in compliance with the
16 Apache License. You may obtain a copy of the Apache License at
17 http://www.apache.org/licenses/LICENSE-2.0.
18 
19 Unless required by applicable law or agreed to in writing, software distributed
20 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
21 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
22 the specific language governing permissions and limitations under the License.
23 
24  Version: <VERSION> Build: <BUILDNUMBER>
25  Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
26 *******************************************************************************/
27 //////////////////////////////////////////////////////////////////////
28 //
29 // AkPlatformFuncs.h
30 //
31 // Audiokinetic platform-dependent functions definition.
32 //
33 //
34 //////////////////////////////////////////////////////////////////////
35 
36 #pragma once
37 
40 
41 #include <nn/os.h>
42 
43 #include <time.h>
44 #include <stdlib.h>
45 #include <stdio.h>
46 #include <string.h>
47 #include <wchar.h>
48 
49 #define AkMax(x1, x2) (((x1) > (x2))? (x1): (x2))
50 #define AkMin(x1, x2) (((x1) < (x2))? (x1): (x2))
51 #define AkClamp(x, min, max) ((x) < (min)) ? (min) : (((x) > (max) ? (max) : (x)))
52 
53 //-----------------------------------------------------------------------------
54 // Platform-specific thread properties definition.
55 //-----------------------------------------------------------------------------
56 struct AkThreadProperties
57 {
58  AkInt32 nPriority; ///< Thread priority. 0=highest, 31=lowest.
59  size_t uStackSize; ///< Thread stack size.
60  int iIdealCore; ///< Preferred core number: see nn::os::SetThreadCoreMask documentation.
61  nn::Bit64 affinityMask; ///< Affinity mask for each core: see nn::os::SetThreadCoreMask documentation.
62 };
63 
64 //-----------------------------------------------------------------------------
65 // External variables.
66 //-----------------------------------------------------------------------------
67 // g_fFreqRatio is used by time helpers to return time values in milliseconds.
68 // It is declared and updated by the sound engine.
69 namespace AK
70 {
72 }
73 
74 #define AK_DECLARE_THREAD_ROUTINE( FuncName ) void FuncName(void* lpParameter)
75 #define AK_THREAD_RETURN( _param_ ) return // (_param_)
76 #define AK_THREAD_ROUTINE_PARAMETER lpParameter
77 #define AK_GET_THREAD_ROUTINE_PARAMETER_PTR(type) reinterpret_cast<type*>( AK_THREAD_ROUTINE_PARAMETER )
78 
79 #define AK_NULL_THREAD nullptr
80 
81 #define AK_THREAD_PRIORITY_NORMAL (nn::os::DefaultThreadPriority)
82 #define AK_THREAD_PRIORITY_ABOVE_NORMAL (nn::os::DefaultThreadPriority-1)
83 #define AK_DEFAULT_STACK_SIZE (128*1024)
84 
85 #define AK_INFINITE (-1)
86 
87 namespace AKPLATFORM
88 {
89  // Thread blocking API
90  // ------------------------------------------------------------------
91 
92  /// Platform Independent Helper
93  AkForceInline void AkClearEvent(AkEvent &out_event)
94  {
95  memset(&out_event, 0, sizeof(out_event));
96  }
97 
98  /// Platform Independent Helper
100  {
101  nn::os::InitializeEvent(&out_event, false, nn::os::EventClearMode_AutoClear);
102  return AK_Success;
103  }
104 
105  /// Platform Independent Helper
106  AkForceInline void AkDestroyEvent(AkEvent & io_event)
107  {
108  if (io_event._state == nn::os::EventType::State_Initialized)
109  nn::os::FinalizeEvent(&io_event);
110  }
111 
112  /// Platform Independent Helper
113  AkForceInline void AkWaitForEvent(AkEvent & in_event)
114  {
115  AKASSERT(in_event._state == nn::os::EventType::State_Initialized);
116  nn::os::WaitEvent(&in_event);
117  }
118 
119  /// Platform Independent Helper
121  {
122  AKASSERT(in_event._state == nn::os::EventType::State_Initialized);
123  nn::os::SignalEvent(&in_event);
124  }
125 
126  // Atomic Operations
127  // ------------------------------------------------------------------
128 
129  /// Platform Independent Helper
130  inline AkInt32 AkInterlockedIncrement(volatile AkInt32 * pValue)
131  {
132  return __sync_add_and_fetch(pValue,1);
133  }
134 
135  /// Platform Independent Helper
136  inline AkInt32 AkInterlockedDecrement(volatile AkInt32 * pValue)
137  {
138  return __sync_sub_and_fetch(pValue,1);
139  }
140 
141  AkForceInline bool AkInterlockedCompareExchange( volatile AkInt32* io_pDest, AkInt32 in_newValue, AkInt32 in_expectedOldVal )
142  {
143  return __sync_bool_compare_and_swap(io_pDest, in_expectedOldVal, in_newValue);
144  }
145 
146  AkForceInline bool AkInterlockedCompareExchange( volatile AkInt64* io_pDest, AkInt64 in_newValue, AkInt64 in_expectedOldVal )
147  {
148  return __sync_bool_compare_and_swap(io_pDest, in_expectedOldVal, in_newValue);
149  }
150 
151  inline void AkMemoryBarrier()
152  {
153  __sync_synchronize();
154  }
155 
156  // Threads
157  // ------------------------------------------------------------------
158 
159  /// Platform Independent Helper
160  AkForceInline bool AkIsValidThread(AkThread * in_pThread)
161  {
162  return in_pThread->thread._state != nn::os::ThreadType::State_NotInitialized;
163  }
164 
165  /// Platform Independent Helper
166  AkForceInline void AkClearThread(AkThread * in_pThread)
167  {
168  in_pThread->thread._state = nn::os::ThreadType::State_NotInitialized;
169  }
170 
171  /// Platform Independent Helper
172  AkForceInline void AkCloseThread(AkThread * in_pThread)
173  {
174  nn::os::DestroyThread(&in_pThread->thread);
175  AK::AlignedFreeHook((void *)in_pThread->pStackAlloc);
176  in_pThread->pStackAlloc = nullptr;
177  }
178 
179 #define AkExitThread( _result ) return
180 
181  /// Platform Independent Helper
183  {
184  out_threadProperties.nPriority = AK_THREAD_PRIORITY_NORMAL;
185  out_threadProperties.uStackSize = AK_DEFAULT_STACK_SIZE;
186  out_threadProperties.iIdealCore = nn::os::IdealCoreUseDefaultValue;
187  out_threadProperties.affinityMask = 0; // ignored when iIdealCore == nn::os::IdealCoreUseDefaultValue
188  }
189 
190  /// Platform Independent Helper
192  AkThreadRoutine pStartRoutine, // Thread routine.
193  void * in_pParams, // Routine params.
194  const AkThreadProperties & in_threadProperties, // Properties.
195  AkThread * out_pThread, // Returned thread handle.
196  const char * in_szThreadName) // Opt thread name.
197  {
198  AKASSERT(out_pThread != NULL);
199  AKASSERT(in_threadProperties.uStackSize > 0);
200  AKASSERT(in_threadProperties.nPriority >= nn::os::HighestThreadPriority && in_threadProperties.nPriority <= nn::os::LowestThreadPriority);
201 
202  out_pThread->pStackAlloc = (AkUInt8 *)AK::AlignedAllocHook(in_threadProperties.uStackSize, nn::os::ThreadStackAlignment);
203  if (!out_pThread->pStackAlloc)
204  return;
205 
206  out_pThread->uStackSize = in_threadProperties.uStackSize;
207 
208  nn::Result result;
209 
210  result = nn::os::CreateThread(&out_pThread->thread, pStartRoutine, in_pParams, out_pThread->pStackAlloc, out_pThread->uStackSize, in_threadProperties.nPriority);
211  if (!result.IsSuccess())
212  {
213  AK::AlignedFreeHook((void *)out_pThread->pStackAlloc);
214  out_pThread->pStackAlloc = nullptr;
215  return;
216  }
217 
218  if (in_szThreadName)
219  {
220  nn::os::SetThreadName(&out_pThread->thread, in_szThreadName);
221  }
222 
223  nn::os::SetThreadCoreMask(&out_pThread->thread, in_threadProperties.iIdealCore, in_threadProperties.affinityMask);
224 
225  nn::os::StartThread(&out_pThread->thread);
226  }
227 
228  /// Platform Independent Helper
229  AkForceInline void AkWaitForSingleThread(AkThread * in_pThread)
230  {
231  nn::os::WaitThread(&in_pThread->thread);
232  }
233 
235  {
236  return nn::os::GetCurrentThread();
237  }
238 
239  /// Platform Independent Helper
240  AkForceInline void AkSleep(AkUInt32 in_ulMilliseconds)
241  {
242  nn::os::SleepThread(nn::TimeSpan::FromMilliSeconds(in_ulMilliseconds));
243  }
244 
245  // Optimized memory functions
246  // --------------------------------------------------------------------
247  /// Platform Independent Helper
248  AkForceInline void AkMemCpy( void * pDest, const void * pSrc, AkUInt32 uSize )
249  {
250  memcpy( pDest, pSrc, uSize );
251  }
252 
253  /// Platform Independent Helper
254  AkForceInline void AkMemSet( void * pDest, AkInt32 iVal, AkUInt32 uSize )
255  {
256  memset( pDest, iVal, uSize );
257  }
258 
259  // Time functions
260  // ------------------------------------------------------------------
261 
262  /// Platform Independent Helper
263  inline void PerformanceCounter( AkInt64 * out_piLastTime )
264  {
265  *out_piLastTime = nn::os::GetSystemTick().GetInt64Value();
266  }
267 
268  /// Platform Independent Helper
269  inline void PerformanceFrequency( AkInt64 * out_piFreq )
270  {
271  *out_piFreq = nn::os::GetSystemTickFrequency();
272  }
273 
274  /// Platform Independent Helper
275  inline void UpdatePerformanceFrequency()
276  {
277  AkInt64 iFreq;
278  PerformanceFrequency(&iFreq);
279  AK::g_fFreqRatio = (AkReal32)((AkReal64)iFreq / 1000);
280  }
281 
282  /// Platform Independent Helper
283  /// Returns a time range in milliseconds, using the sound engine's updated count->milliseconds ratio.
284  inline AkReal32 Elapsed( const AkInt64 & in_iNow, const AkInt64 & in_iStart )
285  {
286  return ( in_iNow - in_iStart ) / AK::g_fFreqRatio;
287  }
288 
289  template<class destType, class srcType>
290  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 *) )
291  {
292  size_t i;
293  size_t lenToCopy = srcStrLen(in_pSrc);
294 
295  lenToCopy = (lenToCopy > in_MaxSize-1) ? in_MaxSize-1 : lenToCopy;
296  for(i = 0; i < lenToCopy; i++)
297  {
298  in_pdDest[i] = (destType) in_pSrc[i];
299  }
300  in_pdDest[lenToCopy] = (destType)0;
301 
302  return lenToCopy;
303  }
304 
305  /// Get the length, in characters, of a NULL-terminated AkUtf16 string
306  /// \return The length, in characters, of the specified string (excluding terminating NULL)
307  inline size_t AkUtf16StrLen(const AkUtf16* in_pStr)
308  {
309  size_t len = 0;
310  while (*in_pStr != 0)
311  {
312  in_pStr++;
313  len++;
314  }
315  return len;
316  }
317 
318  /// Get the length, in characters, of a NULL-terminated AkOSChar string
319  /// \return The length, in characters, of the specified string (excluding terminating NULL)
320  AkForceInline size_t OsStrLen(const AkOSChar* in_pszString)
321  {
322  return (strlen(in_pszString));
323  }
324 
325  /// AkOSChar version of snprintf().
326  #define AK_OSPRINTF snprintf
327 
328 #define CONVERT_UTF16_TO_CHAR(_astring_, _charstring_) \
329  _charstring_ = (char*)AkAlloca( (1 + AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)) * sizeof(char) ); \
330  AK_UTF16_TO_CHAR( _charstring_, (const AkUtf16*)_astring_, AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)+1 )
331 
332  #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
333  #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
334  #define AK_UTF16_TO_WCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, wcslen, AKPLATFORM::AkUtf16StrLen )
335  #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen )
336  #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen )
337  #define AK_WCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, wcslen )
338 
339  // Use with AkOSChar.
340  #define AK_PATH_SEPARATOR ("/")
341 
342  inline int OsStrCmp(const AkOSChar* in_pszString1, const AkOSChar* in_pszString2)
343  {
344  return (strcmp(in_pszString1, in_pszString2));
345  }
346 
347  /// Compare two NULL-terminated AkOSChar strings up to the specified count of characters.
348  /// \return
349  /// - < 0 if in_pszString1 < in_pszString2
350  /// - 0 if the two strings are identical
351  /// - > 0 if in_pszString1 > in_pszString2
352  /// \remark The comparison is case-sensitive
353  inline int OsStrNCmp(const AkOSChar* in_pszString1, const AkOSChar* in_pszString2, size_t in_MaxCountSize)
354  {
355  return (strncmp(in_pszString1, in_pszString2, in_MaxCountSize));
356  }
357 
358  /// String conversion helper
359  inline AkInt32 AkWideCharToChar(const wchar_t* in_pszUnicodeString,
360  AkUInt32 in_uiOutBufferSize,
361  char* io_pszAnsiString)
362  {
363  AKASSERT(io_pszAnsiString != NULL);
364 
365  mbstate_t state;
366  memset(&state, '\0', sizeof(state));
367 
368  return wcsrtombs(io_pszAnsiString, // destination
369  &in_pszUnicodeString, // source
370  in_uiOutBufferSize, // destination length
371  &state); //
372 
373  }
374 
375  /// String conversion helper
376  inline AkInt32 AkCharToWideChar(const char* in_pszAnsiString,
377  AkUInt32 in_uiOutBufferSize,
378  void* io_pvUnicodeStringBuffer)
379  {
380  AKASSERT(io_pvUnicodeStringBuffer != NULL);
381 
382  mbstate_t state;
383  memset(&state, '\0', sizeof(state));
384 
385  return mbsrtowcs((wchar_t*)io_pvUnicodeStringBuffer, // destination
386  &in_pszAnsiString, // source
387  in_uiOutBufferSize, // destination length
388  &state); //
389  }
390 
391  inline AkInt32 AkUtf8ToWideChar(const char* in_pszUtf8String,
392  AkUInt32 in_uiOutBufferSize,
393  void* io_pvUnicodeStringBuffer)
394  {
395  return AkCharToWideChar(in_pszUtf8String, in_uiOutBufferSize, io_pvUnicodeStringBuffer);
396  }
397 
398  /// Safe unicode string copy.
399  inline void SafeStrCpy(wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars)
400  {
401  size_t iSizeCopy = AkMin(in_uDestMaxNumChars - 1, wcslen(in_pSrc) + 1);
402  wcsncpy(in_pDest, in_pSrc, iSizeCopy);
403  in_pDest[iSizeCopy] = '\0';
404  }
405 
406  /// Safe ansi string copy.
407  inline void SafeStrCpy(char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars)
408  {
409  size_t iSizeCopy = AkMin(in_uDestMaxNumChars - 1, strlen(in_pSrc) + 1);
410  strncpy(in_pDest, in_pSrc, iSizeCopy);
411  in_pDest[iSizeCopy] = '\0';
412  }
413 
414  /// Safe unicode string concatenation.
415  inline void SafeStrCat(wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars)
416  {
417  size_t iAvailableSize = (int)(in_uDestMaxNumChars - wcslen(in_pDest) - 1);
418  wcsncat(in_pDest, in_pSrc, AkMin(iAvailableSize, (int)wcslen(in_pSrc)));
419  }
420 
421  /// Safe ansi string concatenation.
422  inline void SafeStrCat(char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars)
423  {
424  size_t iAvailableSize = (int)(in_uDestMaxNumChars - strlen(in_pDest) - 1);
425  strncat(in_pDest, in_pSrc, AkMin(iAvailableSize, (int)strlen(in_pSrc)));
426  }
427 
428  /// Stack allocations.
429  #define AkAlloca( _size_ ) __builtin_alloca( _size_ )
430 
431 #if __BIGGEST_ALIGNMENT__ < AK_SIMD_ALIGNMENT
432 #define AkAllocaSIMD( _size_ ) __builtin_alloca_with_align( _size_, AK_SIMD_ALIGNMENT*8 )
433 #endif
434 
435 #ifndef AK_OPTIMIZED
436  /// Output a debug message on the console (Unicode string)
437  inline void OutputDebugMsg(const wchar_t* in_pszMsg)
438  {
439  char szMsg[256];
440  AkWideCharToChar(in_pszMsg, 256, szMsg);
441  printf("%s", szMsg);
442  }
443  /// Output a debug message on the console (Ansi string)
444  inline void OutputDebugMsg(const char* in_pszMsg)
445  {
446  printf("%s", in_pszMsg);
447  }
448 #else
449  inline void OutputDebugMsg(const wchar_t*){}
450  inline void OutputDebugMsg(const char*){}
451 #endif
452 
453  /// Converts a wchar_t string to an AkOSChar string.
454  /// \remark On some platforms the AkOSChar string simply points to the same string,
455  /// on others a new buffer is allocated on the stack using AkAlloca. This means
456  /// you must make sure that:
457  /// - The source string stays valid and unmodified for as long as you need the
458  /// AkOSChar string (for cases where they point to the same string)
459  /// - The AkOSChar string is used within this scope only -- for example, do NOT
460  /// return that string from a function (for cases where it is allocated on the stack)
461 #define CONVERT_WIDE_TO_OSCHAR( _wstring_, _oscharstring_ ) \
462  _oscharstring_ = (AkOSChar*)AkAlloca( (1 + wcslen( _wstring_ )) * sizeof(AkOSChar) ); \
463  AKPLATFORM::AkWideCharToChar( _wstring_ , (AkUInt32)(1 + wcslen( _wstring_ )), (AkOSChar*)( _oscharstring_ ) )
464 
465  /// Converts a char string to an AkOSChar string.
466  /// \remark On some platforms the AkOSChar string simply points to the same string,
467  /// on others a new buffer is allocated on the stack using AkAlloca. This means
468  /// you must make sure that:
469  /// - The source string stays valid and unmodified for as long as you need the
470  /// AkOSChar string (for cases where they point to the same string)
471  /// - The AkOSChar string is used within this scope only -- for example, do NOT
472  /// return that string from a function (for cases where it is allocated on the stack)
473 #define CONVERT_CHAR_TO_OSCHAR( _astring_, _oscharstring_ ) ( _oscharstring_ ) = (AkOSChar*)( _astring_ )
474 
475  /// Converts a AkOSChar string into wide char string.
476  /// \remark On some platforms the AkOSChar string simply points to the same string,
477  /// on others a new buffer is allocated on the stack using AkAlloca. This means
478  /// you must make sure that:
479  /// - The source string stays valid and unmodified for as long as you need the
480  /// AkOSChar string (for cases where they point to the same string)
481  /// - The AkOSChar string is used within this scope only -- for example, do NOT
482  /// return that string from a function (for cases where it is allocated on the stack)
483 #define CONVERT_OSCHAR_TO_WIDE( _osstring_, _wstring_ ) \
484  _wstring_ = (wchar_t*)AkAlloca((1+strlen(_osstring_)) * sizeof(wchar_t)); \
485  AKPLATFORM::AkCharToWideChar( _osstring_, (AkUInt32)(1 + strlen(_osstring_ )), _wstring_ )
486 
487  /// Converts a AkOSChar string into char string.
488  /// \remark On some platforms the AkOSChar string simply points to the same string,
489  /// on others a new buffer is allocated on the stack using AkAlloca. This means
490  /// you must make sure that:
491  /// - The source string stays valid and unmodified for as long as you need the
492  /// AkOSChar string (for cases where they point to the same string)
493  /// - The AkOSChar string is used within this scope only -- for example, do NOT
494  /// return that string from a function (for cases where it is allocated on the stack)
495 #define CONVERT_OSCHAR_TO_CHAR( _osstring_, _astring_ ) _astring_ = (char*)_osstring_
496 
497  #define AK_PATH_SEPARATOR ("/")
498  #define AK_LIBRARY_PREFIX ("")
499  #define AK_DYNAMIC_LIBRARY_EXTENSION ("")
500 
501 }
502 
503 #ifdef AK_ENABLE_INSTRUMENT
504 
505 #define NN_PERF_PROFILE_ENABLED
506 #include <nn/perf.h>
507 
508 #define AK_INSTRUMENT_BEGIN( _zone_name_ ) NN_PERF_BEGIN_MEASURE_NAME(_zone_name_)
509 #define AK_INSTRUMENT_BEGIN_C( _color_, _zone_name_ )
510 #define AK_INSTRUMENT_END( _zone_name_ ) NN_PERF_END_MEASURE()
511 #define AK_INSTRUMENT_SCOPE( _zone_name_ ) NN_PERF_AUTO_MEASURE_NAME(_zone_name_)
512 
513 #define AK_INSTRUMENT_IDLE_BEGIN( _zone_name_ )
514 #define AK_INSTRUMENT_IDLE_END( _zone_name_ )
515 #define AK_INSTRUMENT_IDLE_SCOPE( _zone_name_ )
516 
517 #define AK_INSTRUMENT_STALL_BEGIN( _zone_name_ )
518 #define AK_INSTRUMENT_STALL_END( _zone_name_ )
519 #define AK_INSTRUMENT_STALL_SCOPE( _zone_name_ )
520 
521 #define AK_INSTRUMENT_THREAD_START( _thread_name_ )
522 
523 #endif // AK_ENABLE_INSTRUMENT
void AkSignalEvent(const AkEvent &in_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:109
AkForceInline AkInt32 AkUtf8ToWideChar(const char *in_pszUtf8String, AkUInt32 in_uiOutBufferSize, void *io_pvUnicodeStringBuffer)
String conversion helper.
Definition: AkPlatformFuncs.h:404
AkForceInline int OsStrCmp(const AkOSChar *in_pszString1, const AkOSChar *in_pszString2)
Definition: AkPlatformFuncs.h:514
The operation was successful.
Definition: AkTypes.h:129
void AkMemoryBarrier()
Definition: AkPlatformFuncs.h:91
ScePthread AkThread
Thread handle.
Definition: AkTypes.h:99
AkForceInline void SafeStrCat(wchar_t *in_pDest, const wchar_t *in_pSrc, size_t in_uDestMaxNumChars)
Safe unicode string concatenation.
Definition: AkPlatformFuncs.h:428
AKRESULT
Standard function call result.
Definition: AkTypes.h:126
uint8_t AkUInt8
Unsigned 8-bit integer.
Definition: AkTypes.h:76
void AkDestroyEvent(AkEvent &io_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:78
void *(* AkThreadRoutine)(void *lpThreadParameter)
Thread routine.
Definition: AkTypes.h:101
AkInt32 AkInterlockedDecrement(AkAtomic32 *pValue)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:76
wchar_t AkUtf16
Definition: AkTypes.h:106
AkForceInline AkReal32 Elapsed(const AkInt64 &in_iNow, const AkInt64 &in_iStart)
Returns a time range in milliseconds, using the sound engine's updated count->milliseconds ratio.
Definition: AkPlatformFuncs.h:366
AkForceInline void AkMemCpy(void *pDest, const void *pSrc, AkUInt32 uSize)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:330
int nPriority
Thread priority.
Definition: AkPlatformFuncs.h:50
Audiokinetic namespace.
void OutputDebugMsg(const char *in_pszMsg)
Output a debug message on the console (Ansi string)
Definition: AkPlatformFuncs.h:57
ScePthread AkThreadID
Thread ID.
Definition: AkTypes.h:100
AkThreadID CurrentThread()
Returns the calling thread's ID.
Definition: AkPlatformFuncs.h:315
void AkClearEvent(AkEvent &out_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:49
nn::Bit64 affinityMask
Affinity mask for each core: see nn::os::SetThreadCoreMask documentation.
Definition: AkPlatformFuncs.h:61
void AkWaitForEvent(AkEvent &in_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:98
void AkCreateThread(AkThreadRoutine pStartRoutine, void *pParams, const AkThreadProperties &in_threadProperties, AkThread *out_pThread, const char *)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:145
#define AKASSERT(Condition)
Definition: AkAssert.h:69
#define AkMin(x1, x2)
Definition: AkPlatformFuncs.h:50
#define AK_DEFAULT_STACK_SIZE
Definition: AkPlatformFuncs.h:83
#define AkForceInline
Force inlining.
Definition: AkTypes.h:62
AkForceInline void UpdatePerformanceFrequency()
Platform Independent Helper.
Definition: AkPlatformFuncs.h:358
int32_t AkInt32
Signed 32-bit integer.
Definition: AkTypes.h:91
void PerformanceCounter(AkInt64 *out_piLastTime)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:106
AkForceInline void AkClearThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:218
AkForceInline void SafeStrCpy(wchar_t *in_pDest, const wchar_t *in_pSrc, size_t in_uDestMaxNumChars)
Safe unicode string copy.
Definition: AkPlatformFuncs.h:412
AkForceInline bool AkIsValidThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:212
AkForceInline void AkSleep(AkUInt32 in_ulMilliseconds)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:321
AkForceInline void AkMemSet(void *pDest, AkInt32 iVal, AkUInt32 uSize)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:336
AkForceInline AkInt32 AkWideCharToChar(const wchar_t *in_pszUnicodeString, AkUInt32 in_uiOutBufferSize, char *io_pszAnsiString)
String conversion helper.
Definition: AkPlatformFuncs.h:372
AKRESULT AkCreateEvent(AkEvent &out_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:55
AkReal32 g_fFreqRatio
Definition: AkPlatformFuncs.h:71
int OsStrNCmp(const AkOSChar *in_pszString1, const AkOSChar *in_pszString2, size_t in_MaxCountSize)
Definition: AkPlatformFuncs.h:525
size_t AkSimpleConvertString(destType *in_pdDest, const srcType *in_pSrc, size_t in_MaxSize, size_t destStrLen(const destType *), size_t srcStrLen(const srcType *))
Definition: AkPlatformFuncs.h:113
int iIdealCore
Preferred core number: see nn::os::SetThreadCoreMask documentation.
Definition: AkPlatformFuncs.h:60
#define NULL
Definition: AkTypes.h:49
int64_t AkInt64
Signed 64-bit integer.
Definition: AkTypes.h:92
void PerformanceFrequency(AkInt64 *out_piFreq)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:43
AkForceInline void AkGetDefaultThreadProperties(AkThreadProperties &out_threadProperties)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:237
AkInt32 nPriority
Thread priority. 0=highest, 31=lowest.
Definition: AkPlatformFuncs.h:58
AkForceInline AkInt32 AkCharToWideChar(const char *in_pszAnsiString, AkUInt32 in_uiOutBufferSize, void *io_pvUnicodeStringBuffer)
String conversion helper.
Definition: AkPlatformFuncs.h:389
AkForceInline void AkCloseThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:224
AkForceInline void AkWaitForSingleThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:308
bool AkInterlockedCompareExchange(volatile AkAtomic32 *io_pDest, AkInt32 in_newValue, AkInt32 in_expectedOldVal)
Definition: AkPlatformFuncs.h:81
AkForceInline size_t OsStrLen(const AkOSChar *in_pszString)
Definition: AkPlatformFuncs.h:500
double AkReal64
64-bit floating point
Definition: AkTypes.h:97
uint32_t AkUInt32
Unsigned 32-bit integer.
Definition: AkTypes.h:78
semaphore_t AkEvent
Definition: AkTypes.h:80
size_t uStackSize
Thread stack size.
Definition: AkPlatformFuncs.h:52
#define AK_THREAD_PRIORITY_NORMAL
Definition: AkPlatformFuncs.h:81
float AkReal32
32-bit floating point
Definition: AkTypes.h:96
char AkOSChar
Generic character string.
Definition: AkTypes.h:94
size_t AkUtf16StrLen(const AkUtf16 *in_pStr)
Definition: AkPlatformFuncs.h:493
AkInt32 AkInterlockedIncrement(AkAtomic32 *pValue)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:70