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

Commit 9039385c authored by Phil Burk's avatar Phil Burk Committed by android-build-merger
Browse files

Merge "Audio ENCODING_IEC61937: enforce use of CHANNEL_OUT_STEREO" into nyc-dev am: 566e7212

am: 9a6de33b

* commit '9a6de33b':
  Audio ENCODING_IEC61937: enforce use of CHANNEL_OUT_STEREO
parents 6346a070 9a6de33b
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -256,6 +256,11 @@ public final class AudioFormat implements Parcelable {
    public static final int ENCODING_AAC_HE_V2 = 12;
    public static final int ENCODING_AAC_HE_V2 = 12;
    /** Audio data format: compressed audio wrapped in PCM for HDMI
    /** Audio data format: compressed audio wrapped in PCM for HDMI
     * or S/PDIF passthrough.
     * 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}.
     * 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.
     */
     */
    public static final int ENCODING_IEC61937 = 13;
    public static final int ENCODING_IEC61937 = 13;


+9 −0
Original line number Original line Diff line number Diff line
@@ -806,6 +806,15 @@ public class AudioTrack implements AudioRouting
        }
        }
        mSampleRate = sampleRateInHz;
        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");
        }

        //--------------
        //--------------
        // channel config
        // channel config
        mChannelConfiguration = channelConfig;
        mChannelConfiguration = channelConfig;