altosuilib: In display thread, set new state synchronously
authorKeith Packard <keithp@keithp.com>
Mon, 21 Sep 2015 05:00:36 +0000 (06:00 +0100)
committerKeith Packard <keithp@keithp.com>
Tue, 13 Oct 2015 20:54:28 +0000 (13:54 -0700)
commita81d028dc62a0a624051fc3c9debb9687fda931e
treebd21dfbeecbf06a7f23bf1324475c222933843e6
parentf61c2b73f3b63aa9c3f0fbccede89c71580089ba
altosuilib: In display thread, set new state synchronously

When replaying telemetry, received_time gets set by both the
telemetry reader (when the file is initially read) and by the replay
reader (as the telemetry is processed). Because these two events are
separated by the time it takes to play the file, the second time is
the one we want for figuring out how long since the last telemetry
packet. However, if we set the global state when pulling the state out
of the telemetry reader, and then the replay reader pauses for a long
time, then the voice output thread sees the intermediate time value
and thinks that it has been a long time since the last packet was
received and reports that the rocket may have crashed.

Fix this by just holding the read state until it has been passed by
the replay reader and had the received_time set to current time.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosuilib/AltosDisplayThread.java