Version
menu_open
link
Wwise SDK 2018.1.11
AkPlatformFuncs.h
Go to the documentation of this file.
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12 Apache License Usage
13 
14 Alternatively, this file may be used under the Apache License, Version 2.0 (the
15 "Apache License"); you may not use this file except in compliance with the
16 Apache License. You may obtain a copy of the Apache License at
17 http://www.apache.org/licenses/LICENSE-2.0.
18 
19 Unless required by applicable law or agreed to in writing, software distributed
20 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
21 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
22 the specific language governing permissions and limitations under the License.
23 
24  Version: <VERSION> Build: <BUILDNUMBER>
25  Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
26 *******************************************************************************/
27 
28 #ifndef _AK_PLATFORM_FUNCS_H_
29 #define _AK_PLATFORM_FUNCS_H_
30 
33 #include <sce_atomic.h>
34 #include <sceerror.h>
35 #include <wchar.h>
36 #include <string.h>
37 #include <stdio.h>
38 #include <time.h>
39 #include <kernel\eventflag.h>
40 #include <unistd.h>
41 #include <sys/time.h>
42 #include <stdlib.h>
43 
44 
45 //-----------------------------------------------------------------------------
46 // Platform-specific thread properties definition.
47 //-----------------------------------------------------------------------------
49 {
50  int nPriority; ///< Thread priority
51  SceKernelCpumask dwAffinityMask; ///< Affinity mask
52  size_t uStackSize; ///< Thread stack size
53  int uSchedPolicy; ///< Thread scheduling policy
54 };
55 
56 //-----------------------------------------------------------------------------
57 // External variables.
58 //-----------------------------------------------------------------------------
59 // g_fFreqRatio is used by time helpers to return time values in milliseconds.
60 // It is declared and updated by the sound engine.
61 namespace AK
62 {
63  extern AkReal32 g_fFreqRatio;
64 }
65 
66 //-----------------------------------------------------------------------------
67 // Defines for PS4.
68 //-----------------------------------------------------------------------------
69 #define AK_DECLARE_THREAD_ROUTINE( FuncName ) void* FuncName(void* lpParameter)
70 #define AK_THREAD_RETURN( _param_ ) return (_param_);
71 #define AK_THREAD_ROUTINE_PARAMETER lpParameter
72 #define AK_GET_THREAD_ROUTINE_PARAMETER_PTR(type) reinterpret_cast<type*>( AK_THREAD_ROUTINE_PARAMETER )
73 
74 #define AK_RETURN_THREAD_OK 0x00000000
75 #define AK_RETURN_THREAD_ERROR 0x00000001
76 #define AK_DEFAULT_STACK_SIZE (128*1024)
77 #define AK_THREAD_DEFAULT_SCHED_POLICY SCE_KERNEL_SCHED_FIFO
78 #define AK_THREAD_PRIORITY_NORMAL SCE_KERNEL_PRIO_FIFO_DEFAULT
79 #define AK_THREAD_PRIORITY_ABOVE_NORMAL SCE_KERNEL_PRIO_FIFO_HIGHEST
80 #define AK_THREAD_PRIORITY_BELOW_NORMAL SCE_KERNEL_PRIO_FIFO_LOWEST
81 
82 #define AK_THREAD_AFFINITY_ALL 63 // from binary 111111 setting the 6 available core to true. (ex: 4 << 1)
83 #define AK_THREAD_AFFINITY_DEFAULT AK_THREAD_AFFINITY_ALL
84 
85 // On PS4 this needs to be called regularly.
86 #define AK_RELEASE_GPU_OFFLINE_FRAME sce::Gnm::submitDone();
87 
88 // NULL objects
89 #define AK_NULL_THREAD NULL
90 
91 #define AK_INFINITE (AK_UINT_MAX)
92 
93 #define AkMax(x1, x2) (((x1) > (x2))? (x1): (x2))
94 #define AkMin(x1, x2) (((x1) < (x2))? (x1): (x2))
95 #define AkClamp(x, min, max) ((x) < (min)) ? (min) : (((x) > (max) ? (max) : (x)))
96 
97 namespace AKPLATFORM
98 {
99 #ifndef AK_OPTIMIZED
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 #else
111  inline void OutputDebugMsg( const wchar_t* ){}
112  inline void OutputDebugMsg( const char* ){}
113 #endif
114 
115 
116  // Simple automatic event API
117  // ------------------------------------------------------------------
118 
119  /// Platform Independent Helper
120  AkForceInline void AkClearEvent( AkEvent & out_event )
121  {
122  out_event = NULL;
123  }
124 
125  AkForceInline bool AkIsValidEvent(const AkEvent & in_event)
126  {
127  return (in_event != NULL);
128  }
129 
130  AkForceInline AKRESULT AkCreateNamedEvent( AkEvent & out_event, const char* in_szName )
131  {
132  // NOTE: AkWaitForEvent uses the SCE_KERNEL_EVF_WAITMODE_CLEAR_PAT flag
133  // to get the same behavior as an auto-reset Win32 event
134  int ret = sceKernelCreateEventFlag(
135  &out_event,
136  in_szName,
137  SCE_KERNEL_EVF_ATTR_MULTI,
138  0 /* not signalled by default */,
139  NULL /* No optional params */ );
140 
141  if( ret == SCE_OK && AkIsValidEvent(out_event))
142  return AK_Success;
143 
144  AkClearEvent( out_event );
145  return AK_Fail;
146  }
147 
148  /// Platform Independent Helper
150  {
151  return AkCreateNamedEvent( out_event, "AkEvent" );
152  }
153 
154  /// Platform Independent Helper
155  AkForceInline void AkDestroyEvent( AkEvent & io_event )
156  {
157  sceKernelDeleteEventFlag(io_event);
158  AkClearEvent( io_event );
159  }
160 
161  /// Platform Independent Helper
162  AkForceInline void AkWaitForEvent( AkEvent & in_event )
163  {
164  AKVERIFY( sceKernelWaitEventFlag(
165  in_event,
166  1,
167  SCE_KERNEL_EVF_WAITMODE_OR | SCE_KERNEL_EVF_WAITMODE_CLEAR_ALL,
168  SCE_NULL,
169  SCE_NULL) == 0 );
170  }
171 
172  /// Platform Independent Helper
173  AkForceInline void AkSignalEvent( const AkEvent & in_event )
174  {
175  AKVERIFY( sceKernelSetEventFlag( in_event, 1 ) == 0 );
176  }
177 
178  // Atomic Operations
179  // ------------------------------------------------------------------
180 
181  /// Platform Independent Helper
183  {
184  return sceAtomicIncrement32( (volatile SceInt32 *) pValue ) + 1;
185  }
186 
187  /// Platform Independent Helper
189  {
190  return sceAtomicDecrement32( (volatile SceInt32 *) pValue ) - 1;
191  }
192 
193  AkForceInline bool AkInterlockedCompareExchange(volatile AkAtomic64* io_pDest, AkInt64 in_newValue, AkInt64 in_expectedOldVal)
194  {
195  return sceAtomicCompareAndSwap64(io_pDest, in_expectedOldVal, in_newValue) == in_expectedOldVal;
196  }
197 
198  AkForceInline bool AkInterlockedCompareExchange(volatile AkAtomic32* io_pDest, AkInt32 in_newValue, AkInt32 in_expectedOldVal)
199  {
200  return sceAtomicCompareAndSwap32(io_pDest, in_expectedOldVal, in_newValue) == in_expectedOldVal;
201  }
202 
204  {
205  __asm("sfence");
206  }
207 
208  // Threads
209  // ------------------------------------------------------------------
210 
211  /// Platform Independent Helper
213  {
214  return ( *in_pThread != AK_NULL_THREAD );
215  }
216 
217  /// Platform Independent Helper
218  AkForceInline void AkClearThread( AkThread * in_pThread )
219  {
220  *in_pThread = AK_NULL_THREAD;
221  }
222 
223  /// Platform Independent Helper
224  AkForceInline void AkCloseThread( AkThread * in_pThread )
225  {
226  AKASSERT( in_pThread );
227  AKASSERT( *in_pThread );
228 
229  // #define KILL_THREAD(t) do { void *ret; scePthreadJoin(t,&ret); } while(false)
230  // AKVERIFY( SCE_OK == sceKernelDeleteThread( *in_pThread ) );
231  AkClearThread( in_pThread );
232  }
233 
234  #define AkExitThread( _result ) return _result; // ?????
235 
236  /// Platform Independent Helper
238  {
239  out_threadProperties.uStackSize = AK_DEFAULT_STACK_SIZE;
240  out_threadProperties.uSchedPolicy = AK_THREAD_DEFAULT_SCHED_POLICY;
241  out_threadProperties.nPriority = AK_THREAD_PRIORITY_NORMAL;
242  out_threadProperties.dwAffinityMask = AK_THREAD_AFFINITY_DEFAULT;
243  }
244 
245  /// Platform Independent Helper
246  inline void AkCreateThread(
247  AkThreadRoutine pStartRoutine, // Thread routine.
248  void * pParams, // Routine params.
249  const AkThreadProperties & in_threadProperties, // Properties. NULL for default.
250  AkThread * out_pThread, // Returned thread handle.
251  const char * in_szThreadName ) // Opt thread name.
252  {
253  AKASSERT( out_pThread != NULL );
254 
255  ScePthreadAttr attr;
256 
257  // Create the attr
258  AKVERIFY(!scePthreadAttrInit(&attr));
259  // Set the stack size
260  AKVERIFY(!scePthreadAttrSetstacksize(&attr,in_threadProperties.uStackSize));
261  AKVERIFY(!scePthreadAttrSetdetachstate(&attr, SCE_PTHREAD_CREATE_JOINABLE));
262  AKVERIFY(!scePthreadAttrSetinheritsched(&attr, SCE_PTHREAD_EXPLICIT_SCHED));
263  AKVERIFY(!scePthreadAttrSetaffinity(&attr,in_threadProperties.dwAffinityMask));
264 
265  // Try to set the thread policy
266  int sched_policy = in_threadProperties.uSchedPolicy;
267  if( scePthreadAttrSetschedpolicy( &attr, sched_policy ) )
268  {
269  AKASSERT( !"AKCreateThread invalid sched policy, will automatically set it to FIFO scheduling" );
270  sched_policy = AK_THREAD_DEFAULT_SCHED_POLICY;
271  AKVERIFY( !scePthreadAttrSetschedpolicy( &attr, sched_policy ));
272  }
273 
274  int minPriority, maxPriority;
275  minPriority = SCE_KERNEL_PRIO_FIFO_HIGHEST;
276  maxPriority = SCE_KERNEL_PRIO_FIFO_LOWEST;
277 
278  // Set the thread priority if valid
279  AKASSERT( in_threadProperties.nPriority >= minPriority && in_threadProperties.nPriority <= maxPriority );
280  if( in_threadProperties.nPriority >= minPriority && in_threadProperties.nPriority <= maxPriority )
281  {
282  SceKernelSchedParam schedParam;
283  AKVERIFY( scePthreadAttrGetschedparam(&attr, &schedParam) == 0 );
284  schedParam.sched_priority = in_threadProperties.nPriority;
285  AKVERIFY( scePthreadAttrSetschedparam(&attr, &schedParam) == 0 );
286  }
287 
288  // Create the tread
289  int threadError = scePthreadCreate(out_pThread, &attr, pStartRoutine, pParams, in_szThreadName);
290  AKASSERT( threadError == 0 );
291  AKVERIFY(!scePthreadAttrDestroy(&attr));
292 
293  if( threadError != 0 )
294  {
295  AkClearThread( out_pThread );
296  return;
297  }
298 
299  // ::CreateThread() return NULL if it fails.
300  if ( !*out_pThread )
301  {
302  AkClearThread( out_pThread );
303  return;
304  }
305  }
306 
307  /// Platform Independent Helper
309  {
310  AKASSERT( in_pThread );
311  AKASSERT( *in_pThread );
312  AKVERIFY(!scePthreadJoin( *in_pThread, NULL ));
313  }
314 
316  {
317  return scePthreadSelf();
318  }
319 
320  /// Platform Independent Helper
321  AkForceInline void AkSleep( AkUInt32 in_ulMilliseconds )
322  {
323  usleep( in_ulMilliseconds * 1000 );
324  }
325 
326  // Optimized memory functions
327  // --------------------------------------------------------------------
328 
329  /// Platform Independent Helper
330  AkForceInline void AkMemCpy( void * pDest, const void * pSrc, AkUInt32 uSize )
331  {
332  memcpy( pDest, pSrc, uSize );
333  }
334 
335  /// Platform Independent Helper
336  AkForceInline void AkMemSet( void * pDest, AkInt32 iVal, AkUInt32 uSize )
337  {
338  memset( pDest, iVal, uSize );
339  }
340 
341  // Time functions
342  // ------------------------------------------------------------------
343 
344  /// Platform Independent Helper
345  AkForceInline void PerformanceCounter( AkInt64 * out_piLastTime )
346  {
347  uint64_t uTime = sceKernelGetProcessTimeCounter();
348  *out_piLastTime = (AkInt64)uTime;
349  }
350 
351  /// Frequency of the PerformanceCounter() (ticks per second)
352  AkForceInline void PerformanceFrequency( AkInt64 * out_piFreq )
353  {
354  *out_piFreq = (AkInt64)sceKernelGetProcessTimeCounterFrequency();
355  }
356 
357  /// Platform Independent Helper
359  {
360  AkInt64 iFreq;
361  PerformanceFrequency( &iFreq );
362  AK::g_fFreqRatio = (AkReal32)( iFreq / 1000 );
363  }
364 
365  /// Returns a time range in milliseconds, using the sound engine's updated count->milliseconds ratio.
366  AkForceInline AkReal32 Elapsed( const AkInt64 & in_iNow, const AkInt64 & in_iStart )
367  {
368  return ( in_iNow - in_iStart ) / AK::g_fFreqRatio;
369  }
370 
371  /// String conversion helper
372  AkForceInline AkInt32 AkWideCharToChar( const wchar_t* in_pszUnicodeString,
373  AkUInt32 in_uiOutBufferSize,
374  char* io_pszAnsiString )
375  {
376  AKASSERT( io_pszAnsiString != NULL );
377 
378  mbstate_t state;
379  memset (&state, '\0', sizeof (state));
380 
381  return (AkInt32)wcsrtombs(io_pszAnsiString, // destination
382  &in_pszUnicodeString, // source
383  in_uiOutBufferSize, // destination length
384  &state); //
385 
386  }
387 
388  /// String conversion helper
389  AkForceInline AkInt32 AkCharToWideChar( const char* in_pszAnsiString,
390  AkUInt32 in_uiOutBufferSize,
391  void* io_pvUnicodeStringBuffer )
392  {
393  AKASSERT( io_pvUnicodeStringBuffer != NULL );
394 
395  mbstate_t state;
396  memset (&state, '\0', sizeof (state));
397 
398  return (AkInt32)mbsrtowcs((wchar_t*)io_pvUnicodeStringBuffer, // destination
399  &in_pszAnsiString, // source
400  in_uiOutBufferSize, // destination length
401  &state); //
402  }
403 
404  AkForceInline AkInt32 AkUtf8ToWideChar( const char* in_pszUtf8String,
405  AkUInt32 in_uiOutBufferSize,
406  void* io_pvUnicodeStringBuffer )
407  {
408  return AkCharToWideChar( in_pszUtf8String, in_uiOutBufferSize, (wchar_t*)io_pvUnicodeStringBuffer );
409  }
410 
411  /// Safe unicode string copy.
412  AkForceInline void SafeStrCpy( wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars )
413  {
414  size_t uSizeCopy = AkMin( in_uDestMaxNumChars - 1, wcslen( in_pSrc ) + 1 );
415  wcsncpy( in_pDest, in_pSrc, uSizeCopy );
416  in_pDest[uSizeCopy] = '\0';
417  }
418 
419  /// Safe ansi string copy.
420  AkForceInline void SafeStrCpy( char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars )
421  {
422  size_t uSizeCopy = AkMin( in_uDestMaxNumChars - 1, strlen( in_pSrc ) + 1 );
423  strncpy( in_pDest, in_pSrc, uSizeCopy );
424  in_pDest[uSizeCopy] = '\0';
425  }
426 
427  /// Safe unicode string concatenation.
428  AkForceInline void SafeStrCat( wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars )
429  {
430  size_t uAvailableSize = ( in_uDestMaxNumChars - wcslen( in_pDest ) - 1 );
431  wcsncat( in_pDest, in_pSrc, AkMin( uAvailableSize, wcslen( in_pSrc ) ) );
432  }
433 
434  /// Safe ansi string concatenation.
435  AkForceInline void SafeStrCat( char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars )
436  {
437  size_t uAvailableSize = ( in_uDestMaxNumChars - strlen( in_pDest ) - 1 );
438  strncat( in_pDest, in_pSrc, AkMin( uAvailableSize, strlen( in_pSrc ) ) );
439  }
440 
441  /// Stack allocations.
442  #define AkAlloca( _size_ ) alloca( _size_ )
443 
444 
445 
446  /// Converts a wchar_t string to an AkOSChar 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_WIDE_TO_OSCHAR( _wstring_, _oscharstring_ ) \
455  _oscharstring_ = (AkOSChar*)AkAlloca( (1 + wcslen( _wstring_ )) * sizeof(AkOSChar) ); \
456  AKPLATFORM::AkWideCharToChar( _wstring_ , (AkUInt32)(1 + wcslen( _wstring_ )), (AkOSChar*)( _oscharstring_ ) )
457 
458 
459  /// Converts a char string to an AkOSChar string.
460  /// \remark On some platforms the AkOSChar string simply points to the same string,
461  /// on others a new buffer is allocated on the stack using AkAlloca. This means
462  /// you must make sure that:
463  /// - The source string stays valid and unmodified for as long as you need the
464  /// AkOSChar string (for cases where they point to the same string)
465  /// - The AkOSChar string is used within this scope only -- for example, do NOT
466  /// return that string from a function (for cases where it is allocated on the stack)
467  #define CONVERT_CHAR_TO_OSCHAR( _astring_, _oscharstring_ ) ( _oscharstring_ ) = (AkOSChar*)( _astring_ )
468 
469  /// Converts a AkOSChar string into wide char string.
470  /// \remark On some platforms the AkOSChar string simply points to the same string,
471  /// on others a new buffer is allocated on the stack using AkAlloca. This means
472  /// you must make sure that:
473  /// - The source string stays valid and unmodified for as long as you need the
474  /// AkOSChar string (for cases where they point to the same string)
475  /// - The AkOSChar string is used within this scope only -- for example, do NOT
476  /// return that string from a function (for cases where it is allocated on the stack)
477  #define CONVERT_OSCHAR_TO_WIDE( _osstring_, _wstring_ ) \
478  _wstring_ = (wchar_t*)AkAlloca((1+strlen(_osstring_)) * sizeof(wchar_t)); \
479  AKPLATFORM::AkCharToWideChar( _osstring_, (AkUInt32)(1 + strlen(_osstring_ )), _wstring_ )
480 
481  /// Converts a AkOSChar string into char string.
482  /// \remark On some platforms the AkOSChar string simply points to the same string,
483  /// on others a new buffer is allocated on the stack using AkAlloca. This means
484  /// you must make sure that:
485  /// - The source string stays valid and unmodified for as long as you need the
486  /// AkOSChar string (for cases where they point to the same string)
487  /// - The AkOSChar string is used within this scope only -- for example, do NOT
488  /// return that string from a function (for cases where it is allocated on the stack)
489  #define CONVERT_OSCHAR_TO_CHAR( _osstring_, _astring_ ) _astring_ = (char*)_osstring_
490 
491  /// Get the length, in characters, of a NULL-terminated AkUtf16 string
492  /// \return The length, in characters, of the specified string (excluding terminating NULL)
493  AkForceInline size_t AkUtf16StrLen( const AkUtf16* in_pStr )
494  {
495  return ( wcslen( in_pStr ) );
496  }
497 
498  /// Get the length, in characters, of a NULL-terminated AkOSChar string
499  /// \return The length, in characters, of the specified string (excluding terminating NULL)
500  AkForceInline size_t OsStrLen( const AkOSChar* in_pszString )
501  {
502  return ( strlen( in_pszString ) );
503  }
504 
505  /// AkOSChar version of sprintf().
506  #define AK_OSPRINTF snprintf
507 
508  /// Compare two NULL-terminated AkOSChar strings
509  /// \return
510  /// - < 0 if in_pszString1 < in_pszString2
511  /// - 0 if the two strings are identical
512  /// - > 0 if in_pszString1 > in_pszString2
513  /// \remark The comparison is case-sensitive
514  AkForceInline int OsStrCmp( const AkOSChar* in_pszString1, const AkOSChar* in_pszString2 )
515  {
516  return ( strcmp( in_pszString1, in_pszString2 ) );
517  }
518 
519  #define AK_UTF16_TO_WCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
520  #define AK_WCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
521  #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkWideCharToChar( in_pSrc, in_MaxSize, in_pdDest )
522  #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkWideCharToChar( in_pSrc, in_MaxSize, in_pdDest )
523  #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkCharToWideChar( in_pSrc, in_MaxSize, in_pdDest )
524  #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkCharToWideChar( in_pSrc, in_MaxSize, in_pdDest )
525 
526  // Use with AkOSChar.
527  #define AK_PATH_SEPARATOR ("/")
528  #define AK_LIBRARY_PREFIX ("")
529  #define AK_DYNAMIC_LIBRARY_EXTENSION (".prx")
530 
531 }
532 
533 #ifdef AK_ENABLE_INSTRUMENT
534 
535 #include <perf.h>
536 #include <sdk_version.h>
537 #if SCE_ORBIS_SDK_VERSION >= 0x04500000
538  #include <razorcpu.h>
539  #ifndef SCE_RAZOR_MARKER_DISABLE_HUD
540  #define SCE_RAZOR_MARKER_DISABLE_HUD 0
541  #endif
542 #endif
543 
544 class AkInstrumentScope
545 {
546 public:
547  inline AkInstrumentScope( const char *in_pszZoneName )
548  {
549  sceRazorCpuPushMarkerStatic( in_pszZoneName, 0, SCE_RAZOR_MARKER_DISABLE_HUD );
550  }
551 
552  inline ~AkInstrumentScope()
553  {
554  sceRazorCpuPopMarker();
555  }
556 };
557 
558 #define AK_INSTRUMENT_BEGIN( _zone_name_ ) sceRazorCpuPushMarkerStatic( text, 0, SCE_RAZOR_MARKER_DISABLE_HUD )
559 #define AK_INSTRUMENT_BEGIN_C( _color_, _zone_name_ ) sceRazorCpuPushMarkerStatic( text, _color_, SCE_RAZOR_MARKER_DISABLE_HUD )
560 #define AK_INSTRUMENT_END( _zone_name_ ) sceRazorCpuPopMarker()
561 #define AK_INSTRUMENT_SCOPE( _zone_name_ ) AkInstrumentScope akInstrumentScope_##__LINE__(_zone_name_)
562 
563 #define AK_INSTRUMENT_IDLE_BEGIN( _zone_name_ )
564 #define AK_INSTRUMENT_IDLE_END( _zone_name_ )
565 #define AK_INSTRUMENT_IDLE_SCOPE( _zone_name_ )
566 
567 #define AK_INSTRUMENT_STALL_BEGIN( _zone_name_ )
568 #define AK_INSTRUMENT_STALL_END( _zone_name_ )
569 #define AK_INSTRUMENT_STALL_SCOPE( _zone_name_ )
570 
571 #define AK_INSTRUMENT_THREAD_START( _thread_name_ )
572 
573 #endif // AK_ENABLE_INSTRUMENT
574 
575 #endif // _AK_PLATFORM_FUNCS_H_
void AkSignalEvent(const AkEvent &in_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:109
AkForceInline AkInt32 AkUtf8ToWideChar(const char *in_pszUtf8String, AkUInt32 in_uiOutBufferSize, void *io_pvUnicodeStringBuffer)
String conversion helper.
Definition: AkPlatformFuncs.h:404
AkForceInline int OsStrCmp(const AkOSChar *in_pszString1, const AkOSChar *in_pszString2)
Definition: AkPlatformFuncs.h:514
#define AK_THREAD_PRIORITY_NORMAL
Definition: AkPlatformFuncs.h:78
#define AK_THREAD_DEFAULT_SCHED_POLICY
Definition: AkPlatformFuncs.h:77
The operation was successful.
Definition: AkTypes.h:129
void AkMemoryBarrier()
Definition: AkPlatformFuncs.h:91
ScePthread AkThread
Thread handle.
Definition: AkTypes.h:100
AkForceInline void SafeStrCat(wchar_t *in_pDest, const wchar_t *in_pSrc, size_t in_uDestMaxNumChars)
Safe unicode string concatenation.
Definition: AkPlatformFuncs.h:428
AKRESULT
Standard function call result.
Definition: AkTypes.h:126
AkForceInline AKRESULT AkCreateNamedEvent(AkEvent &out_event, const char *in_szName)
Definition: AkPlatformFuncs.h:130
void AkDestroyEvent(AkEvent &io_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:78
void *(* AkThreadRoutine)(void *lpThreadParameter)
Thread routine.
Definition: AkTypes.h:102
AkInt32 AkInterlockedDecrement(AkAtomic32 *pValue)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:76
wchar_t AkUtf16
Definition: AkTypes.h:107
AkForceInline AkReal32 Elapsed(const AkInt64 &in_iNow, const AkInt64 &in_iStart)
Returns a time range in milliseconds, using the sound engine's updated count->milliseconds ratio.
Definition: AkPlatformFuncs.h:366
AkForceInline void AkMemCpy(void *pDest, const void *pSrc, AkUInt32 uSize)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:330
int nPriority
Thread priority.
Definition: AkPlatformFuncs.h:50
Audiokinetic namespace.
void OutputDebugMsg(const char *in_pszMsg)
Output a debug message on the console (Ansi string)
Definition: AkPlatformFuncs.h:57
ScePthread AkThreadID
Thread ID.
Definition: AkTypes.h:101
AkThreadID CurrentThread()
Returns the calling thread's ID.
Definition: AkPlatformFuncs.h:315
void AkClearEvent(AkEvent &out_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:49
The operation failed.
Definition: AkTypes.h:130
void AkWaitForEvent(AkEvent &in_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:98
void AkCreateThread(AkThreadRoutine pStartRoutine, void *pParams, const AkThreadProperties &in_threadProperties, AkThread *out_pThread, const char *)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:145
#define AKASSERT(Condition)
Definition: AkAssert.h:69
#define AkForceInline
Force inlining.
Definition: AkTypes.h:63
AkForceInline void UpdatePerformanceFrequency()
Platform Independent Helper.
Definition: AkPlatformFuncs.h:358
int32_t AkInt32
Signed 32-bit integer.
Definition: AkTypes.h:92
void PerformanceCounter(AkInt64 *out_piLastTime)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:106
AkForceInline void AkClearThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:218
AkForceInline void SafeStrCpy(wchar_t *in_pDest, const wchar_t *in_pSrc, size_t in_uDestMaxNumChars)
Safe unicode string copy.
Definition: AkPlatformFuncs.h:412
AkForceInline bool AkIsValidThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:212
#define AK_NULL_THREAD
Definition: AkPlatformFuncs.h:89
AkForceInline void AkSleep(AkUInt32 in_ulMilliseconds)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:321
#define AkMin(x1, x2)
Definition: AkPlatformFuncs.h:94
AkForceInline void AkMemSet(void *pDest, AkInt32 iVal, AkUInt32 uSize)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:336
AkForceInline AkInt32 AkWideCharToChar(const wchar_t *in_pszUnicodeString, AkUInt32 in_uiOutBufferSize, char *io_pszAnsiString)
String conversion helper.
Definition: AkPlatformFuncs.h:372
AKRESULT AkCreateEvent(AkEvent &out_event)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:55
AkReal32 g_fFreqRatio
Definition: AkPlatformFuncs.h:71
AkInt32 AkAtomic32
Signed 32-bit integer - Atomic Declaration.
Definition: AkTypes.h:57
#define NULL
Definition: AkTypes.h:49
int64_t AkInt64
Signed 64-bit integer.
Definition: AkTypes.h:93
#define AKVERIFY(x)
Definition: AkAssert.h:71
void PerformanceFrequency(AkInt64 *out_piFreq)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:43
SceKernelCpumask dwAffinityMask
Affinity mask.
Definition: AkPlatformFuncs.h:51
int uSchedPolicy
Thread scheduling policy.
Definition: AkPlatformFuncs.h:53
AkForceInline bool AkIsValidEvent(const AkEvent &in_event)
Definition: AkPlatformFuncs.h:125
AkForceInline void AkGetDefaultThreadProperties(AkThreadProperties &out_threadProperties)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:237
AkForceInline AkInt32 AkCharToWideChar(const char *in_pszAnsiString, AkUInt32 in_uiOutBufferSize, void *io_pvUnicodeStringBuffer)
String conversion helper.
Definition: AkPlatformFuncs.h:389
AkForceInline void AkCloseThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:224
AkForceInline void AkWaitForSingleThread(AkThread *in_pThread)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:308
bool AkInterlockedCompareExchange(volatile AkAtomic32 *io_pDest, AkInt32 in_newValue, AkInt32 in_expectedOldVal)
Definition: AkPlatformFuncs.h:81
AkForceInline size_t OsStrLen(const AkOSChar *in_pszString)
Definition: AkPlatformFuncs.h:500
uint32_t AkUInt32
Unsigned 32-bit integer.
Definition: AkTypes.h:79
semaphore_t AkEvent
Definition: AkTypes.h:80
#define AK_DEFAULT_STACK_SIZE
Definition: AkPlatformFuncs.h:76
size_t uStackSize
Thread stack size.
Definition: AkPlatformFuncs.h:52
float AkReal32
32-bit floating point
Definition: AkTypes.h:97
char AkOSChar
Generic character string.
Definition: AkTypes.h:95
size_t AkUtf16StrLen(const AkUtf16 *in_pStr)
Definition: AkPlatformFuncs.h:493
AkInt64 AkAtomic64
Signed 64-bit integer - Atomic Declaration.
Definition: AkTypes.h:58
AkInt32 AkInterlockedIncrement(AkAtomic32 *pValue)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:70
#define AK_THREAD_AFFINITY_DEFAULT
Definition: AkPlatformFuncs.h:83

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