mirror of
https://github.com/samsonjs/media.git
synced 2026-04-17 13:15:47 +00:00
Rollback of 70273a0361
*** Original commit *** Assert incoming buffers are little endian in the DefaultAudioSink. *** PiperOrigin-RevId: 310377513
This commit is contained in:
parent
9a4ec54bdf
commit
59ecce6c85
2 changed files with 4 additions and 1 deletions
|
|
@ -629,7 +629,6 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
|
||||
if (inputBuffer == null) {
|
||||
// We are seeing this buffer for the first time.
|
||||
Assertions.checkArgument(buffer.order() == ByteOrder.LITTLE_ENDIAN);
|
||||
if (!buffer.hasRemaining()) {
|
||||
// The buffer is empty.
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -17,11 +17,13 @@ package com.google.android.exoplayer2.audio;
|
|||
|
||||
import androidx.annotation.IntDef;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/**
|
||||
* An {@link AudioProcessor} that skips silence in the input stream. Input and output are 16-bit
|
||||
|
|
@ -315,6 +317,7 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor {
|
|||
* classified as a noisy frame, or the limit of the buffer if no such frame exists.
|
||||
*/
|
||||
private int findNoisePosition(ByteBuffer buffer) {
|
||||
Assertions.checkArgument(buffer.order() == ByteOrder.LITTLE_ENDIAN);
|
||||
// The input is in ByteOrder.nativeOrder(), which is little endian on Android.
|
||||
for (int i = buffer.position(); i < buffer.limit(); i += 2) {
|
||||
if (Math.abs(buffer.getShort(i)) > SILENCE_THRESHOLD_LEVEL) {
|
||||
|
|
@ -330,6 +333,7 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor {
|
|||
* from the byte position to the limit are classified as silent.
|
||||
*/
|
||||
private int findNoiseLimit(ByteBuffer buffer) {
|
||||
Assertions.checkArgument(buffer.order() == ByteOrder.LITTLE_ENDIAN);
|
||||
// The input is in ByteOrder.nativeOrder(), which is little endian on Android.
|
||||
for (int i = buffer.limit() - 2; i >= buffer.position(); i -= 2) {
|
||||
if (Math.abs(buffer.getShort(i)) > SILENCE_THRESHOLD_LEVEL) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue