Misc fixes for light mode#30
Open
xyzzy42 wants to merge 2 commits into
Open
Conversation
When light mode is toggled, it's possible for the buffer pointer or timestamp to get messed up if it happens while the callback is running. The callback will read the current values when it starts, then light mode switch resets them to zero, and then when the callback finishes it updates them based on the original values, effectvely undoing to reset to zero. This doesn't cause a crash, but it does mean the timestamp isn't quite right. It also will cause problems if any code wants to process the audio data as it arrives. It could cause a single callback to be processed with the incorrect high pass filter. The easiest way to fix this is to pause the input stream while doing the mode switch. It could be fixed by making the entire callback a critical section or having the mode switch done asyncrounsly via the callback, but this makes the callback more complex and adds overhead. It seems better to add the extra work to the mode switch rather than the callback, since the former is a rare operation that isn't performance critical while the latter is.
This way settings that affect audio can be read in before audio starts. Since the config file is now read before starting audio, it is possible to start in light or normal mode as configured. If light mode was configured, then previously audio would be started in normal mode and then immediatly switch to light mode after processing a few callbacks.
e641a1b to
4282a1c
Compare
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.
There is race when switching between normal and light mode. Fix this.
If light mode is set in the config file, the app will start in normal anyway and then switch to light mode after processing a bit of audio. This is annoying and can be fixed so it starts in the correct mode to begin with.