Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform icon indicating copy to clipboard operation
Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform copied to clipboard

Android: Not all AudioTracks are released with AndroidUSBAudio::stopIO

Open adamhs1997 opened this issue 4 years ago • 2 comments

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.

adamhs1997 avatar Nov 05 '20 19:11 adamhs1997

We'll investigate this in a couple of weeks. Not able to do it sooner, sorry for that.

gaborszanto avatar Nov 09 '20 13:11 gaborszanto

No worries. I'll work around it in the meantime.

adamhs1997 avatar Nov 09 '20 16:11 adamhs1997

Closing as stale.

ivannador avatar Oct 06 '22 14:10 ivannador