mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Assert silent bytes are 0 in AudioGraphInputTest
PiperOrigin-RevId: 668403467
This commit is contained in:
parent
84f4c7bbcc
commit
9c5ea4f1ba
@ -410,8 +410,7 @@ public class AudioGraphInputTest {
|
|||||||
List<Byte> outputBytes = drainAudioGraphInputUntilEnded(audioGraphInput);
|
List<Byte> outputBytes = drainAudioGraphInputUntilEnded(audioGraphInput);
|
||||||
long expectedSampleCount = Util.durationUsToSampleCount(1_000_000, STEREO_44100.sampleRate);
|
long expectedSampleCount = Util.durationUsToSampleCount(1_000_000, STEREO_44100.sampleRate);
|
||||||
// Silent audio generator rounds up duration.
|
// Silent audio generator rounds up duration.
|
||||||
assertThat(outputBytes.size())
|
assertThat(outputBytes).hasSize((int) ((expectedSampleCount + 1) * STEREO_44100.bytesPerFrame));
|
||||||
.isEqualTo((expectedSampleCount + 1) * STEREO_44100.bytesPerFrame);
|
|
||||||
assertThat(outputBytes.subList(0, inputData.length))
|
assertThat(outputBytes.subList(0, inputData.length))
|
||||||
.containsExactlyElementsIn(Bytes.asList(inputData))
|
.containsExactlyElementsIn(Bytes.asList(inputData))
|
||||||
.inOrder();
|
.inOrder();
|
||||||
@ -452,8 +451,7 @@ public class AudioGraphInputTest {
|
|||||||
List<Byte> outputBytes = drainAudioGraphInputUntilEnded(audioGraphInput);
|
List<Byte> outputBytes = drainAudioGraphInputUntilEnded(audioGraphInput);
|
||||||
long expectedSampleCount = Util.durationUsToSampleCount(500_000, STEREO_44100.sampleRate);
|
long expectedSampleCount = Util.durationUsToSampleCount(500_000, STEREO_44100.sampleRate);
|
||||||
// Silent audio generator rounds up duration.
|
// Silent audio generator rounds up duration.
|
||||||
assertThat(outputBytes.size())
|
assertThat(outputBytes).hasSize((int) ((expectedSampleCount + 1) * STEREO_44100.bytesPerFrame));
|
||||||
.isEqualTo((expectedSampleCount + 1) * STEREO_44100.bytesPerFrame);
|
|
||||||
// Sonic takes a while to zero-out the input.
|
// Sonic takes a while to zero-out the input.
|
||||||
assertThat(min(outputBytes.subList(inputData.length * 6 / 10, outputBytes.size())))
|
assertThat(min(outputBytes.subList(inputData.length * 6 / 10, outputBytes.size())))
|
||||||
.isEqualTo(0);
|
.isEqualTo(0);
|
||||||
@ -462,8 +460,7 @@ public class AudioGraphInputTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getOutput_withSilentMediaItemChange_outputsCorrectAmountOfSilentBytes()
|
public void getOutput_withSilentMediaItemChange_outputsCorrectSilentBytes() throws Exception {
|
||||||
throws Exception {
|
|
||||||
AudioGraphInput audioGraphInput =
|
AudioGraphInput audioGraphInput =
|
||||||
new AudioGraphInput(
|
new AudioGraphInput(
|
||||||
/* requestedOutputAudioFormat= */ AudioFormat.NOT_SET,
|
/* requestedOutputAudioFormat= */ AudioFormat.NOT_SET,
|
||||||
@ -476,13 +473,15 @@ public class AudioGraphInputTest {
|
|||||||
/* decodedFormat= */ null,
|
/* decodedFormat= */ null,
|
||||||
/* isLast= */ true);
|
/* isLast= */ true);
|
||||||
|
|
||||||
int bytesOutput = drainAudioGraphInputUntilEnded(audioGraphInput).size();
|
List<Byte> bytesOutput = drainAudioGraphInputUntilEnded(audioGraphInput);
|
||||||
long expectedSampleCount = Util.durationUsToSampleCount(1_000_000, STEREO_44100.sampleRate);
|
long expectedSampleCount = Util.durationUsToSampleCount(1_000_000, STEREO_44100.sampleRate);
|
||||||
assertThat(bytesOutput).isEqualTo(expectedSampleCount * STEREO_44100.bytesPerFrame);
|
assertThat(bytesOutput).hasSize((int) (expectedSampleCount * STEREO_44100.bytesPerFrame));
|
||||||
|
assertThat(min(bytesOutput)).isEqualTo(0);
|
||||||
|
assertThat(max(bytesOutput)).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getOutput_withThreeSilentMediaItemChanges_outputsCorrectAmountOfSilentBytes()
|
public void getOutput_withThreeSilentMediaItemChanges_outputsCorrectSilentBytes()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
AudioGraphInput audioGraphInput =
|
AudioGraphInput audioGraphInput =
|
||||||
new AudioGraphInput(
|
new AudioGraphInput(
|
||||||
@ -506,13 +505,15 @@ public class AudioGraphInputTest {
|
|||||||
/* decodedFormat= */ null,
|
/* decodedFormat= */ null,
|
||||||
/* isLast= */ true);
|
/* isLast= */ true);
|
||||||
|
|
||||||
int bytesOutput = drainAudioGraphInputUntilEnded(audioGraphInput).size();
|
List<Byte> bytesOutput = drainAudioGraphInputUntilEnded(audioGraphInput);
|
||||||
long expectedSampleCount = Util.durationUsToSampleCount(1_000_000, STEREO_44100.sampleRate);
|
long expectedSampleCount = Util.durationUsToSampleCount(1_000_000, STEREO_44100.sampleRate);
|
||||||
assertThat(bytesOutput).isEqualTo(expectedSampleCount * STEREO_44100.bytesPerFrame);
|
assertThat(bytesOutput).hasSize((int) (expectedSampleCount * STEREO_44100.bytesPerFrame));
|
||||||
|
assertThat(min(bytesOutput)).isEqualTo(0);
|
||||||
|
assertThat(max(bytesOutput)).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getOutput_withSilentMediaItemAndEffectsChange_outputsCorrectAmountOfSilentBytes()
|
public void getOutput_withSilentMediaItemAndEffectsChange_outputsCorrectSilentBytes()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
AudioGraphInput audioGraphInput =
|
AudioGraphInput audioGraphInput =
|
||||||
new AudioGraphInput(
|
new AudioGraphInput(
|
||||||
@ -526,9 +527,11 @@ public class AudioGraphInputTest {
|
|||||||
/* decodedFormat= */ null,
|
/* decodedFormat= */ null,
|
||||||
/* isLast= */ true);
|
/* isLast= */ true);
|
||||||
|
|
||||||
int bytesOutput = drainAudioGraphInputUntilEnded(audioGraphInput).size();
|
List<Byte> bytesOutput = drainAudioGraphInputUntilEnded(audioGraphInput);
|
||||||
long expectedSampleCount = Util.durationUsToSampleCount(500_000, STEREO_44100.sampleRate);
|
long expectedSampleCount = Util.durationUsToSampleCount(500_000, STEREO_44100.sampleRate);
|
||||||
assertThat(bytesOutput).isEqualTo(expectedSampleCount * STEREO_44100.bytesPerFrame);
|
assertThat(bytesOutput).hasSize((int) (expectedSampleCount * STEREO_44100.bytesPerFrame));
|
||||||
|
assertThat(min(bytesOutput)).isEqualTo(0);
|
||||||
|
assertThat(max(bytesOutput)).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user