fixed crash caused by race when dedecting if mic is on

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java | 7 
1 file changed, 6 insertions(+), 1 deletion(-)

Detailed changes

src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java 🔗

@@ -308,7 +308,12 @@ public class WebRTCWrapper {
         if (audioTrack == null) {
             throw new IllegalStateException("Local audio track does not exist (yet)");
         }
-        return audioTrack.enabled();
+        try {
+            return audioTrack.enabled();
+        } catch (final IllegalStateException e) {
+            //sometimes UI might still be rendering the buttons when a background thread has already ended the call
+            return false;
+        }
     }
 
     void setMicrophoneEnabled(final boolean enabled) {