Did anyone used AsyncTask with AsyncResult and AsyncExecutor in LibGDX? I want to run some audio recording and processing asynchronously with checking if result is ready. This is part of my code:
private FftAnalysis analysis;
private AsyncExecutor executor;
private AsyncResult<Double> asyncResult;
(...)
public GameWorld(int midPointY) {
executor = new AsyncExecutor(300); // I know how big this value is.
analysis = new FftAnalysis();
asyncResult = executor.submit(analysis);
}
public void update(float delta){
if(asyncResult.isDone()){
freq = asyncResult.get();
asyncResult = executor.submit(analysis);
}
The isDone() is never true and I don't see function call() from FftAnalysis ever executed...
What am I doing wrong?
Why not just using the libgdx api to do that? Have a look at the Timer class and Task class here: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Timer.html .
Basically you can run your code in a separate thread and get the result when it is finished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With