Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

UE4 AudioInputComponent loses its callback binding after a short time

+2 votes
Currently I'm trying to hook Vivox voice chat into the Wwise AudioInputComponent. Everything is working for short periods of time, but the sound cuts out after a little while. I currently have it set up to call PostAssociatedAudioInputEvent in the BeginPlay function and this successfully causes FillSamplesBuffer to be called for a while, but after roughly 30 seconds to a minute it will simply stop calling FillSamplesBuffer. After some debugging, I discovered that the block of code in AkAudioInputManager that checks whether SamplesCallback is bound will suddenly fail the check at this point, so it appears that the callback is being unbound, but I never return false in the callback so it should always continue.

I had a similar problem with a different delegate that I was using to intercept the Vivox audio, so I'm wondering if this might be the same issue. In that case, I was told by Epic that I shouldn't be using CreateUObject because the delegate was called in a different thread and if it was called while the main thread was doing garbage collection then that could cause it to become unbound. Is it possible something similar is occurring with the AudioInputComponent? I noticed that it also utilizes CreateUObject when it sets up the callbacks and I believe FillSamplesBuffer is called in a different thread as well.

Any help would be appreciated.
asked May 14, 2020 in General Discussion by Joshua S. (120 points)

1 Answer

0 votes
We noticed the same behavior in our project as well when trying to support input from Vivox as well as audio played through the Ureal Media Player. We patched it up by using FAkGlobalAudioInputDelegate::CreateLambda instead of CreateUObject. The lambda won't get accidentally unbound during garbage collection but it may require manual clean up depending on your implementation to ensure nothing tries to call your functions on dead objects.
answered Sep 2, 2020 by Alex P. (180 points)