X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosVoice.java;h=b05913b68140ce1224f6c028bd3cba3ff4d304fa;hb=59dfe661fcb504f390d9726378c676f2b5b005f3;hp=147405f6affd58fb23091181844dda6ec3373044;hpb=b1f1844aa514893228080704da3b3ccf855bda1e;p=fw%2Faltos diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java index 147405f6..b05913b6 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java @@ -45,7 +45,7 @@ public class AltosVoice { } - public void speak(String s) { + public synchronized void speak(String s) { if (!tts_enabled) return; tts.speak(s, TextToSpeech.QUEUE_ADD, null); } @@ -87,7 +87,8 @@ public class AltosVoice { } } old_state = state; - idle_thread.notice(state, spoke); + if (idle_thread != null) + idle_thread.notice(state, spoke); } @@ -117,13 +118,20 @@ public class AltosVoice { state.state == AltosLib.ao_flight_stateless) && state.range >= 0) { - speak(String.format("Height %d, bearing %s %d, elevation %d, range %d.\n", - (int) (state.height() + 0.5), - state.from_pad.bearing_words( - AltosGreatCircle.BEARING_VOICE), - (int) (state.from_pad.bearing + 0.5), - (int) (state.elevation + 0.5), - (int) (state.range + 0.5))); + if (state.from_pad != null) { + speak(String.format("Height %d, bearing %s %d, elevation %d, range %d.\n", + (int) (state.height() + 0.5), + state.from_pad.bearing_words( + AltosGreatCircle.BEARING_VOICE), + (int) (state.from_pad.bearing + 0.5), + (int) (state.elevation + 0.5), + (int) (state.range + 0.5))); + } else { + speak(String.format("Height %d, elevation %d, range %d.\n", + (int) (state.height() + 0.5), + (int) (state.elevation + 0.5), + (int) (state.range + 0.5))); + } } else if (state.state > AltosLib.ao_flight_pad) { if (state.height() != AltosLib.MISSING) speak(String.format("%d meters", (int) (state.height() + 0.5)));