I’m trying to set the encoding for an instance to ENCODING_AAC_LC
This is a snippet of what I’m trying to do
ref = JNI_CALL_OBJECT( p_afmt_builder,
jfields.AudioFormat_Builder.setEncoding,
jfields.AudioFormat.ENCODING_AAC_LC );
Which is supported as per the AOSP documentation
https://developer.android.com/reference/android/media/AudioFormat#ENCODING_AAC_LC
However it always throws this error and fails:
(The error code corresponds to ENOSYS, https://cs.android.com/android/platform/superproject/main/+/main:frameworks/av/media/libstagefright/MediaCodec.cpp;l=6615?q=rendring%20output%20error%20)
createTrack() getOutputForAttr() return error -38 or invalid output handle
createTrack_l(0): AudioFlinger could not create track, status: -38 output 0
Error -38 initializing AudioTrack
Error code -20 when initializing AudioTrack.
I have found only three formats to not throw an error
ENCODING_PCM_16BIT, PCM_8BIT and PCM_FLOAT also seen here:
https://cs.android.com/android/platform/superproject/main/+/main:system/media/audio_utils/fuzz/format_fuzzer/format_fuzzer.cpp;l=36?q=audio_format_t%20
However these don’t give me any audible audio output for my AAC_LC stream
What can be done here?
I tried all possible format variations but they result in either no audio or and Audioflinger error.
adelden22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.