mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Merge pull request #2060 from magefree/revert-2029-audio_threadpool
Revert "Use a dedicated thread pool for audio"
This commit is contained in:
commit
01c21723fd
1 changed files with 3 additions and 18 deletions
|
@ -5,10 +5,6 @@ import java.util.LinkedList;
|
|||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
|
@ -23,6 +19,8 @@ import javax.sound.sampled.SourceDataLine;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import mage.utils.ThreadUtils;
|
||||
|
||||
public class LinePool {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
@ -43,25 +41,12 @@ public class LinePool {
|
|||
|
||||
private Mixer mixer;
|
||||
private int alwaysActive;
|
||||
private ThreadPoolExecutor threadPool;
|
||||
private int threadCount;
|
||||
|
||||
public LinePool() {
|
||||
this(new AudioFormat(22050, 16, 1, true, false), 4, 1);
|
||||
}
|
||||
|
||||
public LinePool(AudioFormat audioFormat, int size, int alwaysActive) {
|
||||
threadPool = new ThreadPoolExecutor(alwaysActive, size, 30L, TimeUnit.SECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread (Runnable runnable) {
|
||||
threadCount++;
|
||||
Thread thread = new Thread(runnable, "Audio" + threadCount);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
});
|
||||
threadPool.prestartAllCoreThreads();
|
||||
|
||||
format = audioFormat;
|
||||
this.alwaysActive = alwaysActive;
|
||||
mixer = AudioSystem.getMixer(null);
|
||||
|
@ -110,7 +95,7 @@ public class LinePool {
|
|||
busyLines.add(line);
|
||||
logLineStats();
|
||||
}
|
||||
threadPool.submit(new Runnable() {
|
||||
ThreadUtils.threadPool.submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in a new issue