Pack PCM into uncompressed ALAC frames for AirPlay/RAOP.
Real senders send compressed ALAC, but every RAOP receiver also decodes the uncompressed/"escape" form (a per-frame flag), so we avoid needing an ALAC compressor: we emit verbatim frames the receiver decodes identically.
Bit layout (MSB-first), confirmed against shairport's hammerton decoder: for
16-bit stereo the frame is 001 (ID_CPE), a 4-bit element-instance tag, 12
unused bits, partialFrame(1)=0, bytesShifted(2)=0, escape(1)=1
(uncompressed), then frames×(L:16, R:16) sample bits, then 111 (ID_END),
zero-padded to a byte. The 4-bit instance tag matters: without it the decoder's
partialFrame flag lands in the sample data and it reads a garbage sample count
(silence still decodes — its sample bits are 0 — but real audio overflows).
Summary
Functions
Encode one frame of interleaved little-endian s16 stereo PCM (frames
sample-pairs, i.e. frames*4 bytes) into an uncompressed ALAC frame.