I am trying to add audio during boot animation in android device. But I heard static noise instead added audio.
I added audio.wav file in part folder, as mentioned in this page.
https://android.googlesource.com/platform/frameworks/base/+/master/cmds/bootanimation/FORMAT.md.
frameworks/base/cmds/bootanimation/
Initially, I had an issue in creating the audio player. I got the below error.
This structure has default values from Google AOSP. I haven't modified.
SLDataFormat_PCM format_pcm = {
SL_DATAFORMAT_PCM,
2,
44100000, // convert to milliHz
32,
16,
3,
SL_BYTEORDER_LITTLEENDIAN
}
01-31 17:51:54.155 6632 6644 W libOpenSLES: Leaving Engine::CreateAudioPlayer (SL_RESULT_PARAMETER_INVALID) 01-31 17:51:54.155 6632 6644 E audioplay: sl CreateAudioPlayer failed with result 2
I have read one post, and changed the sturcture values as below. After that audio player was created successfully, and static noise was heard.
SLDataFormat_PCM pcm;
pcm.formatType = SL_DATAFORMAT_PCM;
pcm.numChannels = 2;
pcm.samplesPerSec = SL_SAMPLINGRATE_8;
pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
If anyhow has experienced similar issue, please provide some inputs on this.