Remove forCancellation flag from Transformer/Muxer.release() method
PiperOrigin-RevId: 630337930
This commit is contained in:
parent
10e29be8b6
commit
24305c043e
@ -469,8 +469,8 @@ public class TransformerPauseResumeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release(boolean forCancellation) throws MuxerException {
|
public void release() throws MuxerException {
|
||||||
wrappedMuxer.release(forCancellation);
|
wrappedMuxer.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public final class DefaultMuxer implements Muxer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release(boolean forCancellation) throws MuxerException {
|
public void release() throws MuxerException {
|
||||||
muxer.release(forCancellation);
|
muxer.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
/** {@link Muxer} implementation that uses a {@link MediaMuxer}. */
|
/** {@link Muxer} implementation that uses a {@link MediaMuxer}. */
|
||||||
/* package */ final class FrameworkMuxer implements Muxer {
|
/* package */ final class FrameworkMuxer implements Muxer {
|
||||||
|
public static final String MUXER_STOPPING_FAILED_ERROR_MESSAGE = "Failed to stop the MediaMuxer";
|
||||||
|
|
||||||
// MediaMuxer supported sample formats are documented in MediaMuxer.addTrack(MediaFormat).
|
// MediaMuxer supported sample formats are documented in MediaMuxer.addTrack(MediaFormat).
|
||||||
private static final ImmutableList<String> SUPPORTED_VIDEO_SAMPLE_MIME_TYPES =
|
private static final ImmutableList<String> SUPPORTED_VIDEO_SAMPLE_MIME_TYPES =
|
||||||
getSupportedVideoSampleMimeTypes();
|
getSupportedVideoSampleMimeTypes();
|
||||||
@ -193,7 +195,7 @@ import java.util.Map;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release(boolean forCancellation) throws MuxerException {
|
public void release() throws MuxerException {
|
||||||
if (isReleased) {
|
if (isReleased) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -218,10 +220,7 @@ import java.util.Map;
|
|||||||
try {
|
try {
|
||||||
stopMuxer(mediaMuxer);
|
stopMuxer(mediaMuxer);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
// It doesn't matter that stopping the muxer throws if the export is being cancelled.
|
throw new MuxerException(MUXER_STOPPING_FAILED_ERROR_MESSAGE, e);
|
||||||
if (!forCancellation) {
|
|
||||||
throw new MuxerException("Failed to stop the muxer", e);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
mediaMuxer.release();
|
mediaMuxer.release();
|
||||||
isReleased = true;
|
isReleased = true;
|
||||||
|
@ -202,7 +202,7 @@ public final class InAppMuxer implements Muxer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release(boolean forCancellation) throws MuxerException {
|
public void release() throws MuxerException {
|
||||||
writeMetadata();
|
writeMetadata();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -31,8 +31,8 @@ import java.nio.ByteBuffer;
|
|||||||
* <p>Query whether {@linkplain Factory#getSupportedSampleMimeTypes(int) sample MIME types} are
|
* <p>Query whether {@linkplain Factory#getSupportedSampleMimeTypes(int) sample MIME types} are
|
||||||
* supported and {@linkplain #addTrack(Format) add all tracks}, then {@linkplain #writeSampleData
|
* supported and {@linkplain #addTrack(Format) add all tracks}, then {@linkplain #writeSampleData
|
||||||
* write sample data} to mux samples. Once any sample data has been written, it is not possible to
|
* write sample data} to mux samples. Once any sample data has been written, it is not possible to
|
||||||
* add tracks. After writing all sample data, {@linkplain #release(boolean) release} the instance to
|
* add tracks. After writing all sample data, {@linkplain #release() release} the instance to finish
|
||||||
* finish writing to the output and return any resources to the system.
|
* writing to the output and return any resources to the system.
|
||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
// TODO: b/330695864 - Replace with the Muxer interface from the Muxer module.
|
// TODO: b/330695864 - Replace with the Muxer interface from the Muxer module.
|
||||||
@ -99,10 +99,8 @@ public interface Muxer {
|
|||||||
*
|
*
|
||||||
* <p>The muxer cannot be used anymore once this method has been called.
|
* <p>The muxer cannot be used anymore once this method has been called.
|
||||||
*
|
*
|
||||||
* @param forCancellation Whether the reason for releasing the resources is the export
|
|
||||||
* cancellation.
|
|
||||||
* @throws MuxerException If the muxer fails to finish writing the output and {@code
|
* @throws MuxerException If the muxer fails to finish writing the output and {@code
|
||||||
* forCancellation} is false.
|
* forCancellation} is false.
|
||||||
*/
|
*/
|
||||||
void release(boolean forCancellation) throws MuxerException;
|
void release() throws MuxerException;
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,18 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
isReady = false;
|
isReady = false;
|
||||||
abortScheduledExecutorService.shutdownNow();
|
abortScheduledExecutorService.shutdownNow();
|
||||||
if (muxer != null) {
|
if (muxer != null) {
|
||||||
muxer.release(releaseReason == MUXER_RELEASE_REASON_CANCELLED);
|
try {
|
||||||
|
muxer.release();
|
||||||
|
} catch (Muxer.MuxerException e) {
|
||||||
|
if (releaseReason == MUXER_RELEASE_REASON_CANCELLED
|
||||||
|
&& checkNotNull(e.getMessage())
|
||||||
|
.equals(FrameworkMuxer.MUXER_STOPPING_FAILED_ERROR_MESSAGE)) {
|
||||||
|
// When releasing the muxer, FrameworkMuxer may sometimes fail before the actual release.
|
||||||
|
// When the release is due to cancellation, swallow this exception.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,9 +142,9 @@ public final class CapturingMuxer implements Muxer, Dumpable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release(boolean forCancellation) throws MuxerException {
|
public void release() throws MuxerException {
|
||||||
released = true;
|
released = true;
|
||||||
wrappedMuxer.release(forCancellation);
|
wrappedMuxer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dumper.Dumpable implementation.
|
// Dumper.Dumpable implementation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user