Hi guys, I am working on a music game project and I need to have a metronome that constantly keeps track of time. I had to implement my own metronome because I need high resolution and I could not implement anything that would give me millisecond accuracy in Unreal. I got my metronome to work properly from a seperate thread I created. But any time I want some audio to play, I get this specific crash.
Assertion failed: IsInGameThread() [File:D:/build/++UE5/Sync/Engine/Source/Runtime/Engine/Private/AudioDevice.cpp] [Line: 5278]
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_ThirdPersonTest!AThirdPersonTestGameMode::ThreadCallback() [S:\UE5Projects\ThirdPersonTest\Source\ThirdPersonTest\ThirdPersonTestGameMode.cpp:81]
UnrealEditor_ThirdPersonTest!SetPromise<TUniqueFunction<void __cdecl(void)> &>() [S:\UnrealEngine\UE_5.0EA\Engine\Source\Runtime\Core\Public\Async\Async.h:57]
UnrealEditor_ThirdPersonTest!TAsyncRunnable::Run() [S:\UnrealEngine\UE_5.0EA\Engine\Source\Runtime\Core\Public\Async\Async.h:436]
UnrealEditor_Core
UnrealEditor_Core
kernel32
ntdll
I guessed that the problem is me calling the play function from any thread other than the game thread. Even if I define the audio play function in a class that exists solely within the game thread, the game (not very surprisingly) crashes with the same crash report. But I have to have my own thread that keeps track of the time and decides when to play sounds. How do you guys think I should approach this issue? Thanks a lot in advance.