-
public final class AudioOptionsOptions for customizing the audio settings of LiveKit.
-
-
Field Summary
Fields Modifier and Type Field Description private final AudioTypeaudioOutputTypeprivate final AudioHandleraudioHandlerprivate final AudioDeviceModuleaudioDeviceModuleprivate final Function1<JavaAudioDeviceModule.Builder, Unit>javaAudioDeviceModuleCustomizerprivate final BooleandisableCommunicationModeWorkaroundprivate final AudioProcessorOptionsaudioProcessorOptionsprivate final BooleandisableAudioPrewarming
-
Constructor Summary
Constructors Constructor Description AudioOptions(AudioType audioOutputType, AudioHandler audioHandler, AudioDeviceModule audioDeviceModule, Function1<JavaAudioDeviceModule.Builder, Unit> javaAudioDeviceModuleCustomizer, Boolean disableCommunicationModeWorkaround, AudioProcessorOptions audioProcessorOptions, Boolean disableAudioPrewarming)
-
Method Summary
Modifier and Type Method Description final AudioTypegetAudioOutputType()Override the default output AudioType. final AudioHandlergetAudioHandler()Override the default AudioHandler. final AudioDeviceModulegetAudioDeviceModule()Override the default AudioDeviceModule. final Function1<JavaAudioDeviceModule.Builder, Unit>getJavaAudioDeviceModuleCustomizer()Called after default setup to allow for customizations on the JavaAudioDeviceModule. final BooleangetDisableCommunicationModeWorkaround()On Android 11+, the audio mode will reset itself from AudioManager.MODE_IN_COMMUNICATION if there is no audio playback or capture for 6 seconds (for example when joining a room with no speakers and the local mic is muted.) This mode reset will cause unexpected behavior when trying to change the volume, causing it to not properly change the volume. final AudioProcessorOptionsgetAudioProcessorOptions()Options for processing the mic and incoming audio. final BooleangetDisableAudioPrewarming()Devices may take some time initializing the audio stack for recording. -
-
Constructor Detail
-
AudioOptions
AudioOptions(AudioType audioOutputType, AudioHandler audioHandler, AudioDeviceModule audioDeviceModule, Function1<JavaAudioDeviceModule.Builder, Unit> javaAudioDeviceModuleCustomizer, Boolean disableCommunicationModeWorkaround, AudioProcessorOptions audioProcessorOptions, Boolean disableAudioPrewarming)
-
-
Method Detail
-
getAudioOutputType
final AudioType getAudioOutputType()
Override the default output AudioType.
This affects the audio routing and how the audio is handled. Default is AudioType.CallAudioType.
Note: if audioHandler is also passed, the values from audioOutputType will not be reflected in it, and must be set yourself.
-
getAudioHandler
final AudioHandler getAudioHandler()
Override the default AudioHandler.
Default is AudioSwitchHandler.
Use NoAudioHandler to turn off automatic audio handling or AudioFocusHandler to get simple audio focus handling.
-
getAudioDeviceModule
final AudioDeviceModule getAudioDeviceModule()
Override the default AudioDeviceModule.
If a non-null value is passed, the library does not take ownership of the object and will not release it upon Room.release. It is the responsibility of the owner to call AudioDeviceModule.release when finished with it to prevent memory leaks.
-
getJavaAudioDeviceModuleCustomizer
final Function1<JavaAudioDeviceModule.Builder, Unit> getJavaAudioDeviceModuleCustomizer()
Called after default setup to allow for customizations on the JavaAudioDeviceModule.
Not used if audioDeviceModule is provided.
Note: We require setting the JavaAudioDeviceModule.Builder.setSamplesReadyCallback to provide support for LocalAudioTrack.addSink. If you wish to grab the audio samples from the local microphone track, use LocalAudioTrack.addSink instead of setting your own callback.
-
getDisableCommunicationModeWorkaround
final Boolean getDisableCommunicationModeWorkaround()
On Android 11+, the audio mode will reset itself from AudioManager.MODE_IN_COMMUNICATION if there is no audio playback or capture for 6 seconds (for example when joining a room with no speakers and the local mic is muted.) This mode reset will cause unexpected behavior when trying to change the volume, causing it to not properly change the volume.
We use a workaround by playing a silent audio track to keep the communication mode from resetting.
Setting this flag to true will disable the workaround.
This flag is a no-op when the audio mode is set to anything other than AudioManager.MODE_IN_COMMUNICATION.
-
getAudioProcessorOptions
final AudioProcessorOptions getAudioProcessorOptions()
Options for processing the mic and incoming audio.
-
getDisableAudioPrewarming
final Boolean getDisableAudioPrewarming()
Devices may take some time initializing the audio stack for recording. Prewarming allows starting up the underlying audio recording prior to publish, letting the audio device be ready immediately when the track is fully published.
If set to true, disables audio recording prewarming (and the related LocalAudioTrack.prewarm function), and audio resources are only used while the track is connected and published. Defaults to false.
-
-
-
-