#### PR Dependency Tree * **PR #14700** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Durable, resumable import queue with explicit import lifecycle and updated popup/tray status behavior. * Async native recording APIs and ability to abort recordings; audio quality metrics (degraded, overflow count). * Added "Importing..." translation. * **Bug Fixes** * More reliable single-claim import processing, retries and cleanup to avoid duplicate imports. * Improved stop/abort teardown stability and safer shutdown behavior. * **Tests** * New/updated tests covering coordinator, import queue, native async flows and teardown scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Windows Audio Recording
This module provides Windows-specific audio recording functionality using the Windows Audio Session API (WASAPI).
Features
- Microphone Activity Detection: Monitor when applications are using the microphone
- Process Identification: Identify which process is using the microphone
- Real-time Notifications: Get callbacks when microphone usage starts/stops
Usage
MicrophoneListener
The MicrophoneListener class provides real-time monitoring of microphone usage:
import { MicrophoneListener } from '@affine/native';
const listener = new MicrophoneListener((isRunning: boolean, processName: string) => {
console.log(`Microphone ${isRunning ? 'started' : 'stopped'} by ${processName}`);
});
// Check current status
console.log('Is microphone currently active:', listener.is_running());
Callback Parameters
The callback receives two parameters:
isRunning: boolean- Whether the microphone is currently activeprocessName: string- Name of the process using the microphone
Implementation Details
Audio Session Monitoring
The implementation uses Windows Audio Session API to:
- Enumerate Audio Sessions: Get all active audio sessions
- Monitor Session State: Track when sessions become active/inactive
- Process Identification: Map audio sessions to process names
- Event Handling: Provide real-time notifications
COM Initialization
The module automatically initializes COM (Component Object Model) with COINIT_MULTITHREADED for proper Windows API interaction.
Error Handling
All Windows API errors are wrapped in WindowsAudioError enum and converted to NAPI errors for JavaScript consumption.
Cross-Platform Compatibility
This Windows implementation maintains API compatibility with the macOS version, providing the same JavaScript interface while using Windows-specific APIs underneath.
Platform Requirements
- Windows 10 or later
- Microphone access permissions
- Audio devices available
Dependencies
windowscrate v0.61 with Audio and Process featureswindows-corecrate v0.61napiandnapi-derivefor JavaScript bindings
Technical Notes
Thread Safety
The implementation uses thread-safe callbacks to JavaScript with ThreadsafeFunction<(bool, String), ()> to ensure proper communication between the Windows audio session monitoring thread and the JavaScript runtime.
Process Name Resolution
Process names are resolved using Windows APIs:
GetModuleFileNameExWfor full executable pathGetProcessImageFileNameWas fallback- Automatic extraction of filename from full path
Session Filtering
The implementation automatically filters out system audio sessions (like AudioSrv) to focus on user applications.