babalae/better-genshin-impact · error · InvalidOperationException

进程音频接口激活失败

Error message

进程音频接口激活失败

What it means

InvalidOperationException from WaitForAudioClient: the completion event WAS signaled within 5s and no exception was stored, yet _audioClient is null. This happens when ActivateCompleted ran, GetActivateResult/activateResult succeeded, but `activatedInterface as IAudioClient` returned null (the async operation returned an object that is not an IAudioClient) without throwing — the InvalidCastException in the handler would instead surface via _exception.

Source

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

                    {
                    }
                }
            }
        }

        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. Update to a recent Windows 10/11 build (process loopback activation requires a supported release).
  2. Confirm typeof(IAudioClient).GUID is the canonical IID_IAudioClient and not accidentally overridden.
  3. Check Windows Event Viewer for COM/activation errors at the failure time.
  4. Fall back to a different capture backend or disable the audio-based AutoSkip feature on unsupported builds.
Defensive patterns

Strategy: try-catch

Try / catch

try { client = handler.WaitForAudioClient(); }
catch (InvalidOperationException e) when (e.Message.Contains("进程音频接口激活失败"))
{ /* unsupported build / COM issue — disable feature */ }

Prevention

When it happens

Trigger: COM activation returned a non-IAudioClient interface for the requested IID; the ActivateAudioInterfaceAsyncNative call used an incorrect audioClientId GUID; partial/unsupported Windows build returns a placeholder interface; race where handler was disposed (_disposed) between Set and read but _completed still got set by an earlier path.

Common situations: Running on an older Windows 10 build that lacks full PROCESS_LOOPBACK support; IID mismatch after an API refactor; antivirus/security hook interfering with COM marshaling.

Related errors


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