mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-26 03:46:28 -08:00
AutoBone: Return recording ASAP and check if it's empty
This commit is contained in:
2 files changed
+23
-11
No files matched your search
@@ -180,10 +180,16 @@ public class AutoBoneWindow extends JFrame {
|
||||
if (frameRecordings.size() > 0) {
|
||||
LogManager.log.info("[AutoBone] Done loading frames!");
|
||||
} else {
|
||||
Future<PoseFrame[]> frames = poseRecorder.getFramesAsync();
|
||||
if (frames != null) {
|
||||
Future<PoseFrame[]> framesFuture = poseRecorder.getFramesAsync();
|
||||
if (framesFuture != null) {
|
||||
setText("Waiting for Recording...");
|
||||
frameRecordings.add(Pair.of("<Recording>", frames.get()));
|
||||
PoseFrame[] frames = framesFuture.get();
|
||||
|
||||
if (frames.length <= 0) {
|
||||
throw new IllegalStateException("Recording has no frames");
|
||||
}
|
||||
|
||||
frameRecordings.add(Pair.of("<Recording>", frames));
|
||||
} else {
|
||||
setText("No Recordings...");
|
||||
LogManager.log.severe("[AutoBone] No recordings found in \"" + loadFolder.getPath() + "\" and no recording was done...");
|
||||
|
||||
@@ -39,13 +39,15 @@ public class PoseRecorder {
|
||||
if (System.currentTimeMillis() >= nextFrameTimeMs) {
|
||||
nextFrameTimeMs = System.currentTimeMillis() + frameRecordingInterval;
|
||||
frames.add(new PoseFrame(skeleton));
|
||||
|
||||
// If done, send finished recording
|
||||
if (frames.size() >= numFrames) {
|
||||
internalStopRecording();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If done, send finished recording
|
||||
CompletableFuture<PoseFrame[]> currentRecording = this.currentRecording;
|
||||
if (currentRecording != null && !currentRecording.isDone()) {
|
||||
currentRecording.complete(frames.toArray(new PoseFrame[0]));
|
||||
}
|
||||
// If done and hasn't yet, send finished recording
|
||||
internalStopRecording();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,8 +81,8 @@ public class PoseRecorder {
|
||||
return currentRecording;
|
||||
}
|
||||
|
||||
public synchronized void stopFrameRecording() {
|
||||
// Synchronized, this value can be expected to stay the same
|
||||
private void internalStopRecording() {
|
||||
CompletableFuture<PoseFrame[]> currentRecording = this.currentRecording;
|
||||
if (currentRecording != null && !currentRecording.isDone()) {
|
||||
// Stop the recording, returning the frames recorded
|
||||
currentRecording.complete(frames.toArray(new PoseFrame[0]));
|
||||
@@ -89,8 +91,12 @@ public class PoseRecorder {
|
||||
numFrames = -1;
|
||||
}
|
||||
|
||||
public synchronized void stopFrameRecording() {
|
||||
internalStopRecording();
|
||||
}
|
||||
|
||||
public synchronized void cancelFrameRecording() {
|
||||
// Synchronized, this value can be expected to stay the same
|
||||
CompletableFuture<PoseFrame[]> currentRecording = this.currentRecording;
|
||||
if (currentRecording != null && !currentRecording.isDone()) {
|
||||
// Cancel the current recording and return nothing
|
||||
currentRecording.cancel(true);
|
||||
|
||||
Reference in new issue
Block a user