Let me explain this in simpler terms. There are 3 lossless codecs
- FLAC - This is a codec that apple doesn't understand. But windows, linux, FreeBSD, openBSD can use this codec. But this codec is not understood by apple devices using apple software (Apple Music, etc). But third party software can play FLAC like jriver mediacenter, audio nirvana, pine player, mpd and many others
- ALAC - This is a codec that is proprietary to apple. Only apple devices can play this
- DSD - This is a codec that windows, linux, BSD etc can use but apple music doesn't use this. But third party software on apple devices can play this (jriver, audio nirvana, mpd, etc)
AAC, mp3, etc are lossy codecs.
Problem 1
When you run apple music on a non-apple hardware or do airplay to a non-apple device, apple music will use the AAC. So when you use apple music on android or do send the stream usining airplay to a non-apple hardware, apple music detects that the end device cannot use ALAC. Hence it choses the AAC version of the music file. So whatever you do, what will get streamed will be a lossy version because the end devices cannot play ALAC codec. So linux, windows, chromecast, etc will never get the lossless version streamed to them from the apple music server.
Problem 2
Apple devices can play ALAC. So apple music server will send the lossless version (ALAC) to the device. So far so good. But all macbooks, ATV etc work on a fixed sample rate. Only the IPAD and Iphones can adjust the sample rate according to the sample rate of the source file of the master on apple music servers. So if you use macbooks (pro, air, mini) or apple tv they will play at a fixed sample rate. So if the ALAC source is encoded at 192 kHz sample rate, the devices will play at a fixed rate (ATV at 48 kHz, airplay at 44.1 kHz, macbooks at whatever sampling rate is set by the Audio Midi Setup App. So even if the source sent by the apple music server is a lossless stream, they will get played at a different sampling rate. However Ipad and Iphones can adjust the sampling rate as per the source. This essentially means that only Iphone and Ipads can play the music bit perfect. Macbooks can play bit perfect as long as you manually adjust the sampling rate for each and every song if it doesn't match the source sampling rate. Exception is the ATV which doesn't have any option to adjust the sampling rate and will always play at 48 kHz and airplay which will play only at 44.1 kHz.
Hope this explanation helps.