Skip to content

Commit

Permalink
Reduce test flakes by adding effects to multi-sequence playback test.
Browse files Browse the repository at this point in the history
This test is flaky at p4head, because CompositionPlayer has no logic to
ensure a specific input is used to configure the audio graph. Depending
on which sequence registers input first, it changes the output format
of the media.

By setting effects on the 2nd sequence, both inputs are the same format
and this flakiness is avoided in the test.

PiperOrigin-RevId: 653582441
  • Loading branch information
Samrobbo authored and copybara-github committed Jul 18, 2024
1 parent e28270b commit 570be36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import static androidx.media3.transformer.TestUtil.FILE_AUDIO_RAW;
import static androidx.media3.transformer.TestUtil.FILE_AUDIO_RAW_STEREO_48000KHZ;
import static androidx.media3.transformer.TestUtil.createAudioEffects;
import static androidx.media3.transformer.TestUtil.createChannelCountChangingAudioProcessor;
import static androidx.media3.transformer.TestUtil.createSampleRateChangingAudioProcessor;
import static androidx.media3.transformer.TestUtil.createVolumeScalingAudioProcessor;

import android.content.Context;
Expand Down Expand Up @@ -215,6 +217,10 @@ public void multiSequenceCompositionPlayback_outputsCorrectSamples() throws Exce
new EditedMediaItem.Builder(
MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_RAW_STEREO_48000KHZ))
.setDurationUs(348_000L)
.setEffects(
createAudioEffects(
createSampleRateChangingAudioProcessor(44100),
createChannelCountChangingAudioProcessor(1)))
.build();
Composition composition =
new Composition.Builder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public static Effects createAudioEffects(AudioProcessor... audioProcessors) {
ImmutableList.copyOf(audioProcessors), /* videoEffects= */ ImmutableList.of());
}

public static SonicAudioProcessor createSampleRateChangingAudioProcessor(int sampleRate) {
SonicAudioProcessor sonicAudioProcessor = new SonicAudioProcessor();
sonicAudioProcessor.setOutputSampleRateHz(sampleRate);
return sonicAudioProcessor;
}

public static SonicAudioProcessor createPitchChangingAudioProcessor(float pitch) {
SonicAudioProcessor sonicAudioProcessor = new SonicAudioProcessor();
sonicAudioProcessor.setPitch(pitch);
Expand Down

0 comments on commit 570be36

Please sign in to comment.