babalae/better-genshin-impact · error · TimeoutException

等待进程音频接口激活超时

Error message

等待进程音频接口激活超时

What it means

TimeoutException raised by AudioInterfaceActivationHandler.WaitForAudioClient when the WinRT ActivateAudioInterfaceAsync completion handler does not signal _completed within 5 seconds. The activation is for per-process loopback capture (PROCESS_LOOPBACK) on the Genshin process. Timeouts typically mean the COM activation never called ActivateCompleted.

Source

Thrown at BetterGenshinImpact/GameTask/AutoSkip/Audio/ProcessLoopbackAudioCapture.cs:359

            {
                if (!_disposed)
                {
                    try
                    {
                        _completed.Set();
                    }
                    catch (ObjectDisposedException)
                    {
                    }
                }
            }
        }

        public IAudioClient WaitForAudioClient()
        {
            if (!_completed.Wait(TimeSpan.FromSeconds(5)))
            {
                throw new TimeoutException("等待进程音频接口激活超时");
            }

            if (_exception != null)
            {
                throw _exception;
            }

            return _audioClient ?? throw new InvalidOperationException("进程音频接口激活失败");
        }

        public void Dispose()
        {
            _disposed = true;
            _completed.Dispose();
        }
    }
}

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Ensure Windows audio service is running and a default render endpoint is enabled.
  2. Start the audio capture only after the game is fully loaded and on the main world screen.
  3. Verify the targetProcessId is still a live Genshin process before activating.
  4. Disable the AutoSkip voice-detection feature if no microphone/audio output is available.
  5. Retry capture activation after a short delay (game audio client spins up lazily).

Example fix

// before
if (!_completed.Wait(TimeSpan.FromSeconds(5)))
    throw new TimeoutException("等待进程音频接口激活超时");

// after: extend the wait and surface a hint
var timeout = TimeSpan.FromSeconds(15);
if (!_completed.Wait(timeout))
    throw new TimeoutException($"等待进程音频接口激活超时({timeout.TotalSeconds:0}s)。请确认游戏已加载且 Windows 音频服务正常。");
Defensive patterns

Strategy: retry

Try / catch

try { client = handler.WaitForAudioClient(); }
catch (TimeoutException) { /* audio client not ready yet; disable voice detection and continue without audio */ Logger.LogWarning("音频接口激活超时,关闭语音跳过检测"); }

Prevention

When it happens

Trigger: Calling ProcessLoopbackAudioCapture on a process that has no active audio stream/graph yet; calling before the game has initialized its audio client; Windows audio service (Audiosrv) stalled or disabled; target process already exited (targetProcessId stale) so the async activation hangs.

Common situations: AutoSkip's voice-dialogue detection started before Genshin finishes loading; audio device disabled/muted at OS level; WASAPI loopback unsupported on the configured endpoint; user switched default audio device mid-session; game launched without sound.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/7c57bdeb329bcc35. Report an issue: GitHub.