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

此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