Skip to content

Commit

Permalink
handling cancel on window close
Browse files Browse the repository at this point in the history
  • Loading branch information
yermak committed Jan 18, 2018
1 parent 18fef91 commit 3ea8696
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,21 @@ public void concat() throws IOException, ExecutionException, InterruptedExceptio

@Override
public void finishedWithError(String error) {

Utils.closeSilently(executorService);
// Utils.closeSilently(progressParser);
}

@Override
public void finished() {

Utils.closeSilently(executorService);
// Utils.closeSilently(progressParser);
}

@Override
public void canceled() {
cancelled = true;
Utils.closeSilently(executorService);
// Utils.closeSilently(progressParser);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class FFMpegConverter implements Callable<ConverterOutput>, Converter, St
private boolean paused;
private Process process;
private final static String FFMPEG = new File("external/x64/ffmpeg.exe").getAbsolutePath();
private ProgressParser progressParser = null;


public FFMpegConverter(MediaInfo mediaInfo, String outputFileName, ProgressCallback callback) {
Expand All @@ -32,7 +33,6 @@ public FFMpegConverter(MediaInfo mediaInfo, String outputFileName, ProgressCallb
}

public ConverterOutput convertMp3toM4a() throws IOException, InterruptedException, ExecutionException {
ProgressParser progressParser = null;
try {
mutex.acquire();
if (cancelled) return null;
Expand Down Expand Up @@ -90,17 +90,21 @@ public ConverterOutput call() throws Exception {

@Override
public void finishedWithError(String error) {

Utils.closeSilently(executorService);
// Utils.closeSilently(progressParser);
}

@Override
public void finished() {
Utils.closeSilently(executorService);
// Utils.closeSilently(progressParser);
}

@Override
public void canceled() {
this.cancelled = true;
Utils.closeSilently(executorService);
// Utils.closeSilently(progressParser);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ParallelConversionStrategy extends AbstractConversionStrategy imple


protected void startConversion() {
Executors.newWorkStealingPool().execute(this);
executorService.execute(this);
}

public void run() {
Expand Down

0 comments on commit 3ea8696

Please sign in to comment.