Avoid error playing wave file when playing multiple subsequent waves (#17918)
Summary of the issue:
First of all, I can't reliably reproduce this, but i have seen several cases lately where an exception was raised in playWaveFile, telling me that None object has no attribute feed. It happens to me around twice a day or so.
ERROR - nvwave.play (10:43:12.334) - nvwave.playWaveFile(error.wav) (17056):
Error playing wave file
Traceback (most recent call last):
File "nvwave.pyc", line 127, in play
AttributeError: 'NoneType' object has no attribute 'idle'
I think I can somewhat understand the issue. playWaveFile can play asynchronously. It has a local function play that sets the global fileWavePlayer to None when done. However when playing several sounds in a row, there can be a case where fileWavePlayer is set to None by one playback, then the next player tries to feed or idle to a None player.
Description of user facing changes
Hopefully, no longer rare errors.
Description of development approach
In the local function, copy the reference to the player in a local variable p and then use that variable to do feed and idle.