Skip to content

Commit a6e5935

Browse files
committed
Close open lines when closing player (fixes #125)
1 parent 68dede8 commit a6e5935

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

core/src/main/java/xyz/gianlu/librespot/player/LinesHolder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
import xyz.gianlu.librespot.common.Utils;
77

88
import javax.sound.sampled.*;
9+
import java.io.Closeable;
910
import java.util.*;
1011
import java.util.concurrent.atomic.AtomicBoolean;
1112

1213
/**
1314
* @author Gianlu
1415
*/
15-
public class LinesHolder {
16+
public class LinesHolder implements Closeable {
1617
private static final Logger LOGGER = Logger.getLogger(LinesHolder.class);
1718
private final Map<Mixer, LineWithState> openLines = new HashMap<>();
1819

@@ -67,6 +68,12 @@ public LineWrapper getLineFor(@NotNull Player.Configuration conf, @NotNull Audio
6768
return getLine(mixer, info);
6869
}
6970

71+
@Override
72+
public void close() {
73+
for (LineWithState line : openLines.values())
74+
line.line.close();
75+
}
76+
7077
public static class MixerException extends Exception {
7178
MixerException(String message) {
7279
super(message);

core/src/main/java/xyz/gianlu/librespot/player/Player.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ public void close() {
520520
preloadTrackHandler.close();
521521
preloadTrackHandler = null;
522522
}
523+
524+
lines.close();
523525
}
524526

525527
@Nullable

0 commit comments

Comments
 (0)