openslessink cannot handle 48kHz
On Android I'm playing an mp4 containing a 48kHz audio stream, on a device with a native output sample rate of 48kHz. When setting the playbin flag GST_PLAY_FLAG_NATIVE_AUDIO playback does not work because openslessink cannot handle 48kHz.
In sys/opensles/openslessink.c there is a comment:
/* According to Android's NDK doc the following are the supported rates */
#define RATES "8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100"
/* 48000 Hz is also claimed to be supported but the AudioFlinger downsampling
* doesn't seems to work properly so we relay GStreamer audioresample element
* to cope with this samplerate. */
Adding 48000 to the RATES list fixes playback with GST_PLAY_FLAG_NATIVE_AUDIO.
Without this fix then 48kHz streams will be downsampled to 44.1kHz by GstAudioResample then possibly upsampled back to 48kHz by the OS, which seems very wasteful.