Community Q&A

Where Wwise users help each other out!

Audiokinetic's Community Q&A is the forum where Wwise users ask and answer questions within the Wwise community. Contact Sales if your project requires a support plan.

UE4 Integration has crash in packaged game

0 votes

In using AkEvent without AkComponent in seqeuncer, Travelling other level with cancelling Event occures game crash in packaged game.

Because PostEvent with DUMMY_GAMEOBJ have not registered to the CallbackManager, CancelEventCallbackCookie in SectionBeingDestroyed is ignored. 
*see FAkAudioDevice::PostEvent

I fixed this issue with following code.

*** Wwise/Source/AkAudio/Private/AkAudioDevice.cpp
***************
*** 1125,1130 ****
--- 1125,1157 ----
  return PostEvent(in_pEvent->GetName(), in_pActor, in_uFlags, in_pfnCallback, in_pCookie, in_bStopWhenOwnerDestroyed);
  }
 
+ //---------- begin code ------------- 
+ template<typename FCreateCallbackPackage>
+ AkPlayingID FAkAudioDevice::PostEvent(
+ const FString& in_EventName,
+ AkGameObjectID gameObjID,
+ FCreateCallbackPackage CreateCallbackPackage
+ )
+ {
+ AkPlayingID playingID = AK_INVALID_PLAYING_ID;
+ 
+ if (m_bSoundEngineInitialized && CallbackManager)
+ {
+ auto pPackage = CreateCallbackPackage(gameObjID);
+ if (pPackage)
+ {
+ playingID = AK::SoundEngine::PostEvent(TCHAR_TO_AK(*in_EventName), gameObjID, pPackage->uUserFlags | AK_EndOfEvent, &FAkComponentCallbackManager::AkComponentCallback, pPackage);
+ if (playingID == AK_INVALID_PLAYING_ID)
+ {
+ CallbackManager->RemoveCallbackPackage(pPackage, gameObjID);
+ }
+ }
+ }
+ 
+ return playingID;
+ }
+ //---------- end code ------------- 
+ 
  /**
   * Post an event to ak soundengine by name
   *
***************
*** 1150,1156 ****
--- 1177,1189 ----
  if (!in_pActor)
  {
  // PostEvent must be bound to a game object. Passing DUMMY_GAMEOBJ as default game object.
+ #if 1 
+ return PostEvent(in_EventName, DUMMY_GAMEOBJ, [in_pfnCallback, in_pCookie, in_uFlags, this](AkGameObjectID gameObjID) {
+ return CallbackManager->CreateCallbackPackage(in_pfnCallback, in_pCookie, in_uFlags, gameObjID);
+ });
+ #else
  return AK::SoundEngine::PostEvent(TCHAR_TO_AK(*in_EventName), DUMMY_GAMEOBJ, in_uFlags, in_pfnCallback, in_pCookie);
+ #endif
  }
  else if (!in_pActor->IsActorBeingDestroyed() && !in_pActor->IsPendingKill())
  {
*** Wwise/Source/AkAudio/Public/AkAudioDevice.h
***************
*** 1225,1230 ****
--- 1225,1239 ----
      FCreateCallbackPackage CreateCallbackPackage
    );
 
+ //----------------BEGIN CODE
+   template<typename FCreateCallbackPackage>
+   AkPlayingID PostEvent(
+     const FString& in_EventName,
+     AkGameObjectID gameObjID,
+     FCreateCallbackPackage CreateCallbackPackage
+   );
+ 
+ //----------------END CODE
 
    // Overload allowing to modify StopWhenOwnerDestroyed after getting the AkComponent
    AKRESULT GetGameObjectID(AActor * in_pActor, AkGameObjectID& io_GameObject, bool in_bStopWhenOwnerDestroyed );

 

asked Feb 8 in General Discussion by Takashi S. (100 points)

Please sign-in or register to answer this question.

...