Closed KillerBOSS2019 closed 1 year ago
DEVINTERFACE_AUDIO_RENDER = "#{e6327cad-dcec-4949-ae8a-991e976a79d2}"
DEVINTERFACE_AUDIO_CAPTURE = "#{2eef81be-33fa-4800-9670-1cd474972c3f}"
MMDEVAPI_TOKEN = "@\\?\SWD#MMDEVAPI#"
#pc.
def generateDeviceId(deviceId, flow):
return f"{MMDEVAPI_TOKEN}{deviceId}{(DEVINTERFACE_AUDIO_RENDER if flow == 0 else DEVINTERFACE_AUDIO_CAPTURE)}"
WindowsCreateString = ctypes.WinDLL("combase.dll").WindowsCreateString
WindowsCreateString.argtypes = [
wintypes.LPCWSTR,
wintypes.UINT,
ctypes.POINTER(wintypes.HSTR)
]
def SwitchProcessTo(deviceid, flow, ERole, processId):
generatedStr = generateDeviceId(deviceid, flow)
stringPtrDeviceId = wintypes.HSTR()
instr = generateDeviceId(deviceid, flow)
WindowsCreateString(instr, len(instr), ctypes.byref(stringPtrDeviceId))
print(generateDeviceId)
print(ctypes.string_at(ctypes.addressof(stringPtrDeviceId)))
I know nothing about C# but I managed to convert this part of code https://github.com/Belphemur/SoundSwitch/blob/d5380f894f118c3a4e13a04095d073e653aadaba/SoundSwitch.Audio.Manager/Interop/Client/ExtendedPolicyClient.cs#L57 now just this part https://github.com/Belphemur/SoundSwitch/blob/d5380f894f118c3a4e13a04095d073e653aadaba/SoundSwitch.Audio.Manager/Interop/Client/Extended/AudioPolicyConfig.cs#L119
solved
I was wondering if theres a way to route audio devices like in Volume Mixer when you click a app you can choose the output/input device.
Also I found this if it helps because I noticed it uses policyconfig thing https://github.com/Belphemur/SoundSwitch/blob/d5380f894f118c3a4e13a04095d073e653aadaba/SoundSwitch.Audio.Manager/AudioSwitcher.cs#L109