Version
menu

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

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