Adding Custom C++ BP Function Not Working as Expected

Hey,

I’m pretty new to C++ so I apologize that this is probably extremely basic. I come from entirely Blueprint programming. I’m trying to add a custom blueprint function that gives me an array of the names of available audio output devices in Windows. But when I add the blueprint function to use it, I get the attached error. I need this function to work in any blueprint class, there is no AudioDeviceOutput class, just the function I’m making.

Here is my code.

header


#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "XAudio2Device.h"
#include "AudioDeviceOutput.generated.h"


/**
 * 
 */
UCLASS()
class MYGAME_API UAudioDeviceOutput : public UBlueprintFunctionLibrary
{
    GENERATED_BODY() public:

        UFUNCTION(BlueprintPure, Category = "Custom", meta = (Keywords = "GetAudioOutputDevices"))
            TArray<FString> GetAudioDevices();
};

cpp


#include "AudioDeviceOutput.h"

TArray<FString> UAudioDeviceOutput::GetAudioDevices()
{
    FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice();
    TArray<FString> AudioDeviceList;
    AudioDevice->GetAudioDeviceList(AudioDeviceList);
    return AudioDeviceList;
}