How to handle speaker change with Android Oboe library?

  android, audio, oboe

I’m trying to implement Oboe library to my project to perform the least latency when playing sounds. I could perform playback manipulating, panning, mixing, the basics things which internal Android library such as SoundPool can provide.

I wanted to test panning effect, I connected headphones to my device, but then, I noticed that any sound didn’t play through my headphones. Device speaker also didn’t play any sound either. So I disconnected my headphones to check if something went wrong. I pressed sound playing button, but I couldn’t hear any sound even though headphones are completely disconnected from device.

When I firstly open the app, it can play sound through device speaker without any problems, but as soon as I connect headphones, no sound plays through both device speaker and headphones.

Same for opposite, if I start app with headphones connected to device, it can play sound very well through headphones. It can even perform panning effect too, but if I disconnect headphones from device, it stops playing any sound.

  1. Do I have to re-open audio stream whenever preferred audio device is changed?
  2. If yes for 1, is there any way to notify app that audio device is changed, so I can manually close stream and re-open it? Or can I make Oboe automatically handle audio device changes?

Source: Android Questions