SG-40625 - Play Forward/Pause button stops responding when playing media files (Linux) #994
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.
SG-40625 - Play Forward/Pause button stops responding when playing media files (Linux)
Linked issues
n/a
Summarize your change.
Describe the reason for the change.
There was a stability problem where calling
stop()orreset()on theQAudioOutputobject would cause audio playback to break after multiple play/stop cycles. To work around this, suspend() was used instead, which solved the instability. However, this introduced a second problem:suspend()does not clear the audio device's internal buffer. This resulted in an audio bleed issue, where sound from the previously played media could be heard for a fraction of a second when starting a new one.Describe what you have tested and on which operating system.
This change introduces a new flushing mechanism that resolves the audio bleed on Linux while avoiding the unstable
stop()andreset()calls.When playback is stopped, instead of immediately suspending the audio device, a new flushing process is initiated. The audio device is kept active momentarily while it is fed with silent audio data, completely overwriting the contents of its internal buffer. Once the buffer is flushed, the device is safely suspended.
This ensures that the audio buffer is clear before the next playback begins, eliminating audio bleed. Because this approach continues to use
suspend()to halt the device, it maintains the stability of the audio system.This logic is confined to the Linux platform and does not affect the behavior on MacOS or Windows.
Add a list of changes, and note any that might need special attention during the review.
If possible, provide screenshots.