Search in sources :

Example 6 with AudioFormat

use of com.google.android.exoplayer2.audio.AudioProcessor.AudioFormat in project ExoPlayer by google.

the class SonicAudioProcessorTest method reconfigureWithSameSampleRate.

@Test
public void reconfigureWithSameSampleRate() throws Exception {
    // When configured for resampling from 44.1 kHz to 48 kHz, the output sample rate is correct.
    sonicAudioProcessor.setOutputSampleRateHz(48000);
    AudioFormat outputAudioFormat = sonicAudioProcessor.configure(AUDIO_FORMAT_44100_HZ);
    assertThat(sonicAudioProcessor.isActive()).isTrue();
    assertThat(outputAudioFormat.sampleRate).isEqualTo(48000);
    // When reconfigured with 48 kHz input, there is no resampling.
    outputAudioFormat = sonicAudioProcessor.configure(AUDIO_FORMAT_48000_HZ);
    assertThat(sonicAudioProcessor.isActive()).isFalse();
    assertThat(outputAudioFormat.sampleRate).isEqualTo(48000);
    // When reconfigure with 44.1 kHz input, resampling is enabled again.
    outputAudioFormat = sonicAudioProcessor.configure(AUDIO_FORMAT_44100_HZ);
    assertThat(sonicAudioProcessor.isActive()).isTrue();
    assertThat(outputAudioFormat.sampleRate).isEqualTo(48000);
}
Also used : AudioFormat(com.google.android.exoplayer2.audio.AudioProcessor.AudioFormat) Test(org.junit.Test)

Aggregations

Format (com.google.android.exoplayer2.Format)3 Test (org.junit.Test)3 AudioFormat (com.google.android.exoplayer2.audio.AudioProcessor.AudioFormat)2 TracksInfo (com.google.android.exoplayer2.TracksInfo)1 AacUtil (com.google.android.exoplayer2.audio.AacUtil)1 UnhandledAudioFormatException (com.google.android.exoplayer2.audio.AudioProcessor.UnhandledAudioFormatException)1 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)1