|
|
@ -46,15 +46,6 @@ public class VideoRecorderAppState extends AbstractAppState { |
|
|
|
return th; |
|
|
|
return th; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
private ExecutorService writeThread = Executors.newSingleThreadExecutor(new ThreadFactory() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Thread newThread(Runnable r) { |
|
|
|
|
|
|
|
Thread th = new Thread(r); |
|
|
|
|
|
|
|
th.setName("jME Video Writing Thread"); |
|
|
|
|
|
|
|
th.setDaemon(true); |
|
|
|
|
|
|
|
return th; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
private int numCpus = Runtime.getRuntime().availableProcessors(); |
|
|
|
private int numCpus = Runtime.getRuntime().availableProcessors(); |
|
|
|
|
|
|
|
|
|
|
|
public VideoRecorderAppState(File file) { |
|
|
|
public VideoRecorderAppState(File file) { |
|
|
@ -125,17 +116,11 @@ public class VideoRecorderAppState extends AbstractAppState { |
|
|
|
Screenshots.convertScreenShot(item.buffer, item.image); |
|
|
|
Screenshots.convertScreenShot(item.buffer, item.image); |
|
|
|
item.data = writer.writeImageToBytes(item.image); |
|
|
|
item.data = writer.writeImageToBytes(item.image); |
|
|
|
while (usedItems.peek() != item) { |
|
|
|
while (usedItems.peek() != item) { |
|
|
|
Thread.sleep(5); |
|
|
|
Thread.sleep(1); |
|
|
|
} |
|
|
|
} |
|
|
|
writeThread.submit(new Callable<Void>() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Void call() throws Exception { |
|
|
|
|
|
|
|
writer.addImage(item.data); |
|
|
|
writer.addImage(item.data); |
|
|
|
freeItems.add(item); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
usedItems.poll(); |
|
|
|
usedItems.poll(); |
|
|
|
|
|
|
|
freeItems.add(item); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|