バージョン

menu_open
Wwise SDK 2021.1.14
AkSyncCaller.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: v2021.1.14 Build: 6590
25  Copyright (c) 2006-2023 Audiokinetic Inc.
26 *******************************************************************************/
27 
28 // AkSyncLoader.h
29 
30 /// \file
31 /// Class for synchronous calls of asynchronous models
32 
33 #ifndef _AK_SYNC_CALLER_H_
34 #define _AK_SYNC_CALLER_H_
35 
37 
38 namespace AK
39 {
40  namespace SoundEngine
41  {
42  /// AkSyncLoader: Init to create a sync event, call the asynchronous method, passing
43  /// it the address of this object as the cookie, then call Wait.
44  class AkSyncCaller
45  {
46  public:
47  /// Initialize.
49  {
50  if ( AKPLATFORM::AkCreateEvent( m_hEvent ) != AK_Success )
51  {
52  AKASSERT( !"Could not create synchronization event" );
53  return AK_Fail;
54  }
55  return AK_Success;
56  }
57 
58  /// Wait until the async function calls its callback.
59  AKRESULT Wait( AKRESULT in_eResult )
60  {
61  if ( in_eResult != AK_Success )
62  {
63  AKPLATFORM::AkDestroyEvent( m_hEvent );
64  return in_eResult;
65  }
66 
67  // Task queueing successful. Block until completion.
68  AKPLATFORM::AkWaitForEvent( m_hEvent );
69  AKPLATFORM::AkDestroyEvent( m_hEvent );
70 
71  return m_eResult;
72  }
73 
74  /// Call this from callback to release blocked thread.
75  inline void Done() { AKPLATFORM::AkSignalEvent( m_hEvent ); }
76 
77  AKRESULT m_eResult; ///< Operation result
78 
79  private:
80  AkEvent m_hEvent; ///< Sync event
81  };
82  }
83 }
84 
85 #endif // _AK_SYNC_CALLER_H_
AKRESULT Init()
Initialize.
Definition: AkSyncCaller.h:48
Audiokinetic namespace
@ AK_Fail
The operation failed.
Definition: AkTypes.h:135
void Done()
Call this from callback to release blocked thread.
Definition: AkSyncCaller.h:75
semaphore_t AkEvent
Definition: AkTypes.h:73
void AkWaitForEvent(AkEvent &in_event)
Platform Independent Helper
Definition: AkPlatformFuncs.h:80
AKRESULT
Standard function call result.
Definition: AkTypes.h:132
@ AK_Success
The operation was successful.
Definition: AkTypes.h:134
void AkDestroyEvent(AkEvent &io_event)
Platform Independent Helper
Definition: AkPlatformFuncs.h:70
#define AKASSERT(Condition)
Definition: AkAssert.h:76
AKRESULT AkCreateEvent(AkEvent &out_event)
Platform Independent Helper
Definition: AkPlatformFuncs.h:58
AKRESULT m_eResult
Operation result
Definition: AkSyncCaller.h:77
void AkSignalEvent(const AkEvent &in_event)
Platform Independent Helper
Definition: AkPlatformFuncs.h:87
AKRESULT Wait(AKRESULT in_eResult)
Wait until the async function calls its callback.
Definition: AkSyncCaller.h:59

このページはお役に立ちましたか?

サポートは必要ですか?

ご質問や問題、ご不明点はございますか?お気軽にお問い合わせください。

サポートページをご確認ください

あなたのプロジェクトについて教えてください。ご不明な点はありませんか。

プロジェクトを登録していただくことで、ご利用開始のサポートをいたします。

Wwiseからはじめよう