The driver should report only those sample formats that the hardware actually supports.
The ALSA library can do automatic sample rate/format conversions (with the "default" or "plughw" devices). However, this does not work if you bypass it with the "hw" device.
Thanks Clemens.
One problem I am having is that my driver doesn't always work with the plughw interface.
For instance, the following stereo pipeline works for 'hw:3,0' but outputs silence for 'plughw:3,0':
gst-launch playbin2 uri=file:///home/root/Iguazu.mp3 audio-sink="alsasink device=plughw:3,0"
I am using older ALSA libraries, so maybe there is a bug there?
alsa-lib-1.0.27.2-r1
My hw definition looks like this:
static struct snd_pcm_hardware snd_imx_audio_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER ), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_16000, .rate_min = 16000, .rate_max = 16000, .channels_min = 2, .channels_max = 2, .buffer_bytes_max = PLAYBACK_TOTAL_BUFFER_SIZE, // total num buffers * buffer size .period_bytes_min = PLAYBACK_STEREO_BUFFER_SIZE, .period_bytes_max = PLAYBACK_STEREO_BUFFER_SIZE, .periods_min = 1, .periods_max = PLAYBACK_TOTAL_NUM_BUFFERS, };