0xB0BAFE77

AutoHotkey Vista Audio Control Function v2.3

Apr 2nd, 2022
2,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; AutoHotkey Vista Audio Control Function v2.3
  2. ; Created by Lexikos
  3. ; https://www.autohotkey.com/board/topic/21984-vista-audio-control-functions/?p=143564
  4. ;
  5. ; MASTER CONTROLS
  6. ;
  7.  
  8. VA_GetMasterVolume(channel="", device_desc="playback")
  9. {
  10.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  11.         return
  12.     if channel =
  13.         VA_IAudioEndpointVolume_GetMasterVolumeLevelScalar(aev, vol)
  14.     else
  15.         VA_IAudioEndpointVolume_GetChannelVolumeLevelScalar(aev, channel-1, vol)
  16.     ObjRelease(aev)
  17.     return Round(vol*100,3)
  18. }
  19.  
  20. VA_SetMasterVolume(vol, channel="", device_desc="playback")
  21. {
  22.     vol := vol>100 ? 100 : vol<0 ? 0 : vol
  23.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  24.         return
  25.     if channel =
  26.         VA_IAudioEndpointVolume_SetMasterVolumeLevelScalar(aev, vol/100)
  27.     else
  28.         VA_IAudioEndpointVolume_SetChannelVolumeLevelScalar(aev, channel-1, vol/100)
  29.     ObjRelease(aev)
  30. }
  31.  
  32. VA_GetMasterChannelCount(device_desc="playback")
  33. {
  34.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  35.         return
  36.     VA_IAudioEndpointVolume_GetChannelCount(aev, count)
  37.     ObjRelease(aev)
  38.     return count
  39. }
  40.  
  41. VA_SetMasterMute(mute, device_desc="playback")
  42. {
  43.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  44.         return
  45.     VA_IAudioEndpointVolume_SetMute(aev, mute)
  46.     ObjRelease(aev)
  47. }
  48.  
  49. VA_GetMasterMute(device_desc="playback")
  50. {
  51.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  52.         return
  53.     VA_IAudioEndpointVolume_GetMute(aev, mute)
  54.     ObjRelease(aev)
  55.     return mute
  56. }
  57.  
  58. ;
  59. ; SUBUNIT CONTROLS
  60. ;
  61.  
  62. VA_GetVolume(subunit_desc="1", channel="", device_desc="playback")
  63. {
  64.     if ! avl := VA_GetDeviceSubunit(device_desc, subunit_desc, "{7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}")
  65.         return
  66.     VA_IPerChannelDbLevel_GetChannelCount(avl, channel_count)
  67.     if channel =
  68.     {
  69.         vol = 0
  70.        
  71.         Loop, %channel_count%
  72.         {
  73.             VA_IPerChannelDbLevel_GetLevelRange(avl, A_Index-1, min_dB, max_dB, step_dB)
  74.             VA_IPerChannelDbLevel_GetLevel(avl, A_Index-1, this_vol)
  75.             this_vol := VA_dB2Scalar(this_vol, min_dB, max_dB)
  76.            
  77.             ; "Speakers Properties" reports the highest channel as the volume.
  78.             if (this_vol > vol)
  79.                 vol := this_vol
  80.         }
  81.     }
  82.     else if channel between 1 and channel_count
  83.     {
  84.         channel -= 1
  85.         VA_IPerChannelDbLevel_GetLevelRange(avl, channel, min_dB, max_dB, step_dB)
  86.         VA_IPerChannelDbLevel_GetLevel(avl, channel, vol)
  87.         vol := VA_dB2Scalar(vol, min_dB, max_dB)
  88.     }
  89.     ObjRelease(avl)
  90.     return vol
  91. }
  92.  
  93. VA_SetVolume(vol, subunit_desc="1", channel="", device_desc="playback")
  94. {
  95.     if ! avl := VA_GetDeviceSubunit(device_desc, subunit_desc, "{7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}")
  96.         return
  97.    
  98.     vol := vol<0 ? 0 : vol>100 ? 100 : vol
  99.    
  100.     VA_IPerChannelDbLevel_GetChannelCount(avl, channel_count)
  101.    
  102.     if channel =
  103.     {
  104.         ; Simple method -- resets balance to "center":
  105.         ;VA_IPerChannelDbLevel_SetLevelUniform(avl, vol)
  106.        
  107.         vol_max = 0
  108.        
  109.         Loop, %channel_count%
  110.         {
  111.             VA_IPerChannelDbLevel_GetLevelRange(avl, A_Index-1, min_dB, max_dB, step_dB)
  112.             VA_IPerChannelDbLevel_GetLevel(avl, A_Index-1, this_vol)
  113.             this_vol := VA_dB2Scalar(this_vol, min_dB, max_dB)
  114.            
  115.             channel%A_Index%vol := this_vol
  116.             channel%A_Index%min := min_dB
  117.             channel%A_Index%max := max_dB
  118.            
  119.             ; Scale all channels relative to the loudest channel.
  120.             ; (This is how Vista's "Speakers Properties" dialog seems to work.)
  121.             if (this_vol > vol_max)
  122.                 vol_max := this_vol
  123.         }
  124.        
  125.         Loop, %channel_count%
  126.         {
  127.             this_vol := vol_max ? channel%A_Index%vol / vol_max * vol : vol
  128.             this_vol := VA_Scalar2dB(this_vol/100, channel%A_Index%min, channel%A_Index%max)            
  129.             VA_IPerChannelDbLevel_SetLevel(avl, A_Index-1, this_vol)
  130.         }
  131.     }
  132.     else if channel between 1 and %channel_count%
  133.     {
  134.         channel -= 1
  135.         VA_IPerChannelDbLevel_GetLevelRange(avl, channel, min_dB, max_dB, step_dB)
  136.         VA_IPerChannelDbLevel_SetLevel(avl, channel, VA_Scalar2dB(vol/100, min_dB, max_dB))
  137.     }
  138.     ObjRelease(avl)
  139. }
  140.  
  141. VA_GetChannelCount(subunit_desc="1", device_desc="playback")
  142. {
  143.     if ! avl := VA_GetDeviceSubunit(device_desc, subunit_desc, "{7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}")
  144.         return
  145.     VA_IPerChannelDbLevel_GetChannelCount(avl, channel_count)
  146.     ObjRelease(avl)
  147.     return channel_count
  148. }
  149.  
  150. VA_SetMute(mute, subunit_desc="1", device_desc="playback")
  151. {
  152.     if ! amute := VA_GetDeviceSubunit(device_desc, subunit_desc, "{DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E}")
  153.         return
  154.     VA_IAudioMute_SetMute(amute, mute)
  155.     ObjRelease(amute)
  156. }
  157.  
  158. VA_GetMute(subunit_desc="1", device_desc="playback")
  159. {
  160.     if ! amute := VA_GetDeviceSubunit(device_desc, subunit_desc, "{DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E}")
  161.         return
  162.     VA_IAudioMute_GetMute(amute, muted)
  163.     ObjRelease(amute)
  164.     return muted
  165. }
  166.  
  167. ;
  168. ; AUDIO METERING
  169. ;
  170.  
  171. VA_GetAudioMeter(device_desc="playback")
  172. {
  173.     if ! device := VA_GetDevice(device_desc)
  174.         return 0
  175.     VA_IMMDevice_Activate(device, "{C02216F6-8C67-4B5B-9D00-D008E73E0064}", 7, 0, audioMeter)
  176.     ObjRelease(device)
  177.     return audioMeter
  178. }
  179.  
  180. VA_GetDevicePeriod(device_desc, ByRef default_period, ByRef minimum_period="")
  181. {
  182.     defaultPeriod := minimumPeriod := 0
  183.     if ! device := VA_GetDevice(device_desc)
  184.         return false
  185.     VA_IMMDevice_Activate(device, "{1CB9AD4C-DBFA-4c32-B178-C2F568A703B2}", 7, 0, audioClient)
  186.     ObjRelease(device)
  187.     ; IAudioClient::GetDevicePeriod
  188.     DllCall(NumGet(NumGet(audioClient+0)+9*A_PtrSize), "ptr",audioClient, "int64*",default_period, "int64*",minimum_period)
  189.     ; Convert 100-nanosecond units to milliseconds.
  190.     default_period /= 10000
  191.     minimum_period /= 10000    
  192.     ObjRelease(audioClient)
  193.     return true
  194. }
  195.  
  196. VA_GetAudioEndpointVolume(device_desc="playback")
  197. {
  198.     if ! device := VA_GetDevice(device_desc)
  199.         return 0
  200.     VA_IMMDevice_Activate(device, "{5CDF2C82-841E-4546-9722-0CF74078229A}", 7, 0, endpointVolume)
  201.     ObjRelease(device)
  202.     return endpointVolume
  203. }
  204.  
  205. VA_GetDeviceSubunit(device_desc, subunit_desc, subunit_iid)
  206. {
  207.     if ! device := VA_GetDevice(device_desc)
  208.         return 0
  209.     subunit := VA_FindSubunit(device, subunit_desc, subunit_iid)
  210.     ObjRelease(device)
  211.     return subunit
  212. }
  213.  
  214. VA_FindSubunit(device, target_desc, target_iid)
  215. {
  216.     if target_desc is integer
  217.         target_index := target_desc
  218.     else
  219.         RegExMatch(target_desc, "(?<_name>.*?)(?::(?<_index>\d+))?$", target)
  220.     ; v2.01: Since target_name is now a regular expression, default to case-insensitive mode if no options are specified.
  221.     if !RegExMatch(target_name,"^[^\(]+\)")
  222.         target_name := "i)" target_name
  223.     r := VA_EnumSubunits(device, "VA_FindSubunitCallback", target_name, target_iid
  224.             , Object(0, target_index ? target_index : 1, 1, 0))
  225.     return r
  226. }
  227.  
  228. VA_FindSubunitCallback(part, interface, index)
  229. {
  230.     index[1] := index[1] + 1 ; current += 1
  231.     if (index[0] == index[1]) ; target == current ?
  232.     {
  233.         ObjAddRef(interface)
  234.         return interface
  235.     }
  236. }
  237.  
  238. VA_EnumSubunits(device, callback, target_name="", target_iid="", callback_param="")
  239. {
  240.     VA_IMMDevice_Activate(device, "{2A07407E-6497-4A18-9787-32F79BD0D98F}", 7, 0, deviceTopology)
  241.     VA_IDeviceTopology_GetConnector(deviceTopology, 0, conn)
  242.     ObjRelease(deviceTopology)
  243.     VA_IConnector_GetConnectedTo(conn, conn_to)
  244.     VA_IConnector_GetDataFlow(conn, data_flow)
  245.     ObjRelease(conn)
  246.     if !conn_to
  247.         return ; blank to indicate error
  248.     part := ComObjQuery(conn_to, "{AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9}") ; IID_IPart
  249.     ObjRelease(conn_to)
  250.     if !part
  251.         return
  252.     r := VA_EnumSubunitsEx(part, data_flow, callback, target_name, target_iid, callback_param)
  253.     ObjRelease(part)
  254.     return r ; value returned by callback, or zero.
  255. }
  256.  
  257. VA_EnumSubunitsEx(part, data_flow, callback, target_name="", target_iid="", callback_param="")
  258. {
  259.     r := 0
  260.    
  261.     VA_IPart_GetPartType(part, type)
  262.    
  263.     if type = 1 ; Subunit
  264.     {
  265.         VA_IPart_GetName(part, name)
  266.        
  267.         ; v2.01: target_name is now a regular expression.
  268.         if RegExMatch(name, target_name)
  269.         {
  270.             if target_iid =
  271.                 r := %callback%(part, 0, callback_param)
  272.             else
  273.                 if VA_IPart_Activate(part, 7, target_iid, interface) = 0
  274.                 {
  275.                     r := %callback%(part, interface, callback_param)
  276.                     ; The callback is responsible for calling ObjAddRef()
  277.                     ; if it intends to keep the interface pointer.
  278.                     ObjRelease(interface)
  279.                 }
  280.  
  281.             if r
  282.                 return r ; early termination
  283.         }
  284.     }
  285.    
  286.     if data_flow = 0
  287.         VA_IPart_EnumPartsIncoming(part, parts)
  288.     else
  289.         VA_IPart_EnumPartsOutgoing(part, parts)
  290.    
  291.     VA_IPartsList_GetCount(parts, count)
  292.     Loop %count%
  293.     {
  294.         VA_IPartsList_GetPart(parts, A_Index-1, subpart)        
  295.         r := VA_EnumSubunitsEx(subpart, data_flow, callback, target_name, target_iid, callback_param)
  296.         ObjRelease(subpart)
  297.         if r
  298.             break ; early termination
  299.     }
  300.     ObjRelease(parts)
  301.     return r ; continue/finished enumeration
  302. }
  303.  
  304. ; device_desc = device_id
  305. ;               | ( friendly_name | 'playback' | 'capture' ) [ ':' index ]
  306. VA_GetDevice(device_desc="playback")
  307. {
  308.     static CLSID_MMDeviceEnumerator := "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
  309.         , IID_IMMDeviceEnumerator := "{A95664D2-9614-4F35-A746-DE8DB63617E6}"
  310.     if !(deviceEnumerator := ComObjCreate(CLSID_MMDeviceEnumerator, IID_IMMDeviceEnumerator))
  311.         return 0
  312.    
  313.     device := 0
  314.    
  315.     if VA_IMMDeviceEnumerator_GetDevice(deviceEnumerator, device_desc, device) = 0
  316.         goto VA_GetDevice_Return
  317.    
  318.     if device_desc is integer
  319.     {
  320.         m2 := device_desc
  321.         if m2 >= 4096 ; Probably a device pointer, passed here indirectly via VA_GetAudioMeter or such.
  322.         {
  323.             ObjAddRef(device := m2)
  324.             goto VA_GetDevice_Return
  325.         }
  326.     }
  327.     else
  328.         RegExMatch(device_desc, "(.*?)\s*(?::(\d+))?$", m)
  329.    
  330.     if m1 in playback,p
  331.         m1 := "", flow := 0 ; eRender
  332.     else if m1 in capture,c
  333.         m1 := "", flow := 1 ; eCapture
  334.     else if (m1 . m2) = ""  ; no name or number specified
  335.         m1 := "", flow := 0 ; eRender (default)
  336.     else
  337.         flow := 2 ; eAll
  338.    
  339.     if (m1 . m2) = ""   ; no name or number (maybe "playback" or "capture")
  340.     {
  341.         VA_IMMDeviceEnumerator_GetDefaultAudioEndpoint(deviceEnumerator, flow, 0, device)
  342.         goto VA_GetDevice_Return
  343.     }
  344.  
  345.     VA_IMMDeviceEnumerator_EnumAudioEndpoints(deviceEnumerator, flow, 1, devices)
  346.    
  347.     if m1 =
  348.     {
  349.         VA_IMMDeviceCollection_Item(devices, m2-1, device)
  350.         goto VA_GetDevice_Return
  351.     }
  352.    
  353.     VA_IMMDeviceCollection_GetCount(devices, count)
  354.     index := 0
  355.     Loop % count
  356.         if VA_IMMDeviceCollection_Item(devices, A_Index-1, device) = 0
  357.             if InStr(VA_GetDeviceName(device), m1) && (m2 = "" || ++index = m2)
  358.                 goto VA_GetDevice_Return
  359.             else
  360.                 ObjRelease(device), device:=0
  361.  
  362. VA_GetDevice_Return:
  363.    ObjRelease(deviceEnumerator)
  364.     if devices
  365.         ObjRelease(devices)
  366.    
  367.     return device ; may be 0
  368. }
  369.  
  370. VA_GetDeviceName(device)
  371. {
  372.     static PKEY_Device_FriendlyName
  373.     if !VarSetCapacity(PKEY_Device_FriendlyName)
  374.         VarSetCapacity(PKEY_Device_FriendlyName, 20)
  375.         ,VA_GUID(PKEY_Device_FriendlyName :="{A45C254E-DF1C-4EFD-8020-67D146A850E0}")
  376.         ,NumPut(14, PKEY_Device_FriendlyName, 16)
  377.     VarSetCapacity(prop, 16)
  378.     VA_IMMDevice_OpenPropertyStore(device, 0, store)
  379.     ; store->GetValue(.., [out] prop)
  380.     DllCall(NumGet(NumGet(store+0)+5*A_PtrSize), "ptr", store, "ptr", &PKEY_Device_FriendlyName, "ptr", &prop)
  381.     ObjRelease(store)
  382.     VA_WStrOut(deviceName := NumGet(prop,8))
  383.     return deviceName
  384. }
  385.  
  386. VA_SetDefaultEndpoint(device_desc, role)
  387. {
  388.     /* Roles:
  389.          eConsole        = 0  ; Default Device
  390.          eMultimedia     = 1
  391.          eCommunications = 2  ; Default Communications Device
  392.     */
  393.     if ! device := VA_GetDevice(device_desc)
  394.         return 0
  395.     if VA_IMMDevice_GetId(device, id) = 0
  396.     {
  397.         cfg := ComObjCreate("{294935CE-F637-4E7C-A41B-AB255460B862}"
  398.                           , "{568b9108-44bf-40b4-9006-86afe5b5a620}")
  399.         hr := VA_xIPolicyConfigVista_SetDefaultEndpoint(cfg, id, role)
  400.         ObjRelease(cfg)
  401.     }
  402.     ObjRelease(device)
  403.     return hr = 0
  404. }
  405.  
  406.  
  407. ;
  408. ; HELPERS
  409. ;
  410.  
  411. ; Convert string to binary GUID structure.
  412. VA_GUID(ByRef guid_out, guid_in="%guid_out%") {
  413.     if (guid_in == "%guid_out%")
  414.         guid_in :=   guid_out
  415.     if  guid_in is integer
  416.         return guid_in
  417.     VarSetCapacity(guid_out, 16, 0)
  418.     DllCall("ole32\CLSIDFromString", "wstr", guid_in, "ptr", &guid_out)
  419.     return &guid_out
  420. }
  421.  
  422. ; Convert binary GUID structure to string.
  423. VA_GUIDOut(ByRef guid) {
  424.     VarSetCapacity(buf, 78)
  425.     DllCall("ole32\StringFromGUID2", "ptr", &guid, "ptr", &buf, "int", 39)
  426.     guid := StrGet(&buf, "UTF-16")
  427. }
  428.  
  429. ; Convert COM-allocated wide char string pointer to usable string.
  430. VA_WStrOut(ByRef str) {
  431.     str := StrGet(ptr := str, "UTF-16")
  432.     DllCall("ole32\CoTaskMemFree", "ptr", ptr)  ; FREES THE STRING.
  433. }
  434.  
  435. VA_dB2Scalar(dB, min_dB, max_dB) {
  436.     min_s := 10**(min_dB/20), max_s := 10**(max_dB/20)
  437.     return ((10**(dB/20))-min_s)/(max_s-min_s)*100
  438. }
  439.  
  440. VA_Scalar2dB(s, min_dB, max_dB) {
  441.     min_s := 10**(min_dB/20), max_s := 10**(max_dB/20)
  442.     return log((max_s-min_s)*s+min_s)*20
  443. }
  444.  
  445.  
  446. ;
  447. ; INTERFACE WRAPPERS
  448. ;   Reference: Core Audio APIs in Windows Vista -- Programming Reference
  449. ;       http://msdn2.microsoft.com/en-us/library/ms679156(VS.85).aspx
  450. ;
  451.  
  452. ;
  453. ; IMMDevice : {D666063F-1587-4E43-81F1-B948E807363F}
  454. ;
  455. VA_IMMDevice_Activate(this, iid, ClsCtx, ActivationParams, ByRef Interface) {
  456.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr", VA_GUID(iid), "uint", ClsCtx, "uint", ActivationParams, "ptr*", Interface)
  457. }
  458. VA_IMMDevice_OpenPropertyStore(this, Access, ByRef Properties) {
  459.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Access, "ptr*", Properties)
  460. }
  461. VA_IMMDevice_GetId(this, ByRef Id) {
  462.     hr := DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint*", Id)
  463.     VA_WStrOut(Id)
  464.     return hr
  465. }
  466. VA_IMMDevice_GetState(this, ByRef State) {
  467.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint*", State)
  468. }
  469.  
  470. ;
  471. ; IDeviceTopology : {2A07407E-6497-4A18-9787-32F79BD0D98F}
  472. ;
  473. VA_IDeviceTopology_GetConnectorCount(this, ByRef Count) {
  474.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Count)
  475. }
  476. VA_IDeviceTopology_GetConnector(this, Index, ByRef Connector) {
  477.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Connector)
  478. }
  479. VA_IDeviceTopology_GetSubunitCount(this, ByRef Count) {
  480.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint*", Count)
  481. }
  482. VA_IDeviceTopology_GetSubunit(this, Index, ByRef Subunit) {
  483.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Subunit)
  484. }
  485. VA_IDeviceTopology_GetPartById(this, Id, ByRef Part) {
  486.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "uint", Id, "ptr*", Part)
  487. }
  488. VA_IDeviceTopology_GetDeviceId(this, ByRef DeviceId) {
  489.     hr := DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint*", DeviceId)
  490.     VA_WStrOut(DeviceId)
  491.     return hr
  492. }
  493. VA_IDeviceTopology_GetSignalPath(this, PartFrom, PartTo, RejectMixedPaths, ByRef Parts) {
  494.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr", PartFrom, "ptr", PartTo, "int", RejectMixedPaths, "ptr*", Parts)
  495. }
  496.  
  497. ;
  498. ; IConnector : {9c2c4058-23f5-41de-877a-df3af236a09e}
  499. ;
  500. VA_IConnector_GetType(this, ByRef Type) {
  501.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", Type)
  502. }
  503. VA_IConnector_GetDataFlow(this, ByRef Flow) {
  504.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int*", Flow)
  505. }
  506. VA_IConnector_ConnectTo(this, ConnectTo) {
  507.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "ptr", ConnectTo)
  508. }
  509. VA_IConnector_Disconnect(this) {
  510.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this)
  511. }
  512. VA_IConnector_IsConnected(this, ByRef Connected) {
  513.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "int*", Connected)
  514. }
  515. VA_IConnector_GetConnectedTo(this, ByRef ConTo) {
  516.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "ptr*", ConTo)
  517. }
  518. VA_IConnector_GetConnectorIdConnectedTo(this, ByRef ConnectorId) {
  519.     hr := DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr*", ConnectorId)
  520.     VA_WStrOut(ConnectorId)
  521.     return hr
  522. }
  523. VA_IConnector_GetDeviceIdConnectedTo(this, ByRef DeviceId) {
  524.     hr := DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "ptr*", DeviceId)
  525.     VA_WStrOut(DeviceId)
  526.     return hr
  527. }
  528.  
  529. ;
  530. ; IPart : {AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9}
  531. ;
  532. VA_IPart_GetName(this, ByRef Name) {
  533.     hr := DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr*", Name)
  534.     VA_WStrOut(Name)
  535.     return hr
  536. }
  537. VA_IPart_GetLocalId(this, ByRef Id) {
  538.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint*", Id)
  539. }
  540. VA_IPart_GetGlobalId(this, ByRef GlobalId) {
  541.     hr := DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "ptr*", GlobalId)
  542.     VA_WStrOut(GlobalId)
  543.     return hr
  544. }
  545. VA_IPart_GetPartType(this, ByRef PartType) {
  546.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "int*", PartType)
  547. }
  548. VA_IPart_GetSubType(this, ByRef SubType) {
  549.     VarSetCapacity(SubType,16,0)
  550.     hr := DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "ptr", &SubType)
  551.     VA_GUIDOut(SubType)
  552.     return hr
  553. }
  554. VA_IPart_GetControlInterfaceCount(this, ByRef Count) {
  555.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint*", Count)
  556. }
  557. VA_IPart_GetControlInterface(this, Index, ByRef InterfaceDesc) {
  558.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "uint", Index, "ptr*", InterfaceDesc)
  559. }
  560. VA_IPart_EnumPartsIncoming(this, ByRef Parts) {
  561.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "ptr*", Parts)
  562. }
  563. VA_IPart_EnumPartsOutgoing(this, ByRef Parts) {
  564.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this, "ptr*", Parts)
  565. }
  566. VA_IPart_GetTopologyObject(this, ByRef Topology) {
  567.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "ptr*", Topology)
  568. }
  569. VA_IPart_Activate(this, ClsContext, iid, ByRef Object) {
  570.     return DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "uint", ClsContext, "ptr", VA_GUID(iid), "ptr*", Object)
  571. }
  572. VA_IPart_RegisterControlChangeCallback(this, iid, Notify) {
  573.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "ptr", VA_GUID(iid), "ptr", Notify)
  574. }
  575. VA_IPart_UnregisterControlChangeCallback(this, Notify) {
  576.     return DllCall(NumGet(NumGet(this+0)+15*A_PtrSize), "ptr", this, "ptr", Notify)
  577. }
  578.  
  579. ;
  580. ; IPartsList : {6DAA848C-5EB0-45CC-AEA5-998A2CDA1FFB}
  581. ;
  582. VA_IPartsList_GetCount(this, ByRef Count) {
  583.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Count)
  584. }
  585. VA_IPartsList_GetPart(this, INdex, ByRef Part) {
  586.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Part)
  587. }
  588.  
  589. ;
  590. ; IAudioEndpointVolume : {5CDF2C82-841E-4546-9722-0CF74078229A}
  591. ;
  592. VA_IAudioEndpointVolume_RegisterControlChangeNotify(this, Notify) {
  593.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr", Notify)
  594. }
  595. VA_IAudioEndpointVolume_UnregisterControlChangeNotify(this, Notify) {
  596.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr", Notify)
  597. }
  598. VA_IAudioEndpointVolume_GetChannelCount(this, ByRef ChannelCount) {
  599.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint*", ChannelCount)
  600. }
  601. VA_IAudioEndpointVolume_SetMasterVolumeLevel(this, LevelDB, GuidEventContext="") {
  602.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  603. }
  604. VA_IAudioEndpointVolume_SetMasterVolumeLevelScalar(this, Level, GuidEventContext="") {
  605.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "float", Level, "ptr", VA_GUID(GuidEventContext))
  606. }
  607. VA_IAudioEndpointVolume_GetMasterVolumeLevel(this, ByRef LevelDB) {
  608.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "float*", LevelDB)
  609. }
  610. VA_IAudioEndpointVolume_GetMasterVolumeLevelScalar(this, ByRef Level) {
  611.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "float*", Level)
  612. }
  613. VA_IAudioEndpointVolume_SetChannelVolumeLevel(this, Channel, LevelDB, GuidEventContext="") {
  614.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "uint", Channel, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  615. }
  616. VA_IAudioEndpointVolume_SetChannelVolumeLevelScalar(this, Channel, Level, GuidEventContext="") {
  617.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this, "uint", Channel, "float", Level, "ptr", VA_GUID(GuidEventContext))
  618. }
  619. VA_IAudioEndpointVolume_GetChannelVolumeLevel(this, Channel, ByRef LevelDB) {
  620.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "uint", Channel, "float*", LevelDB)
  621. }
  622. VA_IAudioEndpointVolume_GetChannelVolumeLevelScalar(this, Channel, ByRef Level) {
  623.     return DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "uint", Channel, "float*", Level)
  624. }
  625. VA_IAudioEndpointVolume_SetMute(this, Mute, GuidEventContext="") {
  626.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "int", Mute, "ptr", VA_GUID(GuidEventContext))
  627. }
  628. VA_IAudioEndpointVolume_GetMute(this, ByRef Mute) {
  629.     return DllCall(NumGet(NumGet(this+0)+15*A_PtrSize), "ptr", this, "int*", Mute)
  630. }
  631. VA_IAudioEndpointVolume_GetVolumeStepInfo(this, ByRef Step, ByRef StepCount) {
  632.     return DllCall(NumGet(NumGet(this+0)+16*A_PtrSize), "ptr", this, "uint*", Step, "uint*", StepCount)
  633. }
  634. VA_IAudioEndpointVolume_VolumeStepUp(this, GuidEventContext="") {
  635.     return DllCall(NumGet(NumGet(this+0)+17*A_PtrSize), "ptr", this, "ptr", VA_GUID(GuidEventContext))
  636. }
  637. VA_IAudioEndpointVolume_VolumeStepDown(this, GuidEventContext="") {
  638.     return DllCall(NumGet(NumGet(this+0)+18*A_PtrSize), "ptr", this, "ptr", VA_GUID(GuidEventContext))
  639. }
  640. VA_IAudioEndpointVolume_QueryHardwareSupport(this, ByRef HardwareSupportMask) {
  641.     return DllCall(NumGet(NumGet(this+0)+19*A_PtrSize), "ptr", this, "uint*", HardwareSupportMask)
  642. }
  643. VA_IAudioEndpointVolume_GetVolumeRange(this, ByRef MinDB, ByRef MaxDB, ByRef IncrementDB) {
  644.     return DllCall(NumGet(NumGet(this+0)+20*A_PtrSize), "ptr", this, "float*", MinDB, "float*", MaxDB, "float*", IncrementDB)
  645. }
  646.  
  647. ;
  648. ; IPerChannelDbLevel  : {C2F8E001-F205-4BC9-99BC-C13B1E048CCB}
  649. ;   IAudioVolumeLevel : {7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}
  650. ;   IAudioBass        : {A2B1A1D9-4DB3-425D-A2B2-BD335CB3E2E5}
  651. ;   IAudioMidrange    : {5E54B6D7-B44B-40D9-9A9E-E691D9CE6EDF}
  652. ;   IAudioTreble      : {0A717812-694E-4907-B74B-BAFA5CFDCA7B}
  653. ;
  654. VA_IPerChannelDbLevel_GetChannelCount(this, ByRef Channels) {
  655.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Channels)
  656. }
  657. VA_IPerChannelDbLevel_GetLevelRange(this, Channel, ByRef MinLevelDB, ByRef MaxLevelDB, ByRef Stepping) {
  658.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Channel, "float*", MinLevelDB, "float*", MaxLevelDB, "float*", Stepping)
  659. }
  660. VA_IPerChannelDbLevel_GetLevel(this, Channel, ByRef LevelDB) {
  661.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint", Channel, "float*", LevelDB)
  662. }
  663. VA_IPerChannelDbLevel_SetLevel(this, Channel, LevelDB, GuidEventContext="") {
  664.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint", Channel, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  665. }
  666. VA_IPerChannelDbLevel_SetLevelUniform(this, LevelDB, GuidEventContext="") {
  667.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  668. }
  669. VA_IPerChannelDbLevel_SetLevelAllChannels(this, LevelsDB, ChannelCount, GuidEventContext="") {
  670.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint", LevelsDB, "uint", ChannelCount, "ptr", VA_GUID(GuidEventContext))
  671. }
  672.  
  673. ;
  674. ; IAudioMute : {DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E}
  675. ;
  676. VA_IAudioMute_SetMute(this, Muted, GuidEventContext="") {
  677.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int", Muted, "ptr", VA_GUID(GuidEventContext))
  678. }
  679. VA_IAudioMute_GetMute(this, ByRef Muted) {
  680.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int*", Muted)
  681. }
  682.  
  683. ;
  684. ; IAudioAutoGainControl : {85401FD4-6DE4-4b9d-9869-2D6753A82F3C}
  685. ;
  686. VA_IAudioAutoGainControl_GetEnabled(this, ByRef Enabled) {
  687.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", Enabled)
  688. }
  689. VA_IAudioAutoGainControl_SetEnabled(this, Enable, GuidEventContext="") {
  690.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int", Enable, "ptr", VA_GUID(GuidEventContext))
  691. }
  692.  
  693. ;
  694. ; IAudioMeterInformation : {C02216F6-8C67-4B5B-9D00-D008E73E0064}
  695. ;
  696. VA_IAudioMeterInformation_GetPeakValue(this, ByRef Peak) {
  697.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "float*", Peak)
  698. }
  699. VA_IAudioMeterInformation_GetMeteringChannelCount(this, ByRef ChannelCount) {
  700.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint*", ChannelCount)
  701. }
  702. VA_IAudioMeterInformation_GetChannelsPeakValues(this, ChannelCount, PeakValues) {
  703.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint", ChannelCount, "ptr", PeakValues)
  704. }
  705. VA_IAudioMeterInformation_QueryHardwareSupport(this, ByRef HardwareSupportMask) {
  706.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint*", HardwareSupportMask)
  707. }
  708.  
  709. ;
  710. ; IAudioClient : {1CB9AD4C-DBFA-4c32-B178-C2F568A703B2}
  711. ;
  712. VA_IAudioClient_Initialize(this, ShareMode, StreamFlags, BufferDuration, Periodicity, Format, AudioSessionGuid) {
  713.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int", ShareMode, "uint", StreamFlags, "int64", BufferDuration, "int64", Periodicity, "ptr", Format, "ptr", VA_GUID(AudioSessionGuid))
  714. }
  715. VA_IAudioClient_GetBufferSize(this, ByRef NumBufferFrames) {
  716.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint*", NumBufferFrames)
  717. }
  718. VA_IAudioClient_GetStreamLatency(this, ByRef Latency) {
  719.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "int64*", Latency)
  720. }
  721. VA_IAudioClient_GetCurrentPadding(this, ByRef NumPaddingFrames) {
  722.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint*", NumPaddingFrames)
  723. }
  724. VA_IAudioClient_IsFormatSupported(this, ShareMode, Format, ByRef ClosestMatch) {
  725.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "int", ShareMode, "ptr", Format, "ptr*", ClosestMatch)
  726. }
  727. VA_IAudioClient_GetMixFormat(this, ByRef Format) {
  728.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint*", Format)
  729. }
  730. VA_IAudioClient_GetDevicePeriod(this, ByRef DefaultDevicePeriod, ByRef MinimumDevicePeriod) {
  731.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "int64*", DefaultDevicePeriod, "int64*", MinimumDevicePeriod)
  732. }
  733. VA_IAudioClient_Start(this) {
  734.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this)
  735. }
  736. VA_IAudioClient_Stop(this) {
  737.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this)
  738. }
  739. VA_IAudioClient_Reset(this) {
  740.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this)
  741. }
  742. VA_IAudioClient_SetEventHandle(this, eventHandle) {
  743.     return DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "ptr", eventHandle)
  744. }
  745. VA_IAudioClient_GetService(this, iid, ByRef Service) {
  746.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "ptr", VA_GUID(iid), "ptr*", Service)
  747. }
  748.  
  749. ;
  750. ; IAudioSessionControl : {F4B1A599-7266-4319-A8CA-E70ACB11E8CD}
  751. ;
  752. /*
  753. AudioSessionStateInactive = 0
  754. AudioSessionStateActive = 1
  755. AudioSessionStateExpired = 2
  756. */
  757. VA_IAudioSessionControl_GetState(this, ByRef State) {
  758.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", State)
  759. }
  760. VA_IAudioSessionControl_GetDisplayName(this, ByRef DisplayName) {
  761.     hr := DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr*", DisplayName)
  762.     VA_WStrOut(DisplayName)
  763.     return hr
  764. }
  765. VA_IAudioSessionControl_SetDisplayName(this, DisplayName, EventContext) {
  766.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "wstr", DisplayName, "ptr", VA_GUID(EventContext))
  767. }
  768. VA_IAudioSessionControl_GetIconPath(this, ByRef IconPath) {
  769.     hr := DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "ptr*", IconPath)
  770.     VA_WStrOut(IconPath)
  771.     return hr
  772. }
  773. VA_IAudioSessionControl_SetIconPath(this, IconPath) {
  774.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "wstr", IconPath)
  775. }
  776. VA_IAudioSessionControl_GetGroupingParam(this, ByRef Param) {
  777.     VarSetCapacity(Param,16,0)
  778.     hr := DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "ptr", &Param)
  779.     VA_GUIDOut(Param)
  780.     return hr
  781. }
  782. VA_IAudioSessionControl_SetGroupingParam(this, Param, EventContext) {
  783.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr", VA_GUID(Param), "ptr", VA_GUID(EventContext))
  784. }
  785. VA_IAudioSessionControl_RegisterAudioSessionNotification(this, NewNotifications) {
  786.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "ptr", NewNotifications)
  787. }
  788. VA_IAudioSessionControl_UnregisterAudioSessionNotification(this, NewNotifications) {
  789.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this, "ptr", NewNotifications)
  790. }
  791.  
  792. ;
  793. ; IAudioSessionManager : {BFA971F1-4D5E-40BB-935E-967039BFBEE4}
  794. ;
  795. VA_IAudioSessionManager_GetAudioSessionControl(this, AudioSessionGuid) {
  796.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr", VA_GUID(AudioSessionGuid))
  797. }
  798. VA_IAudioSessionManager_GetSimpleAudioVolume(this, AudioSessionGuid, StreamFlags, ByRef AudioVolume) {
  799.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr", VA_GUID(AudioSessionGuid), "uint", StreamFlags, "uint*", AudioVolume)
  800. }
  801.  
  802. ;
  803. ; IMMDeviceEnumerator
  804. ;
  805. VA_IMMDeviceEnumerator_EnumAudioEndpoints(this, DataFlow, StateMask, ByRef Devices) {
  806.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int", DataFlow, "uint", StateMask, "ptr*", Devices)
  807. }
  808. VA_IMMDeviceEnumerator_GetDefaultAudioEndpoint(this, DataFlow, Role, ByRef Endpoint) {
  809.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int", DataFlow, "int", Role, "ptr*", Endpoint)
  810. }
  811. VA_IMMDeviceEnumerator_GetDevice(this, id, ByRef Device) {
  812.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "wstr", id, "ptr*", Device)
  813. }
  814. VA_IMMDeviceEnumerator_RegisterEndpointNotificationCallback(this, Client) {
  815.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "ptr", Client)
  816. }
  817. VA_IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(this, Client) {
  818.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "ptr", Client)
  819. }
  820.  
  821. ;
  822. ; IMMDeviceCollection
  823. ;
  824. VA_IMMDeviceCollection_GetCount(this, ByRef Count) {
  825.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Count)
  826. }
  827. VA_IMMDeviceCollection_Item(this, Index, ByRef Device) {
  828.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Device)
  829. }
  830.  
  831. ;
  832. ; IControlInterface
  833. ;
  834. VA_IControlInterface_GetName(this, ByRef Name) {
  835.     hr := DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr*", Name)
  836.     VA_WStrOut(Name)
  837.     return hr
  838. }
  839. VA_IControlInterface_GetIID(this, ByRef IID) {
  840.     VarSetCapacity(IID,16,0)
  841.     hr := DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr", &IID)
  842.     VA_GUIDOut(IID)
  843.     return hr
  844. }
  845.  
  846.  
  847. /*
  848.     INTERFACES REQUIRING WINDOWS 7 / SERVER 2008 R2
  849. */
  850.  
  851. ;
  852. ; IAudioSessionControl2 : {bfb7ff88-7239-4fc9-8fa2-07c950be9c6d}
  853. ;   extends IAudioSessionControl
  854. ;
  855. VA_IAudioSessionControl2_GetSessionIdentifier(this, ByRef id) {
  856.     hr := DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "ptr*", id)
  857.     VA_WStrOut(id)
  858.     return hr
  859. }
  860. VA_IAudioSessionControl2_GetSessionInstanceIdentifier(this, ByRef id) {
  861.     hr := DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "ptr*", id)
  862.     VA_WStrOut(id)
  863.     return hr
  864. }
  865. VA_IAudioSessionControl2_GetProcessId(this, ByRef pid) {
  866.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "uint*", pid)
  867. }
  868. VA_IAudioSessionControl2_IsSystemSoundsSession(this) {
  869.     return DllCall(NumGet(NumGet(this+0)+15*A_PtrSize), "ptr", this)
  870. }
  871. VA_IAudioSessionControl2_SetDuckingPreference(this, OptOut) {
  872.     return DllCall(NumGet(NumGet(this+0)+16*A_PtrSize), "ptr", this, "int", OptOut)
  873. }
  874.  
  875. ;
  876. ; IAudioSessionManager2 : {77AA99A0-1BD6-484F-8BC7-2C654C9A9B6F}
  877. ;   extends IAudioSessionManager
  878. ;
  879. VA_IAudioSessionManager2_GetSessionEnumerator(this, ByRef SessionEnum) {
  880.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "ptr*", SessionEnum)
  881. }
  882. VA_IAudioSessionManager2_RegisterSessionNotification(this, SessionNotification) {
  883.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  884. }
  885. VA_IAudioSessionManager2_UnregisterSessionNotification(this, SessionNotification) {
  886.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  887. }
  888. VA_IAudioSessionManager2_RegisterDuckNotification(this, SessionNotification) {
  889.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  890. }
  891. VA_IAudioSessionManager2_UnregisterDuckNotification(this, SessionNotification) {
  892.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  893. }
  894.  
  895. ;
  896. ; IAudioSessionEnumerator : {E2F5BB11-0570-40CA-ACDD-3AA01277DEE8}
  897. ;
  898. VA_IAudioSessionEnumerator_GetCount(this, ByRef SessionCount) {
  899.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", SessionCount)
  900. }
  901. VA_IAudioSessionEnumerator_GetSession(this, SessionCount, ByRef Session) {
  902.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int", SessionCount, "ptr*", Session)
  903. }
  904.  
  905.  
  906. /*
  907.     UNDOCUMENTED INTERFACES
  908. */
  909.  
  910. ; Thanks to Dave Amenta for publishing this interface - http://goo.gl/6L93L
  911. ; IID := "{568b9108-44bf-40b4-9006-86afe5b5a620}"
  912. ; CLSID := "{294935CE-F637-4E7C-A41B-AB255460B862}"
  913. VA_xIPolicyConfigVista_SetDefaultEndpoint(this, DeviceId, Role) {
  914.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "wstr", DeviceId, "int", Role)
  915. }
  916.  
Advertisement
Add Comment
Please, Sign In to add comment