[javasound] Fix invalid cast on non windows os (#2988)

Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
This commit is contained in:
GiviMAD
2022-05-30 22:59:34 +02:00
committed by GitHub
parent d6c269d95a
commit 214fda0a7b
@@ -109,7 +109,22 @@ public class JavaSoundAudioSource implements AudioSource {
// on OSs other than windows we can open multiple lines for the microphone
if (!windowsOS) {
TargetDataLine microphone = initMicrophone(format);
var inputStream = new JavaSoundInputStream((InputStream) microphone, audioFormat);
var inputStream = new JavaSoundInputStream(new InputStream() {
@Override
public int read() throws IOException {
return microphone.available();
}
@Override
public int read(byte @Nullable [] b, int off, int len) throws IOException {
return microphone.read(b, off, len);
}
@Override
public void close() throws IOException {
microphone.close();
}
}, audioFormat);
microphone.start();
return inputStream;
}