twilio/audioswitch

AudioDeviceChangeListener being invoked even after the AudioSwitch instance being nulled or stopped.

AnonymousUserAndroid opened this issue · 1 comments

Describe the bug
Once the AudioSwitch listener is initialized, the method audioSwitch.start { audioDevices, selectedAudioDevice -> } keeps listening for new changes even after the audioSwitch instance is nulled or audioSwitch.stop() is called.

To Reproduce
Steps to reproduce the behavior:

  1. Initiate the audioSwitch instance via code and then manually reassign it to null or call audioSwitch.stop().
  2. Run the app.
  3. Plug a wired headset or connect a bluetooth headset to the phone.
  4. Disconnect/unplug.
  5. Add debug breakpoint.
  6. See error.

Expected behavior
The audioSwitch.start { audioDevices, selectedAudioDevice -> }listener should stop listening for new changes.

Actual behavior
The audioSwitch.start { audioDevices, selectedAudioDevice -> } listener keeps listening for new changes even with audioSwitch instance is null.

AudioSwitch Version

  • Version: 1.1.4

Android Device (please complete the following information):

  • Device: Xiaomi Redmi Note 9 Pro
  • API Version: 30

Hi @AnonymousUserAndroid I've looked into scenario where AudioSwitch is started then stopped and I do not see any listener callbacks with Wired or Bluetooth devices after stop() has been called. Can you provide code snippet or logs with AudioSwitch.loggingEnabled = true if you are still experiencing this issue. Regarding null scenario object is retained by the system, reassigning to null by itself after AudioSwitch is started it is not advisable and AudioSwitch.stop() should be called to close listeners/receivers and avoid memory leaks. Link