APLAY FORMATS FOR REFERENCE
By default it seems that aplay uses the -D "default", this provides access to the auto-formatting conversions magickery
it also recognises the -D plughw and -D plughw:0 and plughw:0,0
This gives us a rough idea of the kind of formats we might expect to get working out of the box as it were if we used this device. So worth a dig around.
entered lower case
aplay -f {format}
RATES / FORMATS SUPPORTED
Spoiler:
WORKING (rate at 8k default, unless otherwise indicated)
Format: U8 Unsigned 8 bit, Rate 8000 Hz, Mono
Format: S16_LE Signed 16 bit Little Endian, Rate 8000 Hz, Mono
Format: CD Signed 16 bit Little Endian, Rate 44100 Hz, Stereo (Note the higher rate)
Format: DAT Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Format: S24_LE Signed 24 bit Little Endian, Rate 8000 Hz, Mono
Format: S32_LE Signed 32 bit Little Endian, Rate 8000 Hz, Mono
Format: S24_3LE (Signed 24 bit Little Endian in 3bytes, Rate 8000 Hz)
NOT WORKING
Format: U16_LE
Format: S8
Format: U16_BE
Format: S16_BE
Format: S24_BE
Format: U24_LE
Format: U24_BE
Format: S32_BE
Format: U32_LE
Format: U32_BE
Format: FLOAT_LE
Format: FLOAT_BE
Format: FLOAT64_LE
Format: FLOAT64_BE
Format: IEC958_SUBFRAME_LE
Format: MU_LAW
Format: A_LAW
Format: IMA_ADPCM
Format: GSM
Format: SPECIAL
Format: S24_3BE
Format: U24_3LE
Format: U24_3BE
Format: S20_3LE
Format: S20_3BE
Format: U20_3LE
Format: U20_3BE
Format: S18_3LE
Format: S18_3BE
Format: U18_3LE
Format: U18_3BE
Whereas passing it the hardware flag -D hw or it's synonyms hw:0 or hw:0,0 (with the required -c 2 stereo flag, mono is not hw supported)
Reduces us to:
aplay -D {hw-synonym} -c 2 -f {format}
Format: S16_LE
Format: S24_LE
Format: S20_3LE
Which is realistic. This tallies up neatly with our previous HW evidence:
Code:
Formats: S16_LE S24_LE S20_3LE
Channels: 2
Sample rates: 8000 11025 16000 22050 32000 44100 48000
Interrupt interval: 166-512000 us
Buffer size: 333-2048000 us
There are no doubt more permutations and shorthands I have missed.
Please feel free to append. This wasn't about underruns or performance, simply establishing current applications alsa compliance and how they make the card work effectively.
Further thoughts:
So
aplay is pretty solid.
stracing the playback and init stage might give us some clues so I have done that here
with two different types of file. One
mono 44k, and one
strereo 22k, To see what aplay decides about playback.
Seemingly the 44k mono causes a poll typed playback, whereas the 22k caused a direct interleaved decision. Full info in the straces attached (somewhat pruned for brevity), it's interesting stuff.
The Alsa init in
aplay is particularly thorough and looks like something we really should aim to emulate.
Next steps? Possibly try stracing
arecord | aplay and watch how it handles underruns.