From d9f6951a61e66384c57037109ad79d031ccb34ca Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 22 Aug 2017 16:25:24 +0530 Subject: [PATCH] Fixing stats display issue for virtual fire-alarm in MT mode --- .../agent/virtual/VirtualHardwareManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java b/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java index 61135c58a..fdb271e79 100644 --- a/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java +++ b/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java @@ -199,8 +199,11 @@ public class VirtualHardwareManager { try { sequence = MidiSystem.getSequence(audioSrc); sequencer = MidiSystem.getSequencer(); - sequencer.open(); - sequencer.setSequence(sequence); + if(sequencer != null) { + sequencer.open(); + sequencer.setSequence(sequence); + sequencer.setLoopCount(Clip.LOOP_CONTINUOUSLY); + } } catch (InvalidMidiDataException e) { log.error("AudioReader: Error whilst setting MIDI Audio reader sequence"); } catch (IOException e) { @@ -208,8 +211,6 @@ public class VirtualHardwareManager { } catch (MidiUnavailableException e) { log.error("AudioReader: Error whilst openning MIDI Audio reader sequencer"); } - - sequencer.setLoopCount(Clip.LOOP_CONTINUOUSLY); } }