playWaveFile: Don't create a new WavePlayer until after we have waited on the previous thread. (#15681)
Fixes #15311.
Summary of the issue:
When multiple wave files are played asynchronously in rapid succession without any delay between the calls, NVDA can freeze briefly and throw exceptions such as "AttributeError: 'NoneType' object has no attribute 'feed'".
Description of user facing changes
NVDA no longer sometimes freezes briefly when multiple sounds are played in rapid succession.
Description of development approach
Previously, playWaveFile reassigned fileWavePlayer before waiting for the previous thread to complete. If the previous thread was still cleaning up, it might set fileWavePlayer to None after this new assignment. This meant that fileWavePlayer would be None when the new thread tried to run.
Instead, fileWavePlayer is now reassigned after waiting for the previous thread to complete.
In addition, the inner play() function now catches and logs exceptions that occur while trying to play. This would have made this problem a little easier to debug and should make related problems easier to debug in future.