eiz / SynchronousAudioRouter

Low latency application audio routing for Windows
http://sar.audio/
GNU General Public License v3.0
1.07k stars 138 forks source link

SAR Implementation and Windows Server 2022 #122

Open amurzeau opened 3 years ago

amurzeau commented 3 years ago

The way SAR is designed is largely obsolete. I can talk about this now: if you want to solve this problem, look in the 10.0.22000 Windows SDK headers um\audioclientactivationparams.h for VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK and knock yourself out =)

@eiz I tried to read some documentation about that but I didn't understand the underlying goal. Do you mean that Windows 10 will have a way to do what SAR is doing, but without needing a custom driver ?

amurzeau commented 3 years ago

The header contains this:

// Identifier for virtual audio device that supports audio loopback based on
// a process ID instead of the device interface path of a physical audio device.
// Use this for the deviceInterfacePath parameter of ActivateAudioInterfaceAsync when
// AUDIOCLIENT_ACTIVATION_PARAMS::ActivationType is set to AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK.
#define VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK L"VAD\\Process_Loopback"
typedef /* [v1_enum] */ 
enum PROCESS_LOOPBACK_MODE
    {
        PROCESS_LOOPBACK_MODE_INCLUDE_TARGET_PROCESS_TREE   = 0,
        PROCESS_LOOPBACK_MODE_EXCLUDE_TARGET_PROCESS_TREE   = 1
    }   PROCESS_LOOPBACK_MODE;

// This structure is used when creating an IAudioClient using ActivateAudioInterfaceAsync
// for process-based loopback capture. The captured audio either includes or excludes audio rendered
// by the specified process and its child processes, based on how the ProcessLoopbackMode field is set.
typedef struct AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS
    {
    DWORD TargetProcessId;
    PROCESS_LOOPBACK_MODE ProcessLoopbackMode;
    }   AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS;

typedef /* [v1_enum] */ 
enum AUDIOCLIENT_ACTIVATION_TYPE
    {
        AUDIOCLIENT_ACTIVATION_TYPE_DEFAULT = 0,
        AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK    = 1
    }   AUDIOCLIENT_ACTIVATION_TYPE;

// Activation parameter structure that can be used with ActivateAudioInterfaceAsync
// to create an IAudioClient.
typedef struct AUDIOCLIENT_ACTIVATION_PARAMS
    {
    AUDIOCLIENT_ACTIVATION_TYPE ActivationType;
    union 
        {
        AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS ProcessLoopbackParams;
        }   DUMMYUNIONNAME;
    }   AUDIOCLIENT_ACTIVATION_PARAMS;

It seems to me that the goal is to allow an UWP app to capture audio output by some processes only (using the process ID) via the ActivateAudioInterfaceAsync function and a fake capture device.

So this does not seems to render SAR useless, as it is still not possible to output audio to a virtual user defined audio device.