client-sdk-flutter icon indicating copy to clipboard operation
client-sdk-flutter copied to clipboard

[bug] [iOS only] When call setMicrophoneEnabled, audio output switched from Headphones to Speaker

Open UserJah opened this issue 1 year ago • 4 comments

Describe the bug

  1. When I connecting to room with headphones (bluetooth) I hear participants from headphones. But when I call setMicrophoneEnabled(true) audio output automatically switched to speakerphone. Also, Hardware.instanse.enumerateDevices() return only one audio Input - (speaker)

To Reproduce

  1. connect to room with headphones (bluetooth)
  2. enable microphone

Expected behavior

Enable microphone should not switch audio output automatically.

P.S: I'm guessing this may be related to AppleAudioMode. Is there any way to change it?

Platform information

  • Flutter version: [✓] Flutter (Channel stable, 3.16.0, on macOS 13.4 22F66 darwin-arm64, locale ru-AE) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.1) [✓] VS Code (version 1.84.2) [✓] Connected device (3 available) [✓] Network resources

• No issues found!

  • Plugin version: 1.5.3
  • Flutter target OS: iOS
  • Flutter target OS version:12.1
  • Flutter console log:

UserJah avatar Dec 07 '23 09:12 UserJah

hey @UserJah, I saw you made some changes in your fork, is it effective?

cloudwebrtc avatar Dec 11 '23 03:12 cloudwebrtc

What model of Bluetooth headset are you using? I tested Air Pods Pro on iOS and it seems to work as expected

  1. Connect air pods
  2. Turn off fast connect and connect to the room
  3. Sound output from air pods
  4. Enable microphone on iOS
  5. The sound is not output from the speaker.

cloudwebrtc avatar Dec 11 '23 03:12 cloudwebrtc

Hey @cloudwebrtc! I'm using JBL TUNE760NC. For my case it's happens because this code: https://github.com/livekit/client-sdk-flutter/blob/f5c681d5096e23dc332074e273a9dedc77d11dd6/lib/src/track/audio_management.dart#L128C5-L133C6

Hardware.instanse.setSpeakerPhoneOn(true) works only if _preferSpeakerOutput = false. In my case I'm just use await Hardware.instance.setPreferSpeakerOutput(true)

In case my fork - I found better solution. I'm just overide this function https://github.com/livekit/client-sdk-flutter/blob/f5c681d5096e23dc332074e273a9dedc77d11dd6/lib/src/track/audio_management.dart#L36C1-L39C1

like

onConfigureNativeAudio = (_) async {
        return NativeAudioConfiguration(
          appleAudioCategory: AppleAudioCategory.playAndRecord,
          appleAudioCategoryOptions: <AppleAudioCategoryOption>{
            AppleAudioCategoryOption.allowBluetooth,
            AppleAudioCategoryOption.interruptSpokenAudioAndMixWithOthers,
          },
          appleAudioMode: AppleAudioMode.videoChat,
        );
      };

because in my case I don't need dependence of AudioModes on count audio tracks

UserJah avatar Dec 11 '23 09:12 UserJah

A similar bug is also present in my users. I'm still waiting for a solution. https://github.com/livekit/client-sdk-flutter/issues/376

furkanKotic avatar Dec 11 '23 12:12 furkanKotic

hi, any solution ?

std-s avatar May 27 '24 04:05 std-s

fixed https://github.com/livekit/client-sdk-flutter/pull/518

cloudwebrtc avatar May 27 '24 06:05 cloudwebrtc