Skip to content

Commit f22ff8a

Browse files
author
Bri
committed
Add comprehensive diagnostics for process audio capture failures
Addresses issue where Windows 10 Build 19045 users experience inconsistent process capture support due to audio driver and system configuration variations. Changes: - Add Windows version check with user-friendly error messages (Build 19041+ required) - Implement detailed activation failure diagnostics with specific HRESULT error codes - Provide actionable guidance for common failures (driver updates, Windows updates, admin rights) - Add GetActivationResult() method to AudioClientActivationHandler for error retrieval - Update README with comprehensive explanation of process capture requirements and limitations - Explain why feature may not work even on correct Windows version (drivers, updates, hardware) - Document automatic fallback to system-wide audio capture Users will now see exactly why process capture fails and what they can do to fix it, with the application gracefully falling back to system-wide capture when needed.
1 parent d5c38d4 commit f22ff8a

3 files changed

Lines changed: 66 additions & 1 deletion

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ A powerful Windows audio capture application for recording and mixing multiple a
2727
- **Windows 10 Build 19041+ (Version 2004)** - Required for per-application capture feature
2828
- No additional software or drivers required
2929

30-
**Note:** On Windows 7/8/8.1 and early Windows 10 builds, only System Audio and Input Devices (microphones) will be available. Per-application capture requires Windows 10 Version 2004 or later.
30+
**Important Note About Per-Application Capture:**
31+
32+
Per-application capture requires Windows 10 Version 2004 (Build 19041) or later. However, even with the correct Windows version, this feature may not work on all systems due to:
33+
34+
- **Audio driver compatibility** - Some audio drivers don't fully support Windows loopback features
35+
- **Windows Update level** - Certain KB updates are required for full functionality
36+
- **Audio device hardware** - Older audio hardware may not support this feature
37+
38+
If per-application capture fails, AudioCapture will automatically fall back to system-wide audio capture and display a detailed error message explaining why. On Windows 7/8/8.1 and early Windows 10 builds, only System Audio and Input Devices (microphones) will be available.
3139

3240
## How to Use
3341

include/AudioCapture.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ class AudioClientActivationHandler : public IActivateAudioInterfaceCompletionHan
122122
// Check if the handler is valid (event created successfully)
123123
bool IsValid() const { return m_completionEvent != nullptr; }
124124

125+
// Get the activation result (HRESULT code from activation)
126+
HRESULT GetActivationResult() const { return m_activationResult; }
127+
125128
private:
126129
LONG m_refCount;
127130
HANDLE m_completionEvent;

src/AudioCapture.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ bool AudioCapture::InitializeProcessSpecificCapture(DWORD processId) {
251251
}
252252
}
253253

254+
// Check if Windows version supports process loopback (Build 19041+)
255+
if (dwMajorVersion < 10 || (dwMajorVersion == 10 && dwBuild < 19041)) {
256+
wchar_t msg[512];
257+
swprintf_s(msg, L"Process capture requires Windows 10 Build 19041 or later.\n\n"
258+
L"Your system: Windows %lu Build %lu\n\n"
259+
L"Process capture will not be available. The application will fall back to system-wide audio capture.",
260+
dwMajorVersion, dwBuild);
261+
MessageBox(nullptr, msg, L"Process Capture Not Supported", MB_OK | MB_ICONINFORMATION);
262+
return false;
263+
}
264+
254265
// Use the virtual device for process loopback (not a physical device)
255266
LPCWSTR deviceId = VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK;
256267

@@ -318,15 +329,58 @@ bool AudioCapture::InitializeProcessSpecificCapture(DWORD processId) {
318329
asyncOp->Release();
319330

320331
if (!success) {
332+
// Get the activation result to show detailed error
333+
HRESULT activationHr = handler->GetActivationResult();
321334
handler->Release();
335+
336+
// Show detailed error message to help user diagnose
337+
wchar_t msg[1024];
338+
const wchar_t* errorDesc = L"Unknown error";
339+
340+
// Common error codes and what they mean
341+
if (activationHr == E_NOTIMPL || activationHr == 0x88890008) { // AUDCLNT_E_UNSUPPORTED_FORMAT
342+
errorDesc = L"Process loopback audio not supported by your audio driver.\n\n"
343+
L"This is usually caused by:\n"
344+
L"- Outdated or incompatible audio drivers\n"
345+
L"- Missing Windows updates\n"
346+
L"- Audio driver not fully supporting Windows 10 loopback features\n\n"
347+
L"Try updating your audio drivers and Windows.";
348+
} else if (activationHr == E_ACCESSDENIED) {
349+
errorDesc = L"Access denied to audio device.\n\n"
350+
L"Try running the application as administrator.";
351+
} else if (activationHr == 0x887A0002) { // DXGI_ERROR_NOT_FOUND
352+
errorDesc = L"Audio device not found or not available.";
353+
} else if (activationHr == 0x88890001) { // AUDCLNT_E_NOT_INITIALIZED
354+
errorDesc = L"Audio client could not be initialized.\n\n"
355+
L"The audio driver may not support this feature.";
356+
}
357+
358+
swprintf_s(msg,
359+
L"Process capture failed for this application.\n\n"
360+
L"Windows Build: %lu (Requires 19041+)\n"
361+
L"Error Code: 0x%08X\n\n"
362+
L"%s\n\n"
363+
L"The application will fall back to system-wide audio capture.",
364+
dwBuild, activationHr, errorDesc);
365+
366+
MessageBox(nullptr, msg, L"Process Capture Failed", MB_OK | MB_ICONWARNING);
322367
return false;
323368
}
324369

325370
// Get the audio client (this AddRefs it for us)
326371
m_audioClient = handler->GetAudioClient();
327372

328373
if (!m_audioClient) {
374+
HRESULT activationHr = handler->GetActivationResult();
329375
handler->Release();
376+
377+
wchar_t msg[512];
378+
swprintf_s(msg,
379+
L"Failed to get audio client for process capture.\n\n"
380+
L"Error Code: 0x%08X\n\n"
381+
L"The application will fall back to system-wide audio capture.",
382+
activationHr);
383+
MessageBox(nullptr, msg, L"Process Capture Failed", MB_OK | MB_ICONWARNING);
330384
return false;
331385
}
332386

0 commit comments

Comments
 (0)