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

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

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