Skip to content

Commit

Permalink
Remove preferSpeakerphone MediaManager parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu-timar committed Sep 25, 2024
1 parent aa4130a commit 235ba2f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
5 changes: 2 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 @@ -478,15 +478,14 @@ public final class io/getstream/video/android/core/MemberState {
}

public final class io/getstream/video/android/core/MicrophoneManager {
public fun <init> (Lio/getstream/video/android/core/MediaManagerImpl;ZI)V
public fun <init> (Lio/getstream/video/android/core/MediaManagerImpl;I)V
public final fun canHandleDeviceSwitch ()Z
public final fun cleanup ()V
public final fun disable (Z)V
public static synthetic fun disable$default (Lio/getstream/video/android/core/MicrophoneManager;ZILjava/lang/Object;)V
public final fun getAudioUsage ()I
public final fun getDevices ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getMediaManager ()Lio/getstream/video/android/core/MediaManagerImpl;
public final fun getPreferSpeakerphone ()Z
public final fun getSelectedDevice ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getStatus ()Lkotlinx/coroutines/flow/StateFlow;
public final fun isEnabled ()Lkotlinx/coroutines/flow/StateFlow;
Expand Down Expand Up @@ -868,7 +867,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 fun <init> (Landroid/content/Context;Lkotlin/jvm/functions/Function2;)V
public final fun selectDevice (Lcom/twilio/audioswitch/AudioDevice;)V
public fun start ()V
public fun stop ()V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ class ScreenShareManager(
*/
class MicrophoneManager(
val mediaManager: MediaManagerImpl,
val preferSpeakerphone: Boolean,
val audioUsage: Int,
) {
// Internal data
Expand Down Expand Up @@ -451,7 +450,7 @@ class MicrophoneManager(

if (canHandleDeviceSwitch()) {
audioHandler =
AudioSwitchHandler(mediaManager.context, preferSpeakerphone) { devices, selected ->
AudioSwitchHandler(mediaManager.context) { devices, selected ->
logger.i { "audio devices. selected $selected, available devices are $devices" }
_devices.value = devices.map { it.fromAudio() }
_selectedDevice.value = selected?.fromAudio()
Expand Down Expand Up @@ -858,7 +857,7 @@ class MediaManagerImpl(
)

internal val camera = CameraManager(this, eglBaseContext)
internal val microphone = MicrophoneManager(this, preferSpeakerphone = false, audioUsage)
internal val microphone = MicrophoneManager(this, 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 @@ -41,9 +41,8 @@ public interface AudioHandler {
/**
* TODO: this class should be merged into the Microphone Manager
*/
public class AudioSwitchHandler constructor(
public class AudioSwitchHandler(
private val context: Context,
private val preferSpeakerphone: Boolean,
private var audioDeviceChangeListener: AudioDeviceChangeListener,
) :
AudioHandler {
Expand All @@ -65,13 +64,8 @@ public class AudioSwitchHandler constructor(
AudioDevice.BluetoothHeadset::class.java,
)

if (preferSpeakerphone) {
devices.add(AudioDevice.Speakerphone::class.java)
devices.add(AudioDevice.Earpiece::class.java)
} else {
devices.add(AudioDevice.Earpiece::class.java)
devices.add(AudioDevice.Speakerphone::class.java)
}
devices.add(AudioDevice.Earpiece::class.java)
devices.add(AudioDevice.Speakerphone::class.java)

handler.post {
val switch = AudioSwitch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MicrophoneManagerTest {
fun `Ensure setup is called prior to any action onto the microphone manager`() = runTest {
// Given
val mediaManager = mockk<MediaManagerImpl>(relaxed = true)
val actual = MicrophoneManager(mediaManager, false, audioUsage)
val actual = MicrophoneManager(mediaManager, audioUsage)
val context = mockk<Context>(relaxed = true)
val microphoneManager = spyk(actual)
every { mediaManager.context } returns context
Expand Down Expand Up @@ -69,7 +69,6 @@ class MicrophoneManagerTest {
val actual =
MicrophoneManager(
mediaManager,
false,
audioUsage = AudioAttributes.USAGE_VOICE_COMMUNICATION,
)
val context = mockk<Context>(relaxed = true)
Expand All @@ -91,7 +90,7 @@ class MicrophoneManagerTest {
fun `Ensure setup if ever the manager was cleaned`() {
// Given
val mediaManager = mockk<MediaManagerImpl>(relaxed = true)
val actual = MicrophoneManager(mediaManager, false, audioUsage)
val actual = MicrophoneManager(mediaManager, audioUsage)
val context = mockk<Context>(relaxed = true)
val microphoneManager = spyk(actual)
every { mediaManager.context } returns context
Expand Down Expand Up @@ -119,7 +118,7 @@ class MicrophoneManagerTest {
fun `Resume will call enable only if prior status was DeviceStatus#enabled`() {
// Given
val mediaManager = mockk<MediaManagerImpl>(relaxed = true)
val actual = MicrophoneManager(mediaManager, false, audioUsage)
val actual = MicrophoneManager(mediaManager, audioUsage)
val context = mockk<Context>(relaxed = true)
val microphoneManager = spyk(actual)
every { mediaManager.context } returns context
Expand Down

0 comments on commit 235ba2f

Please sign in to comment.