版本
menu_open
link
目标平台:
Wwise SDK 2018.1.11
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  Version: <VERSION> Build: <BUILDNUMBER>
25  Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
26 *******************************************************************************/
27 
28 #pragma once
29 
32 
33 //#include <sys/atomics.h>
34 #include <time.h>
35 #include <stdlib.h>
36 #include <stdio.h>
37 
38 namespace AKPLATFORM
39 {
40  // Atomic Operations
41  // ------------------------------------------------------------------
42 
43  /// Platform Independent Helper
45  {
46  return __sync_add_and_fetch(pValue,1);
47  }
48 
49  /// Platform Independent Helper
51  {
52  return __sync_sub_and_fetch(pValue,1);
53  }
54 
55  AkForceInline bool AkInterlockedCompareExchange(volatile AkAtomic32* io_pDest, AkInt32 in_newValue, AkInt32 in_expectedOldVal)
56  {
57  return __sync_bool_compare_and_swap(io_pDest, in_expectedOldVal, in_newValue);
58  }
59 
60  AkForceInline bool AkInterlockedCompareExchange(volatile AkAtomic64* io_pDest, AkInt64 in_newValue, AkInt64 in_expectedOldVal)
61  {
62  return __sync_bool_compare_and_swap(io_pDest, in_expectedOldVal, in_newValue);
63  }
64 
65  inline void AkMemoryBarrier()
66  {
67  __sync_synchronize();
68  }
69 
70  // Time functions
71  // ------------------------------------------------------------------
72 
73  /// Platform Independent Helper
74  inline void PerformanceCounter( AkInt64 * out_piLastTime )
75  {
76  struct timespec clockNow;
77  clock_gettime(CLOCK_MONOTONIC, &clockNow);
78  *out_piLastTime = ((clockNow.tv_sec + clockNow.tv_nsec/ 1000000000.0) * CLOCKS_PER_SEC);
79  }
80 
81  /// Platform Independent Helper
82  inline void PerformanceFrequency( AkInt64 * out_piFreq )
83  {
84  // TO DO ANDROID ... is there something better
85  *out_piFreq = CLOCKS_PER_SEC;
86  }
87 
88  template<class destType, class srcType>
89  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 *) )
90  {
91  size_t i;
92  size_t lenToCopy = srcStrLen(in_pSrc);
93 
94  lenToCopy = (lenToCopy > in_MaxSize-1) ? in_MaxSize-1 : lenToCopy;
95  for(i = 0; i < lenToCopy; i++)
96  {
97  in_pdDest[i] = (destType) in_pSrc[i];
98  }
99  in_pdDest[lenToCopy] = (destType)0;
100 
101  return lenToCopy;
102  }
103 
104  #define CONVERT_UTF16_TO_CHAR( _astring_, _charstring_ ) \
105  _charstring_ = (char*)AkAlloca( (1 + AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)) * sizeof(char) ); \
106  AK_UTF16_TO_CHAR( _charstring_, (const AkUtf16*)_astring_, AKPLATFORM::AkUtf16StrLen((const AkUtf16*)_astring_)+1 )
107 
108  #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
109  #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, strlen, AKPLATFORM::AkUtf16StrLen )
110  #define AK_UTF16_TO_WCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, wcslen, AKPLATFORM::AkUtf16StrLen )
111  #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen )
112  #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, strlen )
113  #define AK_WCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkSimpleConvertString( in_pdDest, in_pSrc, in_MaxSize, AKPLATFORM::AkUtf16StrLen, wcslen )
114 
115  /// Stack allocations.
116  #define AkAlloca( _size_ ) __builtin_alloca( _size_ )
117 }
void AkMemoryBarrier()
Definition: AkPlatformFuncs.h:91
AkInt32 AkInterlockedDecrement(AkAtomic32 *pValue)
Platform Independent Helper
Definition: AkPlatformFuncs.h:76
#define AkForceInline
Force inlining
Definition: AkTypes.h:63
int32_t AkInt32
Signed 32-bit integer
Definition: AkTypes.h:92
void PerformanceCounter(AkInt64 *out_piLastTime)
Platform Independent Helper
Definition: AkPlatformFuncs.h:106
size_t AkSimpleConvertString(destType *in_pdDest, const srcType *in_pSrc, size_t in_MaxSize, size_t destStrLen(const destType *), size_t srcStrLen(const srcType *))
Definition: AkPlatformFuncs.h:113
AkInt32 AkAtomic32
Signed 32-bit integer - Atomic Declaration
Definition: AkTypes.h:57
int64_t AkInt64
Signed 64-bit integer
Definition: AkTypes.h:93
void PerformanceFrequency(AkInt64 *out_piFreq)
Platform Independent Helper
Definition: AkPlatformFuncs.h:43
bool AkInterlockedCompareExchange(volatile AkAtomic32 *io_pDest, AkInt32 in_newValue, AkInt32 in_expectedOldVal)
Definition: AkPlatformFuncs.h:81
AkInt64 AkAtomic64
Signed 64-bit integer - Atomic Declaration
Definition: AkTypes.h:58
AkInt32 AkInterlockedIncrement(AkAtomic32 *pValue)
Platform Independent Helper
Definition: AkPlatformFuncs.h:70

此页面对您是否有帮助?

需要技术支持?

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

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

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

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

开始 Wwise 之旅