Skip to content

Commit

Permalink
Slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
berry120 committed Dec 31, 2023
1 parent 651c086 commit 552cee6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
public final class QueleaProperties extends SortedProperties {

public static final Version VERSION = new Version("2024.0", VersionType.BETA);
public static final Version VERSION = new Version("2024.0", VersionType.CI);
private static QueleaProperties INSTANCE;
private String userHome;

Expand Down
14 changes: 7 additions & 7 deletions Quelea/src/main/java/org/quelea/windows/video/FXImageSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import org.freedesktop.gstreamer.elements.AppSink;

import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

/**
* A wrapper connecting a GStreamer AppSink and a JavaFX Image, making use of
Expand All @@ -48,6 +48,7 @@
public class FXImageSink {

private final static String DEFAULT_CAPS;
private final static int OLD_SAMPLE_BUFFER_SIZE = 2;

static {
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
Expand All @@ -61,7 +62,7 @@ public class FXImageSink {
private final ReadOnlyObjectWrapper<WritableImage> image;
private Sample activeSample;
private Buffer activeBuffer;
private final List<Sample> oldSamples;
private final Queue<Sample> oldSamples;

/**
* Create an FXImageSink. A new AppSink element will be created that can be
Expand All @@ -78,7 +79,7 @@ public FXImageSink() {
*/
public FXImageSink(AppSink sink) {
this.sink = sink;
oldSamples = new ArrayList<>();
oldSamples = new ArrayBlockingQueue<>(OLD_SAMPLE_BUFFER_SIZE + 1);
sink.set("emit-signals", true);
sink.connect((AppSink.NEW_SAMPLE) elem -> {
Sample s = elem.pullSample();
Expand Down Expand Up @@ -143,9 +144,8 @@ private void updateImage(Sample newSample) {
if (oldBuffer != null) {
oldBuffer.unmap();
}

while (oldSamples.size() > 2) {
oldSamples.remove(0).dispose();
while (oldSamples.size() > OLD_SAMPLE_BUFFER_SIZE) {
oldSamples.remove().dispose();
}

}
Expand Down

0 comments on commit 552cee6

Please sign in to comment.