mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Minor change, add comments.
This commit is contained in:
parent
89bd184407
commit
d7cdfa016e
1 changed files with 4 additions and 4 deletions
|
|
@ -27,9 +27,10 @@ public class LinePool {
|
|||
|
||||
/*
|
||||
* Initially all the lines are in the freeLines pool. When a sound plays, one line is being selected randomly from
|
||||
* the activeLines and then, if it's empty, from freeLines pool and used to play the sound. The line is moved to
|
||||
* the activeLines and then, if it's empty, from the freeLines pool and used to play the sound. The line is moved to
|
||||
* busyLines. When a sound stops, the line is moved to activeLines if it contains <= elements than alwaysActive
|
||||
* parameter, else it's moved to the freeLines pool.
|
||||
* parameter, else it's moved to the freeLines pool. Every 30 seconds the lines in the freeLines pool are closed
|
||||
* from the timer thread to prevent deadlocks in PulseAudio internals.
|
||||
*/
|
||||
|
||||
private Mixer mixer;
|
||||
|
|
@ -101,14 +102,13 @@ public class LinePool {
|
|||
byte[] buffer = mageClip.getBuffer();
|
||||
line.write(buffer, 0, buffer.length);
|
||||
synchronized (LinePool.this) {
|
||||
boolean hasQueue = queue.size() > 0;
|
||||
busyLines.remove(line);
|
||||
if (activeLines.size() < LinePool.this.alwaysActive) {
|
||||
activeLines.add(line);
|
||||
} else {
|
||||
freeLines.add(line);
|
||||
}
|
||||
if (hasQueue) {
|
||||
if (queue.size() > 0) {
|
||||
playSound(queue.poll());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue