GetActiveSounds() call error!

295470-ccccccccccccccc.png

GEngine->GetActiveAudioDevice()->GetActiveSounds();

When played in the editor and in the new window, the above function calls work.

But there’s an error crash in the stand-alone game.

What’s the reason?

4.24.1 Launcher version engine in use.

Assertion failed shows the bool condition that was expected (like if statement), if expected condition fails it crash as it expected to cause UE4 go unstable without that condition meet, this way you won’t get hard to debug crashes, insted you got this discriptive error that say a lot. Most crashes in UE4 is cause by assertion fail so it important to understand it (but you not need to use in your code it you don’t want to) especially if you do C++, you can read about it here

The failed condition is very simple to understand IsInAudioThread() means that you made a call to function that only works in audio thread. You can run code on audio thread from game thread using RunCommandOnAudioThread function and nested functions

FAudioThread::RunCommandOnAudioThread([VarablesToPass,SeperatedByComma]()
	{
		//your audio thread code here
	}
);

you can also pass “this” btw

Not sure if it locks game thread, if it’s not then it means any set you do in audio thread won’t be ready after you call this command as that code is yet to be executed in audio thread. It is recommended to finish the job in audio thread if possible or you can always do FAudioThread::RunCommandOnGameThread on audio thread to pass things back to game thread