Skip to content Skip to sidebar Skip to footer

Android Opensl "paudiosrc: Data Format 2 Not Allowed" - Denying Sl_dataformat_pcm?

I'm trying to create an AudioPlayer with a bufferqueue source and outputmix sink. I've configured the source with a pcm format very similar to that shown in the ndk samples, but Op

Solution 1:

May be the audio sampling rate is not supported in your device. Try SL_SAMPLINGRATE_8 instead of SL_SAMPLINGRATE_48 or pick some other device (Nexus 4/HTC One) to test.

If you hear distorted sound while voice communication then increase your recorder buffer size and you may try changing sampling rate too. Other sampling rate options are: SL_SAMPLINGRATE_16, SL_SAMPLINGRATE_32, SL_SAMPLINGRATE_44_1 etc.

There's a specific/preferred buffer size and sampling rate for each android device. You can have the preferred buffer size and sampling rate from following java code segment. Note that, audioManager.getProperty() doesn't work with API level<17.

AudioManageraudioManager= (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
Stringrate= audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
Stringsize= audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
Log.d("Buffer Size and sample rate", "Size :" + size + " & Rate: " + rate);

Solution 2:

It turns out I needed to be using the SLDataLocator_AndroidSimpleBufferQueue instead of SLDataLocator_AndroidBufferQueue.

Post a Comment for "Android Opensl "paudiosrc: Data Format 2 Not Allowed" - Denying Sl_dataformat_pcm?"