123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606 |
- #include "Wwise/WwiseGlobalCallbacks.h"
- #include "Wwise/API/WwiseSoundEngineAPI.h"
- #include "Wwise/Stats/Concurrency.h"
- #include "AkUnrealHelper.h"
- FWwiseGlobalCallbacks::~FWwiseGlobalCallbacks()
- {
- if (UNLIKELY(bInitialized))
- {
- UE_LOG(LogWwiseConcurrency, Error, TEXT("GlobalCallbacks not terminated at destruction."));
- }
- }
- bool FWwiseGlobalCallbacks::Initialize()
- {
- if (UNLIKELY(bInitialized))
- {
- UE_LOG(LogWwiseConcurrency, Fatal, TEXT("Global Callbacks already initialized"));
- return false;
- }
- auto* SoundEngine = IWwiseSoundEngineAPI::Get();
- if (UNLIKELY(!SoundEngine))
- {
- UE_LOG(LogWwiseConcurrency, Fatal, TEXT("Could not implement callbacks."));
- return false;
- }
- bInitialized = true;
- bool bResult = true;
- AKRESULT Result;
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnRegisterCallbackStatic, AkGlobalCallbackLocation_Register, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `Register` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnBeginCallbackStatic, AkGlobalCallbackLocation_Begin, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `Begin` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnPreProcessMessageQueueForRenderCallbackStatic, AkGlobalCallbackLocation_PreProcessMessageQueueForRender, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `PreProcessMessageQueueForRender` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnPostMessagesProcessedCallbackStatic, AkGlobalCallbackLocation_PostMessagesProcessed, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `PostMessagesProcessed` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnBeginRenderCallbackStatic, AkGlobalCallbackLocation_BeginRender, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `BeginRender` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnEndRenderCallbackStatic, AkGlobalCallbackLocation_EndRender, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `EndRender` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnEndCallbackStatic, AkGlobalCallbackLocation_End, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `End` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnTermCallbackStatic, AkGlobalCallbackLocation_Term, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `Term` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnMonitorCallbackStatic, AkGlobalCallbackLocation_Monitor, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `Monitor` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnMonitorRecapCallbackStatic, AkGlobalCallbackLocation_MonitorRecap, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `MonitorRecap` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnInitCallbackStatic, AkGlobalCallbackLocation_Init, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `Init` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnSuspendCallbackStatic, AkGlobalCallbackLocation_Suspend, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `Suspend` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- Result = SoundEngine->RegisterGlobalCallback(&FWwiseGlobalCallbacks::OnWakeupFromSuspendCallbackStatic, AkGlobalCallbackLocation_WakeupFromSuspend, (void*)this);
- UE_CLOG(Result != AK_Success, LogWwiseConcurrency, Error, TEXT("Cannot Register `WakeupFromSuspend` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- bResult = bResult && (Result == AK_Success);
- return bResult;
- }
- void FWwiseGlobalCallbacks::Terminate()
- {
- if (!bInitialized)
- {
- return;
- }
- auto* SoundEngine = IWwiseSoundEngineAPI::Get();
- if (UNLIKELY(!SoundEngine))
- {
- return;
- }
- bInitialized = false;
- AKRESULT Result;
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnRegisterCallbackStatic, AkGlobalCallbackLocation_Register);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `Register` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnBeginCallbackStatic, AkGlobalCallbackLocation_Begin);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `Begin` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnPreProcessMessageQueueForRenderCallbackStatic, AkGlobalCallbackLocation_PreProcessMessageQueueForRender);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `PreProcessMessageQueueForRender` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnPostMessagesProcessedCallbackStatic, AkGlobalCallbackLocation_PostMessagesProcessed);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `PostMessagesProcessed` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnBeginRenderCallbackStatic, AkGlobalCallbackLocation_BeginRender);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `BeginRender` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnEndRenderCallbackStatic, AkGlobalCallbackLocation_EndRender);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `EndRender` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnEndCallbackStatic, AkGlobalCallbackLocation_End);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `End` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnTermCallbackStatic, AkGlobalCallbackLocation_Term);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `Term` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnMonitorCallbackStatic, AkGlobalCallbackLocation_Monitor);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `Monitor` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnMonitorRecapCallbackStatic, AkGlobalCallbackLocation_MonitorRecap);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `MonitorRecap` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnInitCallbackStatic, AkGlobalCallbackLocation_Init);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `Init` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnSuspendCallbackStatic, AkGlobalCallbackLocation_Suspend);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `Suspend` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- Result = SoundEngine->UnregisterGlobalCallback(&FWwiseGlobalCallbacks::OnWakeupFromSuspendCallbackStatic, AkGlobalCallbackLocation_WakeupFromSuspend);
- UE_CLOG(Result != AK_Success && Result != AK_InvalidParameter, LogWwiseConcurrency, Verbose, TEXT("Cannot Unregister `WakeupFromSuspend` Callback: %d (%s)"), Result, AkUnrealHelper::GetResultString(Result));
- }
- void FWwiseGlobalCallbacks::RegisterSync(FSyncFunction&& InFunction)
- {
- RegisterQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::RegisterCompletion(FCompletionPromise&& Promise)
- {
- RegisterAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForRegister()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForRegister"));
- FEventRef Event;
- RegisterAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::BeginSync(FSyncFunction&& InFunction)
- {
- BeginQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::BeginCompletion(FCompletionPromise&& Promise)
- {
- BeginAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForBegin()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForBegin"));
- FEventRef Event;
- BeginAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::PreProcessMessageQueueForRenderSync(FSyncFunction&& InFunction)
- {
- PreProcessMessageQueueForRenderQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::PreProcessMessageQueueForRenderCompletion(FCompletionPromise&& Promise)
- {
- PreProcessMessageQueueForRenderAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForPreProcessMessageQueueForRender()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForPreProcessMessageQueueForRender"));
- FEventRef Event;
- PreProcessMessageQueueForRenderAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::PostMessagesProcessedSync(FSyncFunction&& InFunction)
- {
- PostMessagesProcessedQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::PostMessagesProcessedCompletion(FCompletionPromise&& Promise)
- {
- PostMessagesProcessedAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForPostMessagesProcessed()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForPostMessagesProcessed"));
- FEventRef Event;
- PostMessagesProcessedAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::BeginRenderSync(FSyncFunction&& InFunction)
- {
- BeginRenderQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::BeginRenderCompletion(FCompletionPromise&& Promise)
- {
- BeginRenderAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForBeginRender()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForBeginRender"));
- FEventRef Event;
- BeginRenderAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::EndRenderSync(FSyncFunction&& InFunction)
- {
- EndRenderQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::EndRenderCompletion(FCompletionPromise&& Promise)
- {
- EndRenderAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForEndRender()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForEndRender"));
- FEventRef Event;
- EndRenderAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::EndSync(FSyncFunction&& InFunction)
- {
- EndQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::EndCompletion(FCompletionPromise&& Promise, int Count)
- {
- if (Count <= 0)
- {
- return Promise.EmplaceValue();
- }
- EndAsync([Promise = MoveTemp(Promise), Count = Count - 1]() mutable
- {
- auto* WwiseGlobalCallbacks = FWwiseGlobalCallbacks::Get();
- WwiseGlobalCallbacks->EndCompletion(MoveTemp(Promise), Count);
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForEnd()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForEnd"));
- FEventRef Event;
- EndAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::TermSync(FSyncFunction&& InFunction)
- {
- TermQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::TermCompletion(FCompletionPromise&& Promise)
- {
- TermAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForTerm()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForTerm"));
- FEventRef Event;
- TermAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::MonitorSync(FSyncFunction&& InFunction)
- {
- MonitorQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::MonitorCompletion(FCompletionPromise&& Promise)
- {
- MonitorAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForMonitor()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForMonitor"));
- FEventRef Event;
- MonitorAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::MonitorRecapSync(FSyncFunction&& InFunction)
- {
- MonitorRecapQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::MonitorRecapCompletion(FCompletionPromise&& Promise)
- {
- MonitorRecapAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForMonitorRecap()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForMonitorRecap"));
- FEventRef Event;
- MonitorRecapAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::InitSync(FSyncFunction&& InFunction)
- {
- InitQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::InitCompletion(FCompletionPromise&& Promise)
- {
- InitAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForInit()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForInit"));
- FEventRef Event;
- InitAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::SuspendSync(FSyncFunction&& InFunction)
- {
- SuspendQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::SuspendCompletion(FCompletionPromise&& Promise)
- {
- SuspendAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForSuspend()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForSuspend"));
- FEventRef Event;
- SuspendAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::WakeupFromSuspendSync(FSyncFunction&& InFunction)
- {
- WakeupFromSuspendQueue.SyncDefer(MoveTemp(InFunction));
- }
- void FWwiseGlobalCallbacks::WakeupFromSuspendCompletion(FCompletionPromise&& Promise)
- {
- WakeupFromSuspendAsync([Promise = MoveTemp(Promise)]() mutable
- {
- Promise.EmplaceValue();
- return EWwiseDeferredAsyncResult::Done;
- });
- }
- void FWwiseGlobalCallbacks::WaitForWakeupFromSuspend()
- {
- SCOPED_WWISECONCURRENCY_EVENT_4(TEXT("FWwiseGlobalCallbacks::WaitForWakeupFromSuspend"));
- FEventRef Event;
- WakeupFromSuspendAsync([&Event]() {Event->Trigger(); return EWwiseDeferredAsyncResult::Done; });
- Event->Wait();
- Event->Reset();
- }
- void FWwiseGlobalCallbacks::OnRegisterCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- RegisterQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnBeginCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- BeginQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnPreProcessMessageQueueForRenderCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- PreProcessMessageQueueForRenderQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnPostMessagesProcessedCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- PostMessagesProcessedQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnBeginRenderCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- BeginRenderQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnEndRenderCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- EndRenderQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnEndCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- EndQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnTermCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- TermQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnMonitorCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- MonitorQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnMonitorRecapCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- MonitorRecapQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnInitCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- InitQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnSuspendCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- SuspendQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnWakeupFromSuspendCallback(AK::IAkGlobalPluginContext* in_pContext)
- {
- WakeupFromSuspendQueue.Run(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnRegisterCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnRegisterCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnBeginCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnBeginCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnPreProcessMessageQueueForRenderCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnPreProcessMessageQueueForRenderCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnPostMessagesProcessedCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnPostMessagesProcessedCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnBeginRenderCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnBeginRenderCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnEndRenderCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnEndRenderCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnEndCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnEndCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnTermCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnTermCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnMonitorCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnMonitorCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnMonitorRecapCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnMonitorRecapCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnInitCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnInitCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnSuspendCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnSuspendCallback(in_pContext);
- }
- void FWwiseGlobalCallbacks::OnWakeupFromSuspendCallbackStatic(AK::IAkGlobalPluginContext* in_pContext,
- AkGlobalCallbackLocation in_eLocation, void* in_pCookie)
- {
- static_cast<FWwiseGlobalCallbacks*>(in_pCookie)->OnWakeupFromSuspendCallback(in_pContext);
- }
|