fix audio issues + potential crash

This commit is contained in:
Sen 2025-05-25 20:43:52 +02:00
parent 93d997c3c0
commit a62dc2309d
2 changed files with 4 additions and 4 deletions

View file

@ -455,7 +455,7 @@ public class Client implements IThreadListener {
@Variable(name = "snd_enabled", category = CVarCategory.SOUND, display = "Tonausgabe") @Variable(name = "snd_enabled", category = CVarCategory.SOUND, display = "Tonausgabe")
public boolean soundEnabled = true; public boolean soundEnabled = true;
@Variable(name = "snd_buffer_size", category = CVarCategory.SOUND, min = 0, max = 1048576, display = "Puffergröße") @Variable(name = "snd_buffer_size", category = CVarCategory.SOUND, min = 0, max = 1048576, display = "Puffergröße")
public int soundBufferSize = 2048; public int soundBufferSize = 16384;
@Variable(name = "snd_frame_size", category = CVarCategory.SOUND, min = 2, max = 8192, display = "PCM-Intervall") @Variable(name = "snd_frame_size", category = CVarCategory.SOUND, min = 2, max = 8192, display = "PCM-Intervall")
public int soundFrameSize = 32; public int soundFrameSize = 32;

View file

@ -138,12 +138,12 @@ public class AudioInterface implements Runnable {
public void run() { public void run() {
AudioFormat format = new AudioFormat(Encoding.PCM_SIGNED, 48000, 16, 2, 2 * 2, 48000, false); AudioFormat format = new AudioFormat(Encoding.PCM_SIGNED, 48000, 16, 2, 2 * 2, 48000, false);
Info info = new Info(SourceDataLine.class, format, this.devbufsize); Info info = new Info(SourceDataLine.class, format, this.devbufsize == 0 ? AudioSystem.NOT_SPECIFIED : this.devbufsize);
try { try {
this.line = (SourceDataLine)AudioSystem.getLine(info); this.line = (SourceDataLine)AudioSystem.getLine(info);
this.line.open(format, this.devbufsize); this.line.open(format, this.devbufsize == 0 ? AudioSystem.NOT_SPECIFIED : this.devbufsize);
} }
catch(LineUnavailableException e) { catch(Exception e) {
this.line = null; this.line = null;
Log.SOUND.error(e, "Konnte Audiogerät nicht öffnen"); Log.SOUND.error(e, "Konnte Audiogerät nicht öffnen");
} }