Do not bother with exceptions during exporting when process was cancelled
This commit is contained in:
@@ -39,6 +39,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private final ReplaySender replaySender;
|
||||
private final RenderOptions options;
|
||||
private final VideoWriter videoWriter;
|
||||
|
||||
private int fps;
|
||||
private boolean mouseWasGrabbed;
|
||||
@@ -60,7 +61,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
this.gui = new GuiVideoRenderer(this);
|
||||
this.replaySender = ReplayMod.replaySender;
|
||||
this.options = options;
|
||||
this.renderingPipeline = Pipelines.newPipeline(options.getMode(), this, new VideoWriter(options) {
|
||||
this.renderingPipeline = Pipelines.newPipeline(options.getMode(), this, videoWriter = new VideoWriter(options) {
|
||||
@Override
|
||||
public void consume(RGBFrame frame) {
|
||||
gui.updatePreview(frame);
|
||||
@@ -418,6 +419,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
videoWriter.abort();
|
||||
this.cancelled = true;
|
||||
renderingPipeline.cancel();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
private final OutputStream outputStream;
|
||||
private final WritableByteChannel channel;
|
||||
private final String commandArgs;
|
||||
private volatile boolean aborted;
|
||||
|
||||
public VideoWriter(final RenderOptions options) throws IOException {
|
||||
this.options = options.copy();
|
||||
@@ -90,6 +91,9 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
channel.write(frame.getByteBuffer());
|
||||
ByteBufferPool.release(frame.getByteBuffer());
|
||||
} catch (Throwable t) {
|
||||
if (aborted) {
|
||||
return;
|
||||
}
|
||||
CrashReport report = CrashReport.makeCrashReport(t, "Exporting frame");
|
||||
CrashReportCategory exportDetails = report.makeCategory("Export details");
|
||||
exportDetails.addCrashSection("Export command", options.getExportCommand());
|
||||
@@ -106,4 +110,8 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
isTrue(width == options.getWidth(), "Width has to be %d but was %d", options.getWidth(), width);
|
||||
isTrue(height == options.getHeight(), "Height has to be %d but was %d", options.getHeight(), height);
|
||||
}
|
||||
|
||||
public void abort() {
|
||||
aborted = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user