Create ExportException for audio from UnhandledAudioFormatException.

All audio processing export errors are related to a UAFE - passing
audioFormat separately is redundant.

PiperOrigin-RevId: 549427685
This commit is contained in:
samrobinson 2023-07-19 22:32:17 +01:00 committed by Ian Baker
parent cdb174c91a
commit beceb996ac
3 changed files with 9 additions and 8 deletions

View file

@ -106,7 +106,7 @@ import java.util.concurrent.atomic.AtomicReference;
try {
reconfigureProcessingForPendingMediaItem();
} catch (AudioProcessor.UnhandledAudioFormatException e) {
throw ExportException.createForAudioProcessing(e, e.inputAudioFormat);
throw ExportException.createForAudioProcessing(e, "AudioGraph reconfiguration");
}
}

View file

@ -60,7 +60,7 @@ import org.checkerframework.dataflow.qual.Pure;
try {
audioGraph = new AudioGraph(firstExporterInputFormat, firstEditedMediaItem);
} catch (AudioProcessor.UnhandledAudioFormatException e) {
throw ExportException.createForAudioProcessing(e, e.inputAudioFormat);
throw ExportException.createForAudioProcessing(e, "AudioGraph initialization");
}
encoderInputAudioFormat = audioGraph.getOutputAudioFormat();
checkState(!encoderInputAudioFormat.equals(AudioFormat.NOT_SET));

View file

@ -23,7 +23,7 @@ import androidx.annotation.Nullable;
import androidx.media3.common.Format;
import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.audio.AudioProcessor.AudioFormat;
import androidx.media3.common.audio.AudioProcessor.UnhandledAudioFormatException;
import androidx.media3.common.util.Clock;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
@ -283,14 +283,15 @@ public final class ExportException extends Exception {
/**
* Creates an instance for an audio processing related exception.
*
* @param cause The cause of the failure.
* @param audioFormat The {@link AudioFormat} used.
* @param exception The cause of the failure.
* @param details The details associated with this exception.
* @return The created instance.
*/
public static ExportException createForAudioProcessing(Throwable cause, AudioFormat audioFormat) {
public static ExportException createForAudioProcessing(
UnhandledAudioFormatException exception, String details) {
return new ExportException(
"Audio processing error, audio_format=" + audioFormat,
cause,
"Audio error: " + details + ", audioFormat=" + exception.inputAudioFormat,
exception,
ERROR_CODE_AUDIO_PROCESSING_FAILED);
}