Skip to content

Commit 60b1db8

Browse files
funtaxma5309
andauthored
Start line before first write to line (#232)
Co-authored-by: ma5309 <[email protected]>
1 parent afc7dc3 commit 60b1db8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/player/mixing/AudioSink.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ public void run() {
144144
}
145145
}
146146
} else {
147-
if (!started)
148-
started = output.start();
149-
150147
try {
148+
if (!started)
149+
started = output.start();
150+
151151
int count = mixing.read(buffer);
152152
output.write(buffer, count);
153153
} catch (IOException | LineUnavailableException | LineHelper.MixerException ex) {
@@ -214,8 +214,9 @@ void stop() {
214214
if (line != null) line.stop();
215215
}
216216

217-
boolean start() {
218-
if (line != null) {
217+
boolean start() throws LineUnavailableException {
218+
if (type == Type.MIXER) {
219+
acquireLine();
219220
line.start();
220221
return true;
221222
}
@@ -225,7 +226,6 @@ boolean start() {
225226

226227
void write(byte[] buffer, int len) throws IOException, LineUnavailableException, LineHelper.MixerException {
227228
if (type == Type.MIXER) {
228-
acquireLine();
229229
line.write(buffer, 0, len);
230230
} else if (type == Type.PIPE) {
231231
if (out == null) {

0 commit comments

Comments
 (0)