Open a new line when a speaker's playback line dies
Both desktop backends dropped writes to a line whose device had gone away, and the per-speaker playout ignored any failure, so that speaker stayed silent for the rest of the session. A write to a dead line now throws; the playout drops that line and the speaker's next packet opens a fresh one. Sound effects and the microphone test's loopback reopen their line the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,11 +25,13 @@ final class JavaSoundPlayback implements AudioPlayback {
|
||||
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int length) {
|
||||
int written;
|
||||
try {
|
||||
line.write(buffer, offset, length);
|
||||
} catch (Exception ignored) {
|
||||
// The line went away (device unplugged); the caller sees silence.
|
||||
written = line.write(buffer, offset, length);
|
||||
} catch (RuntimeException e) {
|
||||
throw new IllegalStateException("The playback line failed", e);
|
||||
}
|
||||
if (written < length && !line.isOpen()) throw new IllegalStateException("The playback line closed");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,9 @@ final class PipeWirePlayback extends PipeWireStream implements AudioPlayback {
|
||||
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int length) {
|
||||
ring.write(buffer, offset, length);
|
||||
if (ring.write(buffer, offset, length) < length && ring.isClosed()) {
|
||||
throw new IllegalStateException("The PipeWire stream ended");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user