Skip to content

Commit

Permalink
Improve device switching
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu-timar committed Sep 25, 2024
1 parent 9d9fae3 commit aa4130a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
3 changes: 0 additions & 3 deletions stream-video-android-core/api/stream-video-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,7 @@ public abstract interface class io/getstream/video/android/core/audio/AudioHandl
public final class io/getstream/video/android/core/audio/AudioSwitchHandler : io/getstream/video/android/core/audio/AudioHandler {
public static final field Companion Lio/getstream/video/android/core/audio/AudioSwitchHandler$Companion;
public fun <init> (Landroid/content/Context;ZLkotlin/jvm/functions/Function2;)V
public final fun getAudioDeviceChangeListener ()Lkotlin/jvm/functions/Function2;
public final fun getPreferSpeakerphone ()Z
public final fun selectDevice (Lcom/twilio/audioswitch/AudioDevice;)V
public final fun setAudioDeviceChangeListener (Lkotlin/jvm/functions/Function2;)V
public fun start ()V
public fun stop ()V
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,17 +900,10 @@ public class Call(

private fun updateMediaManagerFromSettings(callSettings: CallSettingsResponse) {
// Speaker
if (speaker.status.value is DeviceStatus.NotSelected) {
val enableSpeaker =
if (callSettings.video.cameraDefaultOn || camera.status.value is DeviceStatus.Enabled) {
// if camera is enabled then enable speaker. Eventually this should
// be a new audio.defaultDevice setting returned from backend
true
} else {
callSettings.audio.defaultDevice == AudioSettingsResponse.DefaultDevice.Speaker
}
speaker.setEnabled(enableSpeaker)
}
speaker.setEnabled(
enabled = callSettings.audio.defaultDevice == AudioSettingsResponse.DefaultDevice.Speaker ||
callSettings.audio.speakerDefaultOn,
)

// Camera
if (camera.status.value is DeviceStatus.NotSelected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ class MediaManagerImpl(
)

internal val camera = CameraManager(this, eglBaseContext)
internal val microphone = MicrophoneManager(this, preferSpeakerphone = true, audioUsage)
internal val microphone = MicrophoneManager(this, preferSpeakerphone = false, audioUsage)
internal val speaker = SpeakerManager(this, microphone)
internal val screenShare = ScreenShareManager(this, eglBaseContext)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public interface AudioHandler {
*/
public class AudioSwitchHandler constructor(
private val context: Context,
val preferSpeakerphone: Boolean,
var audioDeviceChangeListener: AudioDeviceChangeListener,
private val preferSpeakerphone: Boolean,
private var audioDeviceChangeListener: AudioDeviceChangeListener,
) :
AudioHandler {

Expand Down

0 comments on commit aa4130a

Please sign in to comment.