Closed guness closed 3 years ago
Hi @guness . From the ConcurrentModificationException
it appears that your application is accessing an AudioSwitch
instance from multiple threads. We currently only support access to this class from a single thread as specified in the documentation here. Please make sure that access to this class in your application is single threaded. Thanks!
hey Alton, I will make this single threaded. thanks for the tip.
Hey, I think the README should refer to this situation of only supporting access from a single thread. Besides that I think there are two situations that should also be informed:
AudioSwitch.start
will perform the register of WiredHeadsetReceiver
to listen to ACTION_HEADSET_PLUG
changes, and this is sticky broadcast so when you do astart
the enumerateDevices
will be trigger twice (one directly from the AudioSwitch.start
and another from the callback WiredDeviceConnectionListener
WiredHeadsetReceiver
will send updates through the MainThread. If you startAudioSwitch.start
in a different thread than the Main, you can end in situation where two different threads are calling enumerateDevices
and leading to ConcurrentModificationExceptionThanks
Hi @filipebatista . Thanks for the recommendation! We will add this one to our backlog to address your feedback. We accept pull requests from the community as well so feel free do to so if you'd like.
Describe the bug I don't have a prior logs on clue how did this happened. Stack trace does not show my code and I am not able to reproduce the issue, so sorry for that.
Stack Trace
and second one, probably on another thread or worker:
Expected behavior Probably some thread protection should be there or maybe immutable list should be used. you know the best.
Android Device (please complete the following information):
Version
Additional context Happens rarely.