Creating an audio stream

Hello

I’m trying to use the new audio engine (AudioMixer) to open an output-only audio stream on an Android device (Oculus Quest). There isn’t much documentation on this but after having read the API reference and gone through the source code a bit I tried doing this in an Actor class and adding it to the level.

void AAudioStream::BeginPlay() 
{
     Super::BeginPlay();
     Audio::FMixerDevice* mixerDevice = new Audio::FMixerDevice(new Audio::FMixerPlatformAndroid());
     mixerDevice->InitSoundSubmixes();
     mixerDevice->InitializeHardware();
} 

This makes the game crash right away with this callstack:


Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/Core/Public\Containers/Array.h] [Line: 611]

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: Array index out of bounds: 0 from an array of size 0

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F83F300C4 (0x000000000437C0C4) libUE4.so!FDebug::CheckVerifyFailedImpl(char const*, char const*, int, char16_t const*, ...)

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F8570ABCC (0x0000000005B56BCC) libUE4.so!Audio::FMixerDevice::OnProcessAudioStream(TArray >&)

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F8570D6D4 (0x0000000005B596D4) libUE4.so!non-virtual thunk to Audio::FMixerDevice::OnProcessAudioStream(TArray >&) 

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F857010E0 (0x0000000005B4D0E0) libUE4.so!Audio::FOutputBuffer::MixNextBuffer()

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F85702488 (0x0000000005B4E488) libUE4.so!Audio::IAudioMixerPlatformInterface::RunInternal() 

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F85702620 (0x0000000005B4E620) libUE4.so!Audio::IAudioMixerPlatformInterface::Run()

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F83E3E6A4 (0x000000000428A6A4) libUE4.so!FRunnableThreadPThread::Run()

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007F83DC067C (0x000000000420C67C) libUE4.so!FRunnableThreadPThread::_ThreadProc(void*) 

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007FAA4FDDAC (0x0000000000075DAC) libc.so![Unknown]()

LogPlayLevel: Error:   08-23 15:24:20.498 32512 32697 D UE4     : [2019.08.23-13.24.20:498][  0]LogAndroid: Error: [Callstack] 0x0000007FAA4A61C8 (0x000000000001E1C8) libc.so![Unknown]()


It seems like some array is not initialized but I can’t find out where. Does anyone see where? Any help would be great! Alternative solutions too.

Sourcecode to FMixerPlatformAndroid and FMixerDevice

I managed to solve it using the information her