Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class FFcommandExecuteAsyncTask extends AsyncTask<Void, String, CommandResult> i
private final long timeout;
private long startTime;
private Process process;
private StringBuilder outputStringBuilder = new StringBuilder();
private String output = "";
private boolean quitPending;

Expand All @@ -39,23 +40,27 @@ protected void onPreExecute() {

@Override
protected CommandResult doInBackground(Void... params) {
CommandResult ret = CommandResult.getDummyFailureResponse();
try {
process = shellCommand.run(cmd, environment);
if (process == null) {
return CommandResult.getDummyFailureResponse();
}
Log.d("Running publishing updates method");
checkAndUpdateProcess();
return CommandResult.getOutputFromProcess(process);
ret = CommandResult.getOutputFromProcess(process);
outputStringBuilder.append(ret.output);
} catch (TimeoutException e) {
Log.e("FFmpeg binary timed out", e);
return new CommandResult(false, e.getMessage());
ret = new CommandResult(false, e.getMessage());
outputStringBuilder.append(ret.output);
} catch (Exception e) {
Log.e("Error running FFmpeg binary", e);
} finally {
Util.destroyProcess(process);
}
return CommandResult.getDummyFailureResponse();
output = outputStringBuilder.toString();
return ret;
}

@Override
Expand All @@ -68,7 +73,6 @@ protected void onProgressUpdate(String... values) {
@Override
protected void onPostExecute(CommandResult commandResult) {
if (ffmpegExecuteResponseHandler != null) {
output += commandResult.output;
if (commandResult.success) {
ffmpegExecuteResponseHandler.onSuccess(output);
} else {
Expand Down Expand Up @@ -107,7 +111,7 @@ private void checkAndUpdateProcess() throws TimeoutException, InterruptedExcepti
return;
}

output += line + "\n";
outputStringBuilder.append(line); outputStringBuilder.append("\n");
publishProgress(line);
}
} catch (IOException e) {
Expand Down