Some additional log: ``` Gecko : [Child 14829: MediaDecoderStateMachine #1]: E/cubeb cubeb.c:386:Invalid format, 0x809d2fcc 0x0 1 0 Cubeb_OpenSL: Playback params: Rate 48000, channels 2, format 2, latency in frames 4800. ``` After some digging, I found the key reason is opensl is incompatible with f32 when minsdk <= LOLLPOP. From this [commit](https://hg.mozilla.org/mozilla-central/rev/0a0ec1730ddb#l2.13) (bingo, i guessed right) , Audio output format is AUDIO_OUTPUT_FORMAT = AUDIO_FORMAT_FLOAT32 , will be converted to `CUBEB_SAMPLE_FLOAT32NE` (format 2 in the second line of the log) for cubeb. ``` params.format = CubebUtils::ToCubebFormat<AUDIO_OUTPUT_FORMAT>::value; template <AudioSampleFormat N> struct ToCubebFormat { static const cubeb_sample_format value = CUBEB_SAMPLE_FLOAT32NE; }; ``` then the keypoint https://searchfox.org/mozilla-central/source/media/libcubeb/src/cubeb_opensl.c#1108-1130 if `__ANDROID_API__` < ANDROID_VERSION_LOLLIPOP , `opensl_set_format_ext` is not defined and will not be called, so `format` is NULL , then `opensl_set_format` will be called. In `opensl_set_format` , only ` CUBEB_SAMPLE_S16LE` and ` CUBEB_SAMPLE_S16BE` will be handled, other format will cause CUBEB_ERROR_INVALID_FORMAT. then Audio failed to initialize. When targetting armeabi , the `__ANDROID_API__` is 16 (because of --target=arm-linux-androideabi16) < ANDROID_VERSION_LOLLIPOP (21) , so failure occurs. When targetting arm64 , the `__ANDROID_API__` is 21 (because of --target=aarch64-linux-android21) == ANDROID_VERSION_LOLLIPOP (21) , so format is assigned by `opensl_set_format_ext`. ------------------------- Although i don't know 1) why `opensl` is still used in Android 11. 2) why ndk targetting to API 16 when building armeabi.
Bug 1848518 Comment 12 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Some additional log: ``` Gecko : [Child 14829: MediaDecoderStateMachine #1]: E/cubeb cubeb.c:386:Invalid format, 0x809d2fcc 0x0 1 0 Cubeb_OpenSL: Playback params: Rate 48000, channels 2, format 2, latency in frames 4800. ``` After some digging, I found the key reason is opensl is incompatible with f32 when minsdk <= LOLLPOP. From this [commit](https://hg.mozilla.org/mozilla-central/rev/0a0ec1730ddb#l2.13) (bingo, i guessed right) , Audio output format is AUDIO_OUTPUT_FORMAT = AUDIO_FORMAT_FLOAT32 , will be converted to `CUBEB_SAMPLE_FLOAT32NE` (format 2 in the second line of the log) for cubeb. ``` params.format = CubebUtils::ToCubebFormat<AUDIO_OUTPUT_FORMAT>::value; template <AudioSampleFormat N> struct ToCubebFormat { static const cubeb_sample_format value = CUBEB_SAMPLE_FLOAT32NE; }; ``` then the keypoint https://searchfox.org/mozilla-central/source/media/libcubeb/src/cubeb_opensl.c#1108-1130 if `__ANDROID_API__` < ANDROID_VERSION_LOLLIPOP , `opensl_set_format_ext` is not defined and will not be called, so `format` is NULL , then `opensl_set_format` will be called. In `opensl_set_format` , only ` CUBEB_SAMPLE_S16LE` and ` CUBEB_SAMPLE_S16BE` will be handled, other format will cause CUBEB_ERROR_INVALID_FORMAT. then Audio failed to initialize. When targetting armeabi , the `__ANDROID_API__` is 16 (because of --target=arm-linux-androideabi16) < ANDROID_VERSION_LOLLIPOP (21) , so failure occurs. When targetting arm64 , the `__ANDROID_API__` is 21 (because of --target=aarch64-linux-android21) == ANDROID_VERSION_LOLLIPOP (21) , so format is assigned by `opensl_set_format_ext`. ------------------------- Although i don't know 1) why `opensl` is still used in Android 11. 2) why ndk targetting to API 16 when building armeabi. Got anwser for question 2 from geckoview matrix channel. https://searchfox.org/mozilla-central/rev/ce049e593c7d062a039938cabccaab4c14b8ebfd/build/moz.configure/android-ndk.configure#36-41