When testing #11 I realized that setting a tune on Shutdown resulted in only the first note being played before the rest was cut off. Since playback was moved to a non-blocking thread, the tune no longer blocks on shutdown. While we do NOT want to introduce long-running operations on shutdown, this change does wait up to 3 seconds for a tune to finish playing if one is triggered on the Shutdown event. If the tune is longer than 3 seconds, it will be truncated at that point as the system continues to shut down and terminate the ToneQueue's worker thread.
Description
When testing #11 I realized that setting a tune on
Shutdown
resulted in only the first note being played before the rest was cut off. Since playback was moved to a non-blocking thread, the tune no longer blocks on shutdown. While we do NOT want to introduce long-running operations on shutdown, this change does wait up to 3 seconds for a tune to finish playing if one is triggered on theShutdown
event. If the tune is longer than 3 seconds, it will be truncated at that point as the system continues to shut down and terminate the ToneQueue's worker thread.Test Plan
These changes can be tested by installing the plugin from: https://github.com/stealthmonkey99/OctoPrint-PWMBuzzer/archive/block-shutdown-tune.zip