playWaveFile: Don't create a new WavePlayer until after we have waited on the previous thread.#15681
Merged
Merged
Conversation
seanbudd
approved these changes
Oct 26, 2023
seanbudd
left a comment
Member
There was a problem hiding this comment.
Looks good, could you please add a changelog entry under bug fixes? We recently changed process to require contributors to add these.
…d on the previous thread.
This was referenced Nov 7, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
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.
Testing strategy:
Ran this Python console snippet:
import nvwave; nvwave.playWaveFile("waves/browseMode.wav"); nvwave.playWaveFile("waves/browseMode.wav"); nvwave.playWaveFile("waves/browseMode.wav")Before this change, it usually freezes and throws exceptions. After this change, it does not.
Known issues with pull request:
None.
Code Review Checklist: