IAudioMixerPlatformInterface

Abstract interface for mixer platform.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

AudioMixerCore

Header

/Engine/Source/Runtime/AudioMixerCore/Public/AudioMixer.h

Include

#include "AudioMixer.h"

Syntax

class IAudioMixerPlatformInterface :
    public FRunnable,
    public FSingleThreadRunnable,
    public Audio::IAudioMixerDeviceChangedLister

Remarks

Abstract interface for mixer platform.

Variables

Name Description

Protected variable

FEvent *

 

AudioFadeEvent

Event allows you to block until fadeout is complete.

Protected variable

FEvent *

 

AudioRenderEvent

The render thread sync event.

Protected variable

FRunnableThread...

 

AudioRenderThread

The audio render thread.

Protected variable

FAudioOutputStr...

 

AudioStreamInfo

The audio device stream info.

Protected variable

FThreadSafeBool

 

bFadedOut

Protected variable

FThreadSafeBool

 

bIsDeviceInitialized

Protected variable

FThreadSafeBool

 

bIsGeneratingAudio

Protected variable

FThreadSafeBool

 

bIsInDeviceSwap

This is used if we are attempting to TryLock on DeviceSwapCriticalSection, but a buffer callback is being called in the current thread.

Protected variable

FThreadSafeBool

 

bIsUsingNullDevice

Protected variable

FThreadSafeBool

 

bMoveAudioStreamToNewAudioDevice

Protected variable

FThreadSafeBool

 

bPerformingFade

Protected variable

bool

 

bWarnedBufferUnderrun

Whether or not we warned of buffer underrun.

Protected variable

TAtomic< int32 ...

 

CurrentBufferReadIndex

The buffer which is currently submitted to the output device (and is being read from).

Protected variable

TAtomic< int32 ...

 

CurrentBufferWriteIndex

The buffer which is currently being rendered to (or about to be rendered to).

Protected variable

FString

 

CurrentDeviceName

This device name can be used to override the default device being used on platforms that use strings to identify audio devices.

Protected variable

FCriticalSectio...

 

DeviceSwapCriticalSection

Critical Section used for times when we need the render loop to halt for the device swap.

Protected variable

FParam

 

FadeParam

Source param used to fade in and out audio device.

Protected variable

float

 

FadeVolume

The fade value. Used for fading in/out master audio.

Protected variable

FString

 

LastError

String containing the last generated error.

Protected variable

int32

 

NumOutputBuffers

The number of mixer buffers to queue on the output source voice.

Protected variable

FAudioMixerOpen...

 

OpenStreamParams

Protected variable

TArray< FOutput...

 

OutputBuffers

List of generated output buffers.

Protected variable

FAudioRenderTim...

 

RenderTimeAnalysis

Struct used to store render time analysis data.

Protected variable

FOutputBuffer

 

UnderrunBuffer

Special empty buffer for buffer underruns.

Constructors

Name Description

Public function

IAudioMixerPlatformInterface()

Constructor.

Destructors

Name Description

Public function Virtual

~IAudioMixerPlatformInterface()

Virtual destructor.

Functions

Name Description

Protected function

void

 

ApplyAttenuationInternal

(
    BufferType* BufferDataPtr,
    const int32 NumFrames
)

Protected function

void

 

ApplyMasterAttenuation()

Performs buffer fades for shutdown/startup of audio mixer.

Protected function

void

 

BeginGeneratingAudio()

Start generating audio from our mixer.

Public function Virtual

bool

 

CheckAudioDeviceChange()

Check if audio device changed if applicable. Return true if audio device changed.

Public function

bool

 

CloseAudioStream()

