mirror of
https://github.com/samsonjs/media.git
synced 2026-06-28 05:29:33 +00:00
Add a constructor for AudioFormat that takes Format.
PiperOrigin-RevId: 541662208
This commit is contained in:
parent
69769c77b3
commit
74948d5424
3 changed files with 10 additions and 8 deletions
|
|
@ -59,6 +59,14 @@ public interface AudioProcessor {
|
|||
/** The number of bytes used to represent one audio frame. */
|
||||
public final int bytesPerFrame;
|
||||
|
||||
/**
|
||||
* Creates an instance using the {@link Format#sampleRate}, {@link Format#channelCount} and
|
||||
* {@link Format#pcmEncoding}.
|
||||
*/
|
||||
public AudioFormat(Format format) {
|
||||
this(format.sampleRate, format.channelCount, format.pcmEncoding);
|
||||
}
|
||||
|
||||
public AudioFormat(int sampleRate, int channelCount, @C.PcmEncoding int encoding) {
|
||||
this.sampleRate = sampleRate;
|
||||
this.channelCount = channelCount;
|
||||
|
|
|
|||
|
|
@ -674,9 +674,7 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
}
|
||||
channelMappingAudioProcessor.setChannelMap(outputChannels);
|
||||
|
||||
AudioProcessor.AudioFormat outputFormat =
|
||||
new AudioProcessor.AudioFormat(
|
||||
inputFormat.sampleRate, inputFormat.channelCount, inputFormat.pcmEncoding);
|
||||
AudioProcessor.AudioFormat outputFormat = new AudioProcessor.AudioFormat(inputFormat);
|
||||
try {
|
||||
outputFormat = audioProcessingPipeline.configure(outputFormat);
|
||||
} catch (UnhandledAudioFormatException e) {
|
||||
|
|
|
|||
|
|
@ -83,11 +83,7 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||
encoderOutputBuffer = new DecoderInputBuffer(BUFFER_REPLACEMENT_MODE_DISABLED);
|
||||
|
||||
checkArgument(firstPipelineInputFormat.pcmEncoding != Format.NO_VALUE);
|
||||
AudioFormat inputAudioFormat =
|
||||
new AudioFormat(
|
||||
firstPipelineInputFormat.sampleRate,
|
||||
firstPipelineInputFormat.channelCount,
|
||||
firstPipelineInputFormat.pcmEncoding);
|
||||
AudioFormat inputAudioFormat = new AudioFormat(firstPipelineInputFormat);
|
||||
|
||||
silentAudioGenerator = new SilentAudioGenerator(inputAudioFormat);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue