Version

menu_open
Wwise SDK 2024.1.4
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 #ifndef _AK_PLATFORM_FUNCS_H_
28 #define _AK_PLATFORM_FUNCS_H_
29 
31 #include <sceerror.h>
32 #include <wchar.h>
33 #include <string.h>
34 #include <stdio.h>
35 #include <time.h>
36 #include <kernel/eventflag.h>
37 #include <unistd.h>
38 #include <sys/time.h>
39 #include <stdlib.h>
40 
41 //-----------------------------------------------------------------------------
42 // Platform-specific thread properties definition.
43 //-----------------------------------------------------------------------------
45 {
46  int nPriority; ///< Thread priority
47  SceKernelCpumask dwAffinityMask; ///< Affinity mask
48  size_t uStackSize; ///< Thread stack size
49  int uSchedPolicy; ///< Thread scheduling policy
50 };
51 
52 //-----------------------------------------------------------------------------
53 // External variables.
54 //-----------------------------------------------------------------------------
55 // g_fFreqRatio is used by time helpers to return time values in milliseconds.
56 // It is declared and updated by the sound engine.
57 namespace AK
58 {
59  extern AkReal32 g_fFreqRatio;
60 }
61 
62 //-----------------------------------------------------------------------------
63 // Defines for PS4.
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_RETURN_THREAD_OK 0x00000000
71 #define AK_RETURN_THREAD_ERROR 0x00000001
72 #define AK_DEFAULT_STACK_SIZE (128*1024)
73 #define AK_THREAD_DEFAULT_SCHED_POLICY SCE_KERNEL_SCHED_FIFO
74 #define AK_THREAD_PRIORITY_NORMAL SCE_KERNEL_PRIO_FIFO_DEFAULT
75 #define AK_THREAD_PRIORITY_ABOVE_NORMAL SCE_KERNEL_PRIO_FIFO_HIGHEST
76 #define AK_THREAD_PRIORITY_BELOW_NORMAL SCE_KERNEL_PRIO_FIFO_LOWEST
77 
78 #define AK_THREAD_AFFINITY_ALL 63 // from binary 111111 setting the 6 available core to true. (ex: 4 << 1)
79 #define AK_THREAD_AFFINITY_DEFAULT AK_THREAD_AFFINITY_ALL
80 
81 // On PS4 this needs to be called regularly.
82 #define AK_RELEASE_GPU_OFFLINE_FRAME sce::Gnm::submitDone();
83 
84 // NULL objects
85 #define AK_NULL_THREAD NULL
86 
87 #define AK_INFINITE (AK_UINT_MAX)
88 
89 #define AkMax(x1, x2) (((x1) > (x2))? (x1): (x2))
90 #define AkMin(x1, x2) (((x1) < (x2))? (x1): (x2))
91 #define AkClamp(x, min, max) ((x) < (min)) ? (min) : (((x) > (max) ? (max) : (x)))
92 
93 namespace AKPLATFORM
94 {
95 #ifndef AK_OPTIMIZED
96  // The same orientation must be used for all
97  // OutputDebugMsg (either char or wchar_t) since
98  // using both in the same stream is undefined behavior.
99 
100  /// Output a debug message on the console (Ansi string)
101  AkForceInline void OutputDebugMsg( const char* in_pszMsg )
102  {
103  fputs( in_pszMsg, stderr );
104  }
105  /// Output a debug message on the console (Unicode string)
106  AkForceInline void OutputDebugMsg( const wchar_t* in_pszMsg )
107  {
108  fputws( in_pszMsg, stderr );
109  }
110 
111  /// Output a debug message on the console (Unicode string) (variadic function)
112  template <int MaxSize = 0> // Unused
113  AkForceInline void OutputDebugMsgV( const wchar_t* in_pszFmt, ... )
114  {
115  va_list args;
116  va_start(args, in_pszFmt);
117  vfwprintf(stderr, in_pszFmt, args);
118  va_end(args);
119  }
120 
121  /// Output a debug message on the console (Ansi string) (variadic function)
122  template <int MaxSize = 0> // Unused
123  AkForceInline void OutputDebugMsgV( const char* in_pszFmt, ... )
124  {
125  va_list args;
126  va_start(args, in_pszFmt);
127  vfprintf(stderr, in_pszFmt, args);
128  va_end(args);
129  }
130 #else
131  inline void OutputDebugMsg( const wchar_t* ){}
132  inline void OutputDebugMsg( const char* ){}
133 
134  template <int MaxSize = 0> // Unused
135  inline void OutputDebugMsgV( const wchar_t*, ... ){}
136 
137  template <int MaxSize = 0> // Unused
138  inline void OutputDebugMsgV( const char*, ... ){}
139 #endif
140 
141 
142  // Simple automatic event API
143  // ------------------------------------------------------------------
144 
145  /// Platform Independent Helper
146  AkForceInline void AkClearEvent( AkEvent & out_event )
147  {
148  out_event = NULL;
149  }
150 
151  AkForceInline AKRESULT AkCreateNamedEvent( AkEvent & out_event, const char* in_szName )
152  {
153  // NOTE: AkWaitForEvent uses the SCE_KERNEL_EVF_WAITMODE_CLEAR_PAT flag
154  // to get the same behavior as an auto-reset Win32 event
155  int ret = sceKernelCreateEventFlag(
156  &out_event,
157  in_szName,
158  SCE_KERNEL_EVF_ATTR_MULTI,
159  0 /* not signalled by default */,
160  NULL /* No optional params */ );
161 
162  if( ret == SCE_OK )
163  return AK_Success;
164 
165  AkClearEvent( out_event );
166  return AK_Fail;
167  }
168 
169  /// Platform Independent Helper
171  {
172  return AkCreateNamedEvent( out_event, "AkEvent" );
173  }
174 
175  /// Platform Independent Helper
176  AkForceInline void AkDestroyEvent( AkEvent & io_event )
177  {
178  sceKernelDeleteEventFlag(io_event);
179  AkClearEvent( io_event );
180  }
181 
182  /// Platform Independent Helper
183  AkForceInline void AkWaitForEvent( AkEvent & in_event )
184  {
185  AKVERIFY( sceKernelWaitEventFlag(
186  in_event,
187  1,
188  SCE_KERNEL_EVF_WAITMODE_OR | SCE_KERNEL_EVF_WAITMODE_CLEAR_ALL,
189  SCE_NULL,
190  SCE_NULL) == 0 );
191  }
192 
193  /// Platform Independent Helper
194  AkForceInline void AkSignalEvent( const AkEvent & in_event )
195  {
196  AKVERIFY( sceKernelSetEventFlag( in_event, 1 ) == 0 );
197  }
198 
199  /// Platform Independent Helper
200  AkForceInline void AkClearSemaphore(AkSemaphore& io_semaphore)
201  {
202  io_semaphore = NULL;
203  }
204 
205  /// Platform Independent Helper
206  inline AKRESULT AkCreateSemaphore( AkSemaphore& out_semaphore, AkUInt32 in_initialCount )
207  {
208  int ret = sceKernelCreateSema(
209  &out_semaphore,
210  "AkSemaphore",
211  0,
212  in_initialCount,
213  INT_MAX,
214  NULL );
215 
216  return ( ret == SCE_OK ) ? AK_Success : AK_Fail;
217  }
218 
219  /// Platform Independent Helper
220  inline void AkDestroySemaphore(AkSemaphore& io_semaphore)
221  {
222  AKVERIFY(sceKernelDeleteSema(io_semaphore) == SCE_OK);
223  }
224 
225  /// 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.
226  inline void AkWaitForSemaphore(AkSemaphore& in_semaphore)
227  {
228  AKVERIFY(sceKernelWaitSema(in_semaphore, 1, NULL) == SCE_OK);
229  }
230 
231  /// Platform Independent Helper - Semaphore signal, aka Operation V. Increments value of semaphore by an arbitrary count.
232  inline void AkReleaseSemaphore(AkSemaphore& in_semaphore, AkUInt32 in_count)
233  {
234  AKVERIFY(sceKernelSignalSema(in_semaphore, in_count) == SCE_OK);
235  }
236 
237  // Threads
238  // ------------------------------------------------------------------
239 
240  /// Platform Independent Helper
242  {
243  return ( *in_pThread != AK_NULL_THREAD );
244  }
245 
246  /// Platform Independent Helper
247  AkForceInline void AkClearThread( AkThread * in_pThread )
248  {
249  *in_pThread = AK_NULL_THREAD;
250  }
251 
252  /// Platform Independent Helper
253  AkForceInline void AkCloseThread( AkThread * in_pThread )
254  {
255  AKASSERT( in_pThread );
256  AKASSERT( *in_pThread );
257 
258  // #define KILL_THREAD(t) do { void *ret; scePthreadJoin(t,&ret); } while(false)
259  // AKVERIFY( SCE_OK == sceKernelDeleteThread( *in_pThread ) );
260  AkClearThread( in_pThread );
261  }
262 
263  #define AkExitThread( _result ) return _result;
264 
265  /// Platform Independent Helper
267  {
268  out_threadProperties.uStackSize = AK_DEFAULT_STACK_SIZE;
269  out_threadProperties.uSchedPolicy = AK_THREAD_DEFAULT_SCHED_POLICY;
270  out_threadProperties.nPriority = AK_THREAD_PRIORITY_NORMAL;
271  out_threadProperties.dwAffinityMask = AK_THREAD_AFFINITY_DEFAULT;
272  }
273 
274  /// Platform Independent Helper
275  inline void AkCreateThread(
276  AkThreadRoutine pStartRoutine, // Thread routine.
277  void * pParams, // Routine params.
278  const AkThreadProperties & in_threadProperties, // Properties. NULL for default.
279  AkThread * out_pThread, // Returned thread handle.
280  const char * in_szThreadName ) // Opt thread name.
281  {
282  AKASSERT( out_pThread != NULL );
283 
284  ScePthreadAttr attr;
285 
286  // Create the attr
287  AKVERIFY(!scePthreadAttrInit(&attr));
288  // Set the stack size
289  AKVERIFY(!scePthreadAttrSetstacksize(&attr,in_threadProperties.uStackSize));
290  AKVERIFY(!scePthreadAttrSetdetachstate(&attr, SCE_PTHREAD_CREATE_JOINABLE));
291  AKVERIFY(!scePthreadAttrSetinheritsched(&attr, SCE_PTHREAD_EXPLICIT_SCHED));
292  AKVERIFY(!scePthreadAttrSetaffinity(&attr,in_threadProperties.dwAffinityMask));
293 
294  // Try to set the thread policy
295  int sched_policy = in_threadProperties.uSchedPolicy;
296  if( scePthreadAttrSetschedpolicy( &attr, sched_policy ) )
297  {
298  AKASSERT( !"AKCreateThread invalid sched policy, will automatically set it to FIFO scheduling" );
299  sched_policy = AK_THREAD_DEFAULT_SCHED_POLICY;
300  AKVERIFY( !scePthreadAttrSetschedpolicy( &attr, sched_policy ));
301  }
302 
303  int minPriority, maxPriority;
304  minPriority = SCE_KERNEL_PRIO_FIFO_HIGHEST;
305  maxPriority = SCE_KERNEL_PRIO_FIFO_LOWEST;
306 
307  // Set the thread priority if valid
308  AKASSERT( in_threadProperties.nPriority >= minPriority && in_threadProperties.nPriority <= maxPriority );
309  if( in_threadProperties.nPriority >= minPriority && in_threadProperties.nPriority <= maxPriority )
310  {
311  SceKernelSchedParam schedParam;
312  AKVERIFY( scePthreadAttrGetschedparam(&attr, &schedParam) == 0 );
313  schedParam.sched_priority = in_threadProperties.nPriority;
314  AKVERIFY( scePthreadAttrSetschedparam(&attr, &schedParam) == 0 );
315  }
316 
317  // Create the tread
318  int threadError = scePthreadCreate(out_pThread, &attr, pStartRoutine, pParams, in_szThreadName);
319  AKASSERT( threadError == 0 );
320  AKVERIFY(!scePthreadAttrDestroy(&attr));
321 
322  if( threadError != 0 )
323  {
324  AkClearThread( out_pThread );
325  return;
326  }
327 
328  // ::CreateThread() return NULL if it fails.
329  if ( !*out_pThread )
330  {
331  AkClearThread( out_pThread );
332  return;
333  }
334  }
335 
336  /// Platform Independent Helper
338  {
339  AKASSERT( in_pThread );
340  AKASSERT( *in_pThread );
341  AKVERIFY(!scePthreadJoin( *in_pThread, NULL ));
342  }
343 
345  {
346  return scePthreadSelf();
347  }
348 
349  /// Platform Independent Helper
350  AkForceInline void AkSleep( AkUInt32 in_ulMilliseconds )
351  {
352  usleep( in_ulMilliseconds * 1000 );
353  }
354 
355  // Time functions
356  // ------------------------------------------------------------------
357 
358  /// Platform Independent Helper
359  AkForceInline void PerformanceCounter( AkInt64 * out_piLastTime )
360  {
361  uint64_t uTime = sceKernelGetProcessTimeCounter();
362  *out_piLastTime = (AkInt64)uTime;
363  }
364 
365  /// Frequency of the PerformanceCounter() (ticks per second)
366  AkForceInline void PerformanceFrequency( AkInt64 * out_piFreq )
367  {
368  *out_piFreq = (AkInt64)sceKernelGetProcessTimeCounterFrequency();
369  }
370 
371  /// Platform Independent Helper
373  {
374  AkInt64 iFreq;
375  PerformanceFrequency( &iFreq );
376  AK::g_fFreqRatio = (AkReal32)((AkReal64)iFreq / 1000);
377  }
378 
379  /// Returns a time range in milliseconds, using the sound engine's updated count->milliseconds ratio.
380  AkForceInline AkReal32 Elapsed( const AkInt64 & in_iNow, const AkInt64 & in_iStart )
381  {
382  return ( in_iNow - in_iStart ) / AK::g_fFreqRatio;
383  }
384 
385  /// String conversion helper
386  AkForceInline AkInt32 AkWideCharToChar( const wchar_t* in_pszUnicodeString,
387  AkUInt32 in_uiOutBufferSize,
388  char* io_pszAnsiString )
389  {
390  AKASSERT( io_pszAnsiString != NULL );
391 
392  mbstate_t state;
393  memset (&state, '\0', sizeof (state));
394 
395  return (AkInt32)wcsrtombs(io_pszAnsiString, // destination
396  &in_pszUnicodeString, // source
397  in_uiOutBufferSize, // destination length
398  &state); //
399 
400  }
401 
402  /// String conversion helper
403  AkForceInline AkInt32 AkCharToWideChar( const char* in_pszAnsiString,
404  AkUInt32 in_uiOutBufferSize,
405  void* io_pvUnicodeStringBuffer )
406  {
407  AKASSERT( io_pvUnicodeStringBuffer != NULL );
408 
409  mbstate_t state;
410  memset (&state, '\0', sizeof (state));
411 
412  return (AkInt32)mbsrtowcs((wchar_t*)io_pvUnicodeStringBuffer, // destination
413  &in_pszAnsiString, // source
414  in_uiOutBufferSize, // destination length
415  &state); //
416  }
417 
418  AkForceInline AkInt32 AkUtf8ToWideChar( const char* in_pszUtf8String,
419  AkUInt32 in_uiOutBufferSize,
420  void* io_pvUnicodeStringBuffer )
421  {
422  return AkCharToWideChar( in_pszUtf8String, in_uiOutBufferSize, (wchar_t*)io_pvUnicodeStringBuffer );
423  }
424 
425  /// Safe unicode string copy.
426  AkForceInline void SafeStrCpy( wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars )
427  {
428  size_t uSizeCopy = AkMin( in_uDestMaxNumChars - 1, wcslen( in_pSrc ) + 1 );
429  wcsncpy( in_pDest, in_pSrc, uSizeCopy );
430  in_pDest[uSizeCopy] = '\0';
431  }
432 
433  /// Safe ansi string copy.
434  AkForceInline void SafeStrCpy( char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars )
435  {
436  size_t uSizeCopy = AkMin( in_uDestMaxNumChars - 1, strlen( in_pSrc ) + 1 );
437  strncpy( in_pDest, in_pSrc, uSizeCopy );
438  in_pDest[uSizeCopy] = '\0';
439  }
440 
441  /// Safe unicode string concatenation.
442  AkForceInline void SafeStrCat( wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars )
443  {
444  size_t uAvailableSize = ( in_uDestMaxNumChars - wcslen( in_pDest ) - 1 );
445  wcsncat( in_pDest, in_pSrc, AkMin( uAvailableSize, wcslen( in_pSrc ) ) );
446  }
447 
448  /// Safe ansi string concatenation.
449  AkForceInline void SafeStrCat( char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars )
450  {
451  size_t uAvailableSize = ( in_uDestMaxNumChars - strlen( in_pDest ) - 1 );
452  strncat( in_pDest, in_pSrc, AkMin( uAvailableSize, strlen( in_pSrc ) ) );
453  }
454 
455  inline int SafeStrFormat(wchar_t * in_pDest, size_t in_uDestMaxNumChars, const wchar_t* in_pszFmt, ...)
456  {
457  va_list args;
458  va_start(args, in_pszFmt);
459  int r = vswprintf(in_pDest, in_uDestMaxNumChars, in_pszFmt, args);
460  va_end(args);
461  return r;
462  }
463 
464  inline int SafeStrFormat(char * in_pDest, size_t in_uDestMaxNumChars, const char* in_pszFmt, ...)
465  {
466  va_list args;
467  va_start(args, in_pszFmt);
468  int r = vsnprintf(in_pDest, in_uDestMaxNumChars, in_pszFmt, args);
469  va_end(args);
470  return r;
471  }
472 
473  /// Stack allocations.
474  #define AkAlloca( _size_ ) alloca( _size_ )
475 
476 
477 
478  /// Converts a wchar_t string to an AkOSChar string.
479  /// \remark On some platforms the AkOSChar string simply points to the same string,
480  /// on others a new buffer is allocated on the stack using AkAlloca. This means
481  /// you must make sure that:
482  /// - The source string stays valid and unmodified for as long as you need the
483  /// AkOSChar string (for cases where they point to the same string)
484  /// - The AkOSChar string is used within this scope only -- for example, do NOT
485  /// return that string from a function (for cases where it is allocated on the stack)
486  #define CONVERT_WIDE_TO_OSCHAR( _wstring_, _oscharstring_ ) \
487  _oscharstring_ = (AkOSChar*)AkAlloca( (1 + wcslen( _wstring_ )) * sizeof(AkOSChar) ); \
488  AKPLATFORM::AkWideCharToChar( _wstring_ , (AkUInt32)(1 + wcslen( _wstring_ )), (AkOSChar*)( _oscharstring_ ) )
489 
490 
491  /// Converts a char string to an AkOSChar 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_CHAR_TO_OSCHAR( _astring_, _oscharstring_ ) ( _oscharstring_ ) = (AkOSChar*)( _astring_ )
500 
501  /// Converts a AkOSChar string into wide char string.
502  /// \remark On some platforms the AkOSChar string simply points to the same string,
503  /// on others a new buffer is allocated on the stack using AkAlloca. This means
504  /// you must make sure that:
505  /// - The source string stays valid and unmodified for as long as you need the
506  /// AkOSChar string (for cases where they point to the same string)
507  /// - The AkOSChar string is used within this scope only -- for example, do NOT
508  /// return that string from a function (for cases where it is allocated on the stack)
509  #define CONVERT_OSCHAR_TO_WIDE( _osstring_, _wstring_ ) \
510  _wstring_ = (wchar_t*)AkAlloca((1+strlen(_osstring_)) * sizeof(wchar_t)); \
511  AKPLATFORM::AkCharToWideChar( _osstring_, (AkUInt32)(1 + strlen(_osstring_ )), _wstring_ )
512 
513  /// Converts a AkOSChar string into char string.
514  /// \remark On some platforms the AkOSChar string simply points to the same string,
515  /// on others a new buffer is allocated on the stack using AkAlloca. This means
516  /// you must make sure that:
517  /// - The source string stays valid and unmodified for as long as you need the
518  /// AkOSChar string (for cases where they point to the same string)
519  /// - The AkOSChar string is used within this scope only -- for example, do NOT
520  /// return that string from a function (for cases where it is allocated on the stack)
521  #define CONVERT_OSCHAR_TO_CHAR( _osstring_, _astring_ ) _astring_ = (char*)_osstring_
522 
523  /// Get the length, in characters, of a NULL-terminated AkUtf16 string
524  /// \return The length, in characters, of the specified string (excluding terminating NULL)
525  AkForceInline size_t AkUtf16StrLen( const AkUtf16* in_pStr )
526  {
527  return ( wcslen( in_pStr ) );
528  }
529 
530  /// Get the length, in characters, of a NULL-terminated AkOSChar string
531  /// \return The length, in characters, of the specified string (excluding terminating NULL)
532  AkForceInline size_t OsStrLen( const AkOSChar* in_pszString )
533  {
534  return ( strlen( in_pszString ) );
535  }
536 
537  /// AkOSChar version of sprintf().
538  #define AK_OSPRINTF snprintf
539 
540  /// Compare two NULL-terminated AkOSChar strings
541  /// \return
542  /// - < 0 if in_pszString1 < in_pszString2
543  /// - 0 if the two strings are identical
544  /// - > 0 if in_pszString1 > in_pszString2
545  /// \remark The comparison is case-sensitive
546  AkForceInline int OsStrCmp( const AkOSChar* in_pszString1, const AkOSChar* in_pszString2 )
547  {
548  return ( strcmp( in_pszString1, in_pszString2 ) );
549  }
550 
551  /// Compare two NULL-terminated AkOSChar strings up to the specified count of characters.
552  /// \return
553  /// - < 0 if in_pszString1 < in_pszString2
554  /// - 0 if the two strings are identical
555  /// - > 0 if in_pszString1 > in_pszString2
556  /// \remark The comparison is case-sensitive
557  inline int OsStrNCmp( const AkOSChar* in_pszString1, const AkOSChar* in_pszString2, size_t in_MaxCountSize )
558  {
559  return ( strncmp(in_pszString1, in_pszString2, in_MaxCountSize) );
560  }
561 
562  /// Detects whether the string represents an absolute path to a file
563  inline bool IsAbsolutePath(const AkOSChar* in_pszPath, size_t in_pathLen)
564  {
565  return in_pathLen >= 1 && in_pszPath[0] == '/';
566  }
567 
568  #define AK_UTF8_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
569  #define AK_UTF16_TO_WCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
570  #define AK_WCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
571  #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkWideCharToChar( in_pSrc, in_MaxSize, in_pdDest )
572  #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkWideCharToChar( in_pSrc, in_MaxSize, in_pdDest )
573  #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkCharToWideChar( in_pSrc, in_MaxSize, in_pdDest )
574  #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkCharToWideChar( in_pSrc, in_MaxSize, in_pdDest )
575 
576  // Use with AkOSChar.
577  #define AK_PATH_SEPARATOR "/"
578  #define AK_HOST_PATH_SEPARATOR "\\"
579  #define AK_LIBRARY_PREFIX ""
580  #define AK_DYNAMIC_LIBRARY_EXTENSION ".prx"
581 
582  #define AK_FILEHANDLE_TO_UINTPTR(_h) ((AkUIntPtr)_h)
583  #define AK_SET_FILEHANDLE_TO_UINTPTR(_h,_u) _h = (AkFileHandle)_u
584 }
585 
586 #endif // _AK_PLATFORM_FUNCS_H_
#define AK_THREAD_DEFAULT_SCHED_POLICY
#define AkMin(x1, x2)
AKRESULT AkCreateSemaphore(AkSemaphore &out_semaphore, AkUInt32 in_initialCount)
Platform Independent Helper.
size_t AkUtf16StrLen(const AkUtf16 *in_pStr)
Definition of data structures for AkAudioObject.
@ AK_Fail
The operation failed.
Definition: AkTypes.h:137
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
#define AK_NULL_THREAD
AKRESULT
Standard function call result.
Definition: AkTypes.h:134
void OutputDebugMsg(const char *in_pszMsg)
Output a debug message on the console (Ansi string)
char AkOSChar
Generic character string.
Definition: AkTypes.h:60
int SafeStrFormat(wchar_t *in_pDest, size_t in_uDestMaxNumChars, const wchar_t *in_pszFmt,...)
#define NULL
Definition: AkTypes.h:46
#define AK_THREAD_PRIORITY_NORMAL
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.
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
#define AK_DEFAULT_STACK_SIZE
#define AKVERIFY(x)
Definition: AkAssert.h:69
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)
SceKernelCpumask dwAffinityMask
Affinity mask.
AkReal32 g_fFreqRatio
double AkReal64
64-bit floating point
AKRESULT AkCreateEvent(AkEvent &out_event)
Platform Independent Helper.
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.
#define AK_THREAD_AFFINITY_DEFAULT
void AkWaitForSemaphore(AkSemaphore &in_semaphore)
Platform Independent Helper - Semaphore wait, aka Operation P. Decrements value of semaphore,...
size_t uStackSize
Thread stack size.
void PerformanceFrequency(AkInt64 *out_piFreq)
Platform Independent Helper.
int uSchedPolicy
Thread scheduling policy.
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 AKRESULT AkCreateNamedEvent(AkEvent &out_event, const char *in_szName)
AkForceInline AkInt32 AkWideCharToChar(const wchar_t *in_pszUnicodeString, AkUInt32 in_uiOutBufferSize, char *io_pszAnsiString)
String conversion helper.
AkForceInline void AkWaitForSingleThread(AkThread *in_pThread)
Platform Independent Helper.
void AkSignalEvent(const AkEvent &in_event)
Platform Independent Helper.
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