Closes the audio stream (if it's open).

Public function

ICompressedA...

 

CreateCompressedAudioInfo

(
    USoundWave* SoundWave
)

Creates a Compressed audio info class suitable for decompressing this SoundWave.

Public function Virtual Const

bool

 

DisablePCMAudioCaching()

Whether or not the platform disables caching of decompressed PCM data (i.e. to save memory on fixed memory platforms)

Public function Virtual

void

 

FadeIn()

Reset the fade state (use if reusing audio platform interface, e.g. in main audio device.

Public function Virtual

void

 

FadeOut()

Start a fadeout. Prevents pops during shutdown.

Public function Static

bool

 

GetChannelTypeAtIndex

(
    const int32 Index,
    EAudioMixerChannel::Type& OutType
)

Helper function to gets the channel map type at the given index.

Public function Virtual

FString

 

GetCurrentDeviceName()

Returns the name of the currently used audio device.

Public function

FString

 

GetDefaultDeviceName()

Return any optional device name defined in platform configuratio.

Public function Virtual Const

bool

 

GetDefaultOutputDeviceIndex

(
    uint32& OutDefaultDeviceIndex
)

Returns the default device index.

Public function Virtual

int32

 

GetIndexForDevice

(
    const FString& InDeviceName
)

Can be used to look up the current index for a given device name.

Public function Const

FString

 

GetLastError()

Returns the last error generated.

Public function Virtual

int32

 

GetNumFrames

(
    const int32 InNumReqestedFrames
)

Allows platforms to filter the requested number of frames to render.

Public function Virtual

bool

 

GetNumOutputDevices

(
    uint32& OutNumOutputDevices
)

Returns the number of output devices.

Public function

bool

 

GetOutputDeviceInfo

(
    const uint32 InDeviceIndex,
    FAudioPlatformDeviceInfo& OutInfo
)

Gets the device information of the given device index.

Public function Const

EAudioMixerP...

 

GetPlatformApi()

Returns the platform API enumeration.

Public function Const

FAudioPlatfo...

 

GetPlatformDeviceInfo()

Returns the platform device info of the currently open audio stream.

Public function Const

FAudioPlatfo...

 

GetPlatformSettings()

Gets the platform specific audio settings.

Public function

FName

 

GetRuntimeFormat

(
    USoundWave* InSoundWave
)

Returns the name of the format of the input sound wave.

Public function

bool

 

HasCompressedAudioInfoClass

(
    USoundWave* InSoundWave
)

Checks if the platform has a compressed audio format for sound waves.

Public function

bool

 

InitializeHardware()

Initialize the hardware.

Public function Const

bool

 

IsInitialized()

Is the hardware initialized.

Public function Virtual Const

bool

 

IsNonRealtime()

Whether this is an interface for a non-realtime renderer.

Protected function

uint32

 

MainAudioDeviceRun()

Run the "main" audio device.

Public function Virtual

bool

 

MoveAudioStreamToNewAudioDevice

(
    const FString& InNewDeviceId
)

Resets the audio stream to use a new audio device with the given device ID (empty string means default).

Protected function

void

 

OnAudioMixerPlatformError

(
    const FString& ErrorDetails,
    const FString& FileName,
    int32 LineNumber
)

Is called when an error is generated.

Public function Virtual

void

 

OnHardwareUpdate()

Function called at the beginning of every call of UpdateHardware on the audio thread.

Public function

bool

 

OpenAudioStream

(
    const FAudioMixerOpenStreamParams&...
)

Opens up a new audio stream with the given parameters.

Public function

void

 

PostInitializeHardware()

This is called after InitializeHardware() is called.

Public function

void

 

ReadNextBuffer()

Retrieves the next generated buffer and feeds it to the platform mixer output stream.

Public function Virtual

void

 

ResumeContext()

Function to resume audio rendering. Used on mobile platforms which can suspend the application.

Public function Virtual

void

 

ResumePlaybackOnNewDevice()

Resumes playback on new audio device after device change.

Protected function Virtual

uint32

 

RunInternal()

Wrapper around the thread Run. This is virtualized so a platform can fundamentally override the render function.

Public function

bool

 

StartAudioStream()

Starts the audio stream processing and generating audio.

Protected function

void

 

StartRunningNullDevice()

When called, spins up a thread to start consuming output when no audio device is available.

Public function

bool

 

StopAudioStream()

Stops the audio stream (but keeps the audio stream open).

Protected function

void

 

StopGeneratingAudio()

Stops the render thread from generating audio.

Protected function

void

 

StopRunningNullDevice()

When called, terminates the null device.

Public function Virtual

void

 

SubmitBuffer

(
    const uint8* Buffer
)

Submit the given buffer to the platform's output audio device.

Public function Virtual Const

bool

 

SupportsHardwareDecompression()

Whether or not this platform has hardware decompression.

Public function Virtual Const

bool

 

SupportsRealtimeDecompression()

Whether or not the platform supports realtime decompression.

Public function Virtual

void

 

SuspendContext()

Function to stop all audio from rendering. Used on mobile platforms which can suspend the application.

Public function

bool

 

TeardownHardware()

Teardown the hardware.

Overridden from FRunnable

Name Description

Public function Virtual

FSingleThrea...

 

GetSingleThreadInterface()

FSingleThreadRunnable accessor for ticking this FRunnable when multi-threading is disabled.

Public function Virtual

uint32

 

Run()

Runs the runnable object.

Overridden from FSingleThreadRunnable

Name Description

Public function Virtual

void

 

Tick()

Tick function.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss