@Test public void testDoesNotSupportNon16BitInput() throws Exception { try { sonicAudioProcessor.configure(44100, 2, C.ENCODING_PCM_8BIT); fail(); } catch (AudioProcessor.UnhandledFormatException e) { } try { sonicAudioProcessor.configure(44100, 2, C.ENCODING_PCM_24BIT); fail(); } catch (AudioProcessor.UnhandledFormatException e) { } try { sonicAudioProcessor.configure(44100, 2, C.ENCODING_PCM_32BIT); fail(); } catch (AudioProcessor.UnhandledFormatException e) { } }
@Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } int outputSampleRateHz = pendingOutputSampleRateHz == SAMPLE_RATE_NO_CHANGE ? sampleRateHz : pendingOutputSampleRateHz; if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.outputSampleRateHz == outputSampleRateHz) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.outputSampleRateHz = outputSampleRateHz; pendingSonicRecreation = true; return true; }
SonicAudioProcessor implements AudioProcessor { @Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } int outputSampleRateHz = pendingOutputSampleRateHz == SAMPLE_RATE_NO_CHANGE ? sampleRateHz : pendingOutputSampleRateHz; if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.outputSampleRateHz == outputSampleRateHz) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.outputSampleRateHz = outputSampleRateHz; pendingSonicRecreation = true; return true; } }
SonicAudioProcessor implements AudioProcessor { @Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } int outputSampleRateHz = pendingOutputSampleRateHz == SAMPLE_RATE_NO_CHANGE ? sampleRateHz : pendingOutputSampleRateHz; if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.outputSampleRateHz == outputSampleRateHz) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.outputSampleRateHz = outputSampleRateHz; pendingSonicRecreation = true; return true; } SonicAudioProcessor(); }
SonicAudioProcessor implements AudioProcessor { @Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } int outputSampleRateHz = pendingOutputSampleRateHz == SAMPLE_RATE_NO_CHANGE ? sampleRateHz : pendingOutputSampleRateHz; if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.outputSampleRateHz == outputSampleRateHz) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.outputSampleRateHz = outputSampleRateHz; pendingSonicRecreation = true; return true; } SonicAudioProcessor(); float setSpeed(float speed); float setPitch(float pitch); void setOutputSampleRateHz(int sampleRateHz); long scaleDurationForSpeedup(long duration); @Override boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding); @Override boolean isActive(); @Override int getOutputChannelCount(); @Override int getOutputEncoding(); @Override int getOutputSampleRateHz(); @Override void queueInput(ByteBuffer inputBuffer); @Override void queueEndOfStream(); @Override ByteBuffer getOutput(); @Override boolean isEnded(); @Override void flush(); @Override void reset(); }
SonicAudioProcessor implements AudioProcessor { @Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } int outputSampleRateHz = pendingOutputSampleRateHz == SAMPLE_RATE_NO_CHANGE ? sampleRateHz : pendingOutputSampleRateHz; if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.outputSampleRateHz == outputSampleRateHz) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.outputSampleRateHz = outputSampleRateHz; pendingSonicRecreation = true; return true; } SonicAudioProcessor(); float setSpeed(float speed); float setPitch(float pitch); void setOutputSampleRateHz(int sampleRateHz); long scaleDurationForSpeedup(long duration); @Override boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding); @Override boolean isActive(); @Override int getOutputChannelCount(); @Override int getOutputEncoding(); @Override int getOutputSampleRateHz(); @Override void queueInput(ByteBuffer inputBuffer); @Override void queueEndOfStream(); @Override ByteBuffer getOutput(); @Override boolean isEnded(); @Override void flush(); @Override void reset(); static final float MAXIMUM_SPEED; static final float MINIMUM_SPEED; static final float MAXIMUM_PITCH; static final float MINIMUM_PITCH; static final int SAMPLE_RATE_NO_CHANGE; }