Files
Explosion-Overhaul/build/decompiled/com/vinlanx/explosionoverhaul/client/SoundEngineAudioQueue.java
2026-05-04 10:03:58 +00:00

52 lines
1.2 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package com.vinlanx.explosionoverhaul.client;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
public final class SoundEngineAudioQueue {
private static final Queue<Runnable> QUEUE = new ConcurrentLinkedQueue<Runnable>();
private SoundEngineAudioQueue() {
}
public static void enqueueAudio(Runnable task) {
if (task == null) {
return;
}
if (SoundEngineAudioQueue.isSoundThread()) {
try {
task.run();
}
catch (Throwable t) {
t.printStackTrace();
}
SoundEngineAudioQueue.drainNow();
} else {
QUEUE.offer(task);
}
}
public static void drainNow() {
Runnable next;
if (!SoundEngineAudioQueue.isSoundThread()) {
return;
}
while ((next = QUEUE.poll()) != null) {
try {
next.run();
}
catch (Throwable t) {
t.printStackTrace();
}
}
}
private static boolean isSoundThread() {
return "Sound engine".equals(Thread.currentThread().getName());
}
}