Skip to content

Commit d81cee0

Browse files
committed
Fixed issue with volume when re-acquiring line (#150)
1 parent 2820b74 commit d81cee0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ private static class Output implements Closeable {
266266
private final Type type;
267267
private SourceDataLine line;
268268
private OutputStream out;
269+
private int lastVolume = -1;
269270

270271
Output(@NotNull Type type, @NotNull MixingLine mixing, @NotNull Player.Configuration conf, @Nullable File pipe, @Nullable OutputStream out) throws LineUnavailableException {
271272
this.conf = conf;
@@ -298,6 +299,8 @@ private void acquireLine() throws LineUnavailableException {
298299

299300
line = LineHelper.getLineFor(conf, Output.OUTPUT_FORMAT);
300301
line.open(Output.OUTPUT_FORMAT);
302+
303+
if (lastVolume != -1) setVolume(lastVolume);
301304
}
302305

303306
void stop() {
@@ -356,6 +359,8 @@ public AudioFormat getFormat() {
356359
}
357360

358361
void setVolume(int volume) {
362+
lastVolume = volume;
363+
359364
if (line != null) {
360365
FloatControl ctrl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
361366
if (ctrl != null) {

0 commit comments

Comments
 (0)