Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54385841 authored by jiabin's avatar jiabin
Browse files

Support 8 channel IEC61937.

There is no longer a requirement for IEC61937 streams to be stereo.
For high bit-rate streams they may have 8 channels.

Test: create AudioTrack with 8 channel IEC61937
Bug: 31916412
Change-Id: I4dfd3e78041a81601d5bde47a4deaa0313066028
parent e6791edb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -273,8 +273,8 @@ public final class AudioFormat implements Parcelable {

    /** Audio data format: compressed audio wrapped in PCM for HDMI
     * or S/PDIF passthrough.
     * IEC61937 uses a stereo stream of 16-bit samples as the wrapper.
     * So the channel mask for the track must be {@link #CHANNEL_OUT_STEREO}.
     * For devices whose SDK version is less than {@link android.os.Build.VERSION_CODES#S}, the
     * channel mask of IEC61937 track must be {@link #CHANNEL_OUT_STEREO}.
     * Data should be written to the stream in a short[] array.
     * If the data is written in a byte[] array then there may be endian problems
     * on some platforms when converting to short internally.
+4 −6
Original line number Diff line number Diff line
@@ -1676,13 +1676,11 @@ public class AudioTrack extends PlayerBase
        }
        mSampleRate = sampleRateInHz;

        // IEC61937 is based on stereo. We could coerce it to stereo.
        // But the application needs to know the stream is stereo so that
        // it is encoded and played correctly. So better to just reject it.
        if (audioFormat == AudioFormat.ENCODING_IEC61937
                && channelConfig != AudioFormat.CHANNEL_OUT_STEREO) {
            throw new IllegalArgumentException(
                    "ENCODING_IEC61937 must be configured as CHANNEL_OUT_STEREO");
                && channelConfig != AudioFormat.CHANNEL_OUT_STEREO
                && AudioFormat.channelCountFromOutChannelMask(channelConfig) != 8) {
            Log.w(TAG, "ENCODING_IEC61937 is configured with channel mask as " + channelConfig
                    + ", which is not 2 or 8 channels");
        }

        //--------------