Imagine an Android device (possibly any device from any manufacturer) that is connected via bluetooth to a speaker (or any bluetooth audio device)... and there has been a "significant" amount of time where no audio has been played from the device.
At the moment audio resumes playing from this device, there is more often than not a "speaker is slowly waking up" phase where no audio is heard and the audio is late to become audible.
This is less obvious when the audio is being "kept alive" with constant audio, or only taking short breaks of silence, but what if you have an application that makes very short and intermittent sounds at unpredictable times... like an alarm that measures environmental conditions with a sensor?
I'm not sure if:
A) This behavior is some kind of power-saving feature of the output device and we would have no control over it other than to play some kind of fake audio/silence prior to our desired sound... or have a low-volume sound/white noise on a constant loop... in order to pre-empt/prevent the "warm up."
B) It's part of the bluetooth protocol/standard/definition
C) It's controllable in software with something like (on Android):
bluetooth.setMode(BluetoothMode.NO_NAPPING_ALLOWED);
I'm hoping the case is (C), and if so, then what is the proper code for this?
I'm sure there is a similar question out there that is asked in a different way, but I can't find it, and I have searched through the documentation for AudioManager and although bluetooth is mentioned in many places, I can't find this functionality.
For fun, I accessed developer options on my phone and picked the option to keep the device awake. I also tried to disable any battery optimization.
My SONY XB-900 headphones turned off after some minutes of silence, my cheapo Monster headphones did not turn off, and a cheapo Bluetooth Speaker did not turn off.
I repeated the same thing on Windows, exactly the same results.
Then I searched on some forums, using the keywords "Bluetooth" "prevent" "awake" "power saving" "standby" "disconnected" "annoying" and "silence".
This commenter told something interesting:
I read that sony SRS-X1 bluetooth speaker doesn't cut off bluetooth audio connection after a period of inactivity. It just enters standby mode which it takes about 0.1 second to exit when audio signals arrive. So, you can lose 0.1 second of audio when audio is played after a period of inactivity. However, you can prevent it from entering standby mode by playing 20Hz noise continuously. Speakers cannot react to 20Hz noise, so 20Hz noise is silent.
This makes me believe that is a pure playback device-side implementation, and the OS nor Bluetooth have anything to do with it. The fact that you did not find any documentation about it supports the theory. Looks like the solution is the one you already mentioned: Play a very low or very high frequency on loop to keep the device awake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With