Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-houses-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"client-sdk-android": minor
---

Default prioritizing speaker over earpiece
5 changes: 5 additions & 0 deletions .changeset/new-bulldogs-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"client-sdk-android": minor
---

Explicitly expose AudioSwitchHandler from Room for easier audio handling
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 LiveKit, Inc.
* Copyright 2023-2025 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,8 @@ import javax.inject.Inject
import javax.inject.Singleton

/**
* An [AudioHandler] built on top of [AudioSwitch].
* An [AudioHandler] built on top of [AudioSwitch]. This handles things such as
* getting the audio focus as needed, as well as automatic audio output device management.
*
* The various settings should be set before connecting to a [Room] and [start] is called.
*/
Expand Down Expand Up @@ -222,8 +223,8 @@ constructor(private val context: Context) : AudioHandler {
listOf(
AudioDevice.BluetoothHeadset::class.java,
AudioDevice.WiredHeadset::class.java,
AudioDevice.Earpiece::class.java,
AudioDevice.Speakerphone::class.java,
AudioDevice.Earpiece::class.java,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidliu I guess this fix is for: #580?
If that's the case, I'm curious what will become the active audio output in case we setup custom preferredDeviceList in which Earpiece is the first one, then disconnect/reconnect to room? Will that be Speakerphone or Earpiece with this fix?

Copy link
Contributor Author

@davidliu davidliu Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didnt see that bug before making this change; our other SDKs use this ordering, so this is to align with that.

Connecting/disconnecting shouldn't change or reset the order, if it does, then that's a bug.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. If you have time, could you take a look at the bug please? I think that might be related.
Thanks a lot.

)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 LiveKit, Inc.
* Copyright 2023-2025 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,10 +26,13 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import io.livekit.android.ConnectOptions
import io.livekit.android.LiveKit
import io.livekit.android.LiveKitOverrides
import io.livekit.android.RoomOptions
import io.livekit.android.Version
import io.livekit.android.audio.AudioHandler
import io.livekit.android.audio.AudioProcessingController
import io.livekit.android.audio.AudioSwitchHandler
import io.livekit.android.audio.AuthedAudioProcessingController
import io.livekit.android.audio.CommunicationWorkaround
import io.livekit.android.dagger.InjectionNames
Expand Down Expand Up @@ -77,6 +80,17 @@ constructor(
private val defaultDispatcher: CoroutineDispatcher,
@Named(InjectionNames.DISPATCHER_IO)
private val ioDispatcher: CoroutineDispatcher,
/**
* The [AudioHandler] for setting up the audio as need.
*
* By default, this is an instance of [AudioSwitchHandler].
*
* This can be substituted for your own custom implementation through
* [LiveKitOverrides.audioOptions] when creating the room with [LiveKit.create].
*
* @see [audioSwitchHandler]
* @see [AudioSwitchHandler]
*/
val audioHandler: AudioHandler,
private val closeableManager: CloseableManager,
private val e2EEManagerFactory: E2EEManager.Factory,
Expand Down Expand Up @@ -272,6 +286,14 @@ constructor(
val remoteParticipants: Map<Participant.Identity, RemoteParticipant>
get() = mutableRemoteParticipants

/**
* A convenience getter for the audio handler as a [AudioSwitchHandler].
*
* Will return null if [audioHandler] is not a [AudioSwitchHandler].
*/
val audioSwitchHandler: AudioSwitchHandler?
get() = audioHandler as? AudioSwitchHandler

private var sidToIdentity = mutableMapOf<Participant.Sid, Participant.Identity>()

private var mutableActiveSpeakers by flowDelegate(emptyList<Participant>())
Expand Down
Loading