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