Skip to content
Closed
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
Execute the Async task in serial
If ffmpeg should be limited to one process the async task that calls
the process should be executed in serial. This means you can execute
multiple async ffmpeg commands at once and they will be executed in
serial
  • Loading branch information
bperin committed Dec 7, 2014
commit 06f76573ca3dc3a93c657d97683186ab3317446d
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.hiteshsondhi88.libffmpeg;

import java.util.Map;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;

import java.util.Map;

import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException;
import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException;

Expand Down Expand Up @@ -60,15 +60,13 @@ public void loadBinary(FFmpegLoadBinaryResponseHandler ffmpegLoadBinaryResponseH
}
}

@Override
@SuppressLint("NewApi") @Override
public void execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
if (ffmpegExecuteAsyncTask != null && !ffmpegExecuteAsyncTask.isProcessCompleted()) {
throw new FFmpegCommandAlreadyRunningException("FFmpeg command is already running, you are only allowed to run single command at a time");
}

if (!TextUtils.isEmpty(cmd)) {
String ffmpegCmd = FileUtils.getFFmpeg(context, environvenmentVars) + " "+ cmd;
ffmpegExecuteAsyncTask = new FFmpegExecuteAsyncTask(ffmpegCmd, timeout, ffmpegExecuteResponseHandler);
ffmpegExecuteAsyncTask.execute();
FFmpegExecuteAsyncTask ffmpegExecuteAsyncTask = new FFmpegExecuteAsyncTask(ffmpegCmd, timeout, ffmpegExecuteResponseHandler);
ffmpegExecuteAsyncTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
} else {
throw new IllegalArgumentException("shell command cannot be empty");
}
Expand Down