Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform
Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform copied to clipboard
Android: Not all AudioTracks are released with AndroidUSBAudio::stopIO
I built an app based on your SuperpoweredUSBExample demo app for Android. Like that app, it allows for a simple audio passthrough from microphone to speakers, but my app allows for multiple device connections. I noticed that after starting and stopping playback a few times, the app would crash with some AudioTrack and OpenSL errors. After profiling the app with Android Studio, I noticed that each time AndroidUSBAudio::startIO was called, two AudioTracks are created. However, when AndroidUSBAudio::stopIO is called, only one is released. After starting and restopping a few times, the device would hit the limit of 32 available AudioTracks and the app would crash. This is especially noticeable when using multiple devices (since they each leak their own AudioTrack).
I later pulled the USB Example app again and tested with that. The same issue occurs.
I reproduced this issue on an S7 with Android 8. I only have one device to test with, so I can't say for sure if this is a device-specific issue.
We'll investigate this in a couple of weeks. Not able to do it sooner, sorry for that.
No worries. I'll work around it in the meantime.
Closing as stale.