Do not play audio if audio service is not ready
Currently, audio is playing without any checking audio service. This causes a crash if audio service is not ready yet. Add checking audio service before playing audio to avoid this crash. Bug: 232943444 Test: Manual testing of Cherrypick-To-Main as follows: Tweak the clockwork boot animation to have audio: $ cd ~/main/device/google/clockwork/bootanimations/square_280 $ mv bootanimation.zip bootanimation_orig.zip $ unzip -d newanimation bootanimation.zip $ cd newanimation $ cp ~/main/frameworks/base/data/sounds/newwavelabs/Miami_Twice.wav part1/audio.wav $ zip -0qry -i \*.txt \*.png \*.wav @ ../bootanimation.zip *.txt part* $ cd .. $ unzip -l bootanimation.zip | grep files 1494650 197 files $ unzip -l bootanimation_orig.zip | grep files 770910 196 files Confirmed initAudioThread is a "no-op" (early exits without calling audioplay::create) when audio service is not available. Confirmed the playPart() and shutdown() AudioAnimationCallbacks are safe "no-ops" if they're called when audioplay::create() has not been called. See ag/21777853 for details and b/272124709 to track "clarifying they're safe" enhancement. After confirming this all works on main, created a cherrypick of the original CL. Cherrypick-To-Main observation: Considered moving the code added to InitAudioThread::threadLoop() to the top of AudioAnimationCallbacks::init() to eliminate the overhead of running a "no-op" thread when the audio service is not available. For Wear-On-Main initiative, our primary goal is to move wear-dev CLs directly to main – happy to file an enhancement to track this consideration if it would be an improvement. Change-Id: Ica3525fa8bf8534778db388211e8a7c2ade6db9f (cherry picked from commit ca5110fc1083706c021b28e8c524e92f8fd34349)
Loading
Please register or sign in to comment