Commit 1241c8c3 by samrobinson Committed by Oliver Woodman

Rollback of https://github.com/google/ExoPlayer/commit/59ecce6c857e51688371d4d06495940dad803b0f

*** Original commit ***

Rollback of https://github.com/google/ExoPlayer/commit/70273a0361cd3091858c0c9122c58ce9cb8ec62a

*** Original commit ***

Assert incoming buffers are little endian in the DefaultAudioSink.

***

***

PiperOrigin-RevId: 310889382
parent 159e3a80
...@@ -629,6 +629,7 @@ public final class DefaultAudioSink implements AudioSink { ...@@ -629,6 +629,7 @@ public final class DefaultAudioSink implements AudioSink {
if (inputBuffer == null) { if (inputBuffer == null) {
// We are seeing this buffer for the first time. // We are seeing this buffer for the first time.
Assertions.checkArgument(buffer.order() == ByteOrder.LITTLE_ENDIAN);
if (!buffer.hasRemaining()) { if (!buffer.hasRemaining()) {
// The buffer is empty. // The buffer is empty.
return true; return true;
......
...@@ -17,13 +17,11 @@ package com.google.android.exoplayer2.audio; ...@@ -17,13 +17,11 @@ package com.google.android.exoplayer2.audio;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/** /**
* An {@link AudioProcessor} that skips silence in the input stream. Input and output are 16-bit * An {@link AudioProcessor} that skips silence in the input stream. Input and output are 16-bit
...@@ -317,7 +315,6 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor { ...@@ -317,7 +315,6 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor {
* classified as a noisy frame, or the limit of the buffer if no such frame exists. * classified as a noisy frame, or the limit of the buffer if no such frame exists.
*/ */
private int findNoisePosition(ByteBuffer buffer) { private int findNoisePosition(ByteBuffer buffer) {
Assertions.checkArgument(buffer.order() == ByteOrder.LITTLE_ENDIAN);
// The input is in ByteOrder.nativeOrder(), which is little endian on Android. // The input is in ByteOrder.nativeOrder(), which is little endian on Android.
for (int i = buffer.position(); i < buffer.limit(); i += 2) { for (int i = buffer.position(); i < buffer.limit(); i += 2) {
if (Math.abs(buffer.getShort(i)) > SILENCE_THRESHOLD_LEVEL) { if (Math.abs(buffer.getShort(i)) > SILENCE_THRESHOLD_LEVEL) {
...@@ -333,7 +330,6 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor { ...@@ -333,7 +330,6 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor {
* from the byte position to the limit are classified as silent. * from the byte position to the limit are classified as silent.
*/ */
private int findNoiseLimit(ByteBuffer buffer) { private int findNoiseLimit(ByteBuffer buffer) {
Assertions.checkArgument(buffer.order() == ByteOrder.LITTLE_ENDIAN);
// The input is in ByteOrder.nativeOrder(), which is little endian on Android. // The input is in ByteOrder.nativeOrder(), which is little endian on Android.
for (int i = buffer.limit() - 2; i >= buffer.position(); i -= 2) { for (int i = buffer.limit() - 2; i >= buffer.position(); i -= 2) {
if (Math.abs(buffer.getShort(i)) > SILENCE_THRESHOLD_LEVEL) { if (Math.abs(buffer.getShort(i)) > SILENCE_THRESHOLD_LEVEL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment