Playing AAC multichannel (5.1 surround) audio stream on Apple TV

I have written a tvOS app which receives AAC 5.1 audio stream over the network and I am using AudioToolbox to decode (mFormatID = kAudioFormatMPEGAAC) to 5.1 channels. But I only hear 2 channels (Stereo) outputs on my 5.1 surround system (which is connected to the TV using an Audio Optical cable).

I am not sure why PCM multi-channel is not outputting from AppleTV. Am I missing anything?

Decoder parameters:

    AudioStreamBasicDescription asbd
= {0};

    asbd.mFormatID =
kAudioFormatMPEG4AAC;

    asbd.mFormatFlags =
kMPEG4Object_AAC_Main;

    asbd.mSampleRate = samplingRate;

    asbd.mBitsPerChannel = 0;

    asbd.mBytesPerPacket = 0; 

    asbd.mFramesPerPacket = 1024;

    asbd.mBytesPerFrame = 0;。

    asbd.mChannelsPerFrame = numOfChannels; // 6

    asbd.mBitsPerChannel = 0; 

    asbd.mReserved = 0; 

Additionally, when I query the total number of audio channels on AppleTV, it is always 2 (even though it is connected to the surround system). This is just for me to know audio capabilities.

AVAudioSession.sharedInstance().currentRoute.outputs[0].channels

Replies

An optical cable haven't got enough bandwidth to transmit 6 channels of PCM audio. It can only do 6 channels of AC3 or DTS.

I don't remember if the AppleTV will automatically convert it to AC3 if you set it to do so in the AppleTV settings.

  • Okay, I will try to connect with HDMI ARC and see if anything changes. But I am curious about the AppleTV decoder as it does not do passthrough. Isn't all formats (like AAC, AC3, or DTS) will be decoded into uncompressed multiple PCM audio channels by AppleTV? Or is there a difference in output for each format?

Add a Comment