fix(FxController): prevent sleep during playback and re-init audio on system resume#533
Open
akai07 wants to merge 2 commits into
Open
fix(FxController): prevent sleep during playback and re-init audio on system resume#533akai07 wants to merge 2 commits into
akai07 wants to merge 2 commits into
Conversation
… in OnDeviceStateChanged - Filter capture (eRender) device events in OnDeviceStateChanged via IMMEndpoint.GetDataFlow to prevent unnecessary playback reinit when input devices change state - Track reconnected device GUID when state transitions to ACTIVE - Add reconnection detection in sndDevicesImplementDeviceRules to auto-select reconnected playback devices (fixes BT headset reconnect after UNPLUGGED) - Clear reconnection state on reinit
… system resume - Call SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED) when audio processing starts to prevent system sleep during playback - Revert to SetThreadExecutionState(ES_CONTINUOUS) when processing stops - Handle PBT_APMRESUMEAUTOMATIC power event: check device changes and restore power state after system resume from sleep - Clear execution state on controller destruction
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.
Summary
Prevents the system from sleeping while FxSound is actively processing audio. Also handles system resume from sleep and RDP session changes to ensure audio processing continues correctly.
Changes
SetThreadExecutionState — Sleep prevention
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED)to prevent system sleep and display off.SetThreadExecutionState(ES_CONTINUOUS)to allow normal power management.PBT_APMRESUMEAUTOMATIC — System resume handler
Added
WM_POWERBROADCASTcase in the message window callback. WhenPBT_APMRESUMEAUTOMATICfires after resume from sleep:audio_passthru_->checkDeviceChanges()to refresh device state (devices may have changed during sleep)setPowerState()to re-activate audio processing with the stored power stateFiles Changed
fxsound/Source/GUI/FxController.cpp— Sleep prevention, power event handling, execution state cleanupRelated Issues