servalproject/batphone — pull request #36 by klkblake (2012-10-05 06:19:19+00:00)
Title: Fix race condition in AudioPlayer

AudioPlayer.cleanup() is called both from the playback thread when it is
shutting down, and from the AudioManager when it gets the CallEnded
message from servald. The playback thread will throw an NPE if it
attempts to shutdown when cleanup() has already been called. Hence, we
cause cleanup() to return immediately if playbackThread is not null, and
only set playbackThread to null immediately before the call to cleanup()
in the playback thread itself.