Fix: recover remote desktop audio after dropped formats and sleep
The client's audio thread starts before the capture thread sends TOKEN_BITMAPINFO, so its first packet - the only one carrying the AudioFormat - reaches the master before CScreenSpyDlg exists and is dropped as an unknown command. Without a format the master cannot open waveOut, and the client re-announced only on an audio off/on, so a remote desktop opened with audio enabled stayed silent until the toolbar button was toggled twice. The master now asks for a re-announce when data arrives with no format on record (CMD_AUDIO_CTRL enable, persist=0, one request per 2 s, 15 attempts max), and the client attaches the format to its next packet. Entering Modern Standby tears down the render endpoint. The client got AUDCLNT_E_DEVICE_INVALIDATED and rebuilt its loopback capture in that same instant; the new client initialized and started fine but was bound to the dying audio engine, so after resume GetNextPacketSize returned zero packets forever without error, and only a fresh screen session recovered. The audio thread now measures its own loop gap (GetTickCount64 plus wall clock, 2 s; a normal pass is ~10 ms) and rebuilds the capture client after the machine was frozen, waits a second after an invalidation, and rebuilds on an audio off-to-on. The master rebuilds waveOut on resume from WM_POWERBROADCAST. The format recovery was verified live; the resume recovery is build-verified and awaits a field check on a sleeping machine. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
74d64fec87
commit
f96e4a7320
4 files changed
+107
-5
No files matched your search
@@ -442,6 +442,10 @@ public:
|
||||
BOOL m_bAudioInitPending = FALSE; // 已在 worker 线程登记重建,等待 UI 线程处理
|
||||
ULONGLONG m_nLastAudioInitTick = 0; // 上次尝试打开 waveOut 的时刻(失败重试节流)
|
||||
ULONGLONG m_nLastAudioErrLog = 0; // 上次打印音频错误日志的时刻(日志节流)
|
||||
// 没收到格式包时主动请客户端重发(首包常比 TOKEN_BITMAPINFO 先到、对话框还没建好被丢掉)。
|
||||
// m_nAudioFmtReqCount 封顶:老客户端不认这个请求,别一直发。
|
||||
ULONGLONG m_nLastAudioFmtReqTick = 0; // 上次请求重发格式的时刻(节流)
|
||||
int m_nAudioFmtReqCount = 0; // 已请求重发格式的次数
|
||||
|
||||
void OnAudioData(BYTE* pData, UINT32 len); // 处理音频数据
|
||||
void StopAudioPlayback(); // 停止音频播放(任一线程,内部加锁)
|
||||
@@ -489,6 +493,7 @@ public:
|
||||
afx_msg LRESULT OnWaveOutDone(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnWaveOutClose(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnAudioInitDevice(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnPowerResume(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnRecvFileV2Chunk(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnRecvFileV2Complete(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg void OnExitFullscreen()
|
||||
|
||||
Reference in new issue
Block a user