mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Fix some NPE in VoiceInput
This commit is contained in:
1 parent
36e917a444
commit
f7a470f3fb
1 file changed
+14
-7
@@ -13,11 +13,11 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VoiceInput extends Thread
|
||||
{
|
||||
public VoiceClient voiceClient;
|
||||
private VoiceClient voiceClient;
|
||||
|
||||
public DataLine.Info microphone;
|
||||
private DataLine.Info microphone;
|
||||
|
||||
public TargetDataLine targetLine;
|
||||
private TargetDataLine targetLine;
|
||||
|
||||
public VoiceInput(VoiceClient client)
|
||||
{
|
||||
@@ -32,6 +32,11 @@ public class VoiceInput extends Thread
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
if(!AudioSystem.isLineSupported(microphone))
|
||||
{
|
||||
Mekanism.logger.info("No audio system available.");
|
||||
return;
|
||||
}
|
||||
targetLine = ((TargetDataLine)AudioSystem.getLine(microphone));
|
||||
targetLine.open(voiceClient.format, 2200);
|
||||
targetLine.start();
|
||||
@@ -82,14 +87,16 @@ public class VoiceInput extends Thread
|
||||
|
||||
audioInput.close();
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while running client input thread.");
|
||||
e.printStackTrace();
|
||||
Mekanism.logger.error("VoiceServer: Error while running client input thread.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
targetLine.flush();
|
||||
targetLine.close();
|
||||
if(targetLine != null)
|
||||
{
|
||||
targetLine.flush();
|
||||
targetLine.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user