1#![allow(dead_code)]
2#![allow(non_upper_case_globals)]
3#![allow(non_snake_case)]
4#![allow(clippy::missing_safety_doc)]
5
6use std::ffi::c_void;
7use std::mem::zeroed;
8use windows::core::imp::CanInto;
9use windows::core::{IUnknown, Interface, Param, Result, BOOL, GUID, HRESULT, PCWSTR};
10use windows::Devices::Custom::DeviceSharingMode;
11use windows::Win32::Foundation::PROPERTYKEY;
12use windows::Win32::Media::Audio::{ERole, WAVEFORMATEX};
13use windows::Win32::System::Com::StructuredStorage::PROPVARIANT;
14
15pub const PolicyConfigClient: GUID = GUID::from_u128(0x870af99c_171d_4f9e_af0d_e63df40c2bc9);
16
17#[repr(transparent)]
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct IPolicyConfig(IUnknown);
20
21impl CanInto<IUnknown> for IPolicyConfig {}
22
23impl IPolicyConfig {
24 pub unsafe fn GetMixFormat(
25 &self,
26 device_name: impl Param<PCWSTR>,
27 ) -> Result<*mut WAVEFORMATEX> {
28 let mut result__ = zeroed::<*mut WAVEFORMATEX>();
29 (Interface::vtable(self).GetMixFormat)(
30 Interface::as_raw(self),
31 device_name.param().abi(),
32 &mut result__,
33 )
34 .map(|| result__)
35 }
36
37 pub unsafe fn GetDeviceFormat(
38 &self,
39 device_name: impl Param<PCWSTR>,
40 default: impl Into<BOOL>,
41 ) -> Result<*mut WAVEFORMATEX> {
42 let mut result__ = zeroed::<*mut WAVEFORMATEX>();
43 (Interface::vtable(self).GetDeviceFormat)(
44 Interface::as_raw(self),
45 device_name.param().abi(),
46 default.into().0,
47 &mut result__,
48 )
49 .map(|| result__)
50 }
51
52 pub unsafe fn ResetDeviceFormat(&self, device_name: impl Param<PCWSTR>) -> Result<()> {
53 (Interface::vtable(self).ResetDeviceFormat)(
54 Interface::as_raw(self),
55 device_name.param().abi(),
56 )
57 .ok()
58 }
59
60 pub unsafe fn SetDeviceFormat(
61 &self,
62 device_name: impl Param<PCWSTR>,
63 mut endpoint_format: WAVEFORMATEX,
64 mut mix_format: WAVEFORMATEX,
65 ) -> Result<()> {
66 (Interface::vtable(self).SetDeviceFormat)(
67 Interface::as_raw(self),
68 device_name.param().abi(),
69 &mut endpoint_format,
70 &mut mix_format,
71 )
72 .ok()
73 }
74
75 pub unsafe fn GetProcessingPeriod(
76 &self,
77 device_name: impl Param<PCWSTR>,
78 default: impl Into<BOOL>,
79 default_period: *mut i64,
80 min_period: *mut i64,
81 ) -> Result<()> {
82 (Interface::vtable(self).GetProcessingPeriod)(
83 Interface::as_raw(self),
84 device_name.param().abi(),
85 default.into().0,
86 default_period,
87 min_period,
88 )
89 .ok()
90 }
91
92 pub unsafe fn SetProcessingPeriod(
93 &self,
94 device_name: impl Param<PCWSTR>,
95 period: *mut i64,
96 ) -> Result<()> {
97 (Interface::vtable(self).SetProcessingPeriod)(
98 Interface::as_raw(self),
99 device_name.param().abi(),
100 period,
101 )
102 .ok()
103 }
104
105 pub unsafe fn GetShareMode(
106 &self,
107 device_name: impl Param<PCWSTR>,
108 ) -> Result<DeviceSharingMode> {
109 let mut result__ = zeroed::<DeviceSharingMode>();
110 (Interface::vtable(self).GetShareMode)(
111 Interface::as_raw(self),
112 device_name.param().abi(),
113 &mut result__,
114 )
115 .map(|| result__)
116 }
117
118 pub unsafe fn SetShareMode(
119 &self,
120 device_name: impl Param<PCWSTR>,
121 mut mode: DeviceSharingMode,
122 ) -> Result<()> {
123 (Interface::vtable(self).SetShareMode)(
124 Interface::as_raw(self),
125 device_name.param().abi(),
126 &mut mode,
127 )
128 .ok()
129 }
130
131 pub unsafe fn GetPropertyValue(
132 &self,
133 device_name: impl Param<PCWSTR>,
134 bFxStore: impl Into<BOOL>,
135 key: *const PROPERTYKEY,
136 ) -> Result<PROPVARIANT> {
137 let mut result__ = zeroed::<PROPVARIANT>();
138 (Interface::vtable(self).GetPropertyValue)(
139 Interface::as_raw(self),
140 device_name.param().abi(),
141 bFxStore.into().0,
142 key,
143 &mut result__,
144 )
145 .map(|| result__)
146 }
147
148 pub unsafe fn SetPropertyValue(
149 &self,
150 device_name: impl Param<PCWSTR>,
151 bFxStore: impl Into<BOOL>,
152 key: *const PROPERTYKEY,
153 propvar: *mut PROPVARIANT,
154 ) -> Result<()> {
155 (Interface::vtable(self).SetPropertyValue)(
156 Interface::as_raw(self),
157 device_name.param().abi(),
158 bFxStore.into().0,
159 key,
160 propvar,
161 )
162 .ok()
163 }
164
165 pub unsafe fn SetDefaultEndpoint(
166 &self,
167 device_name: impl Param<PCWSTR>,
168 role: ERole,
169 ) -> Result<()> {
170 (Interface::vtable(self).SetDefaultEndpoint)(
171 Interface::as_raw(self),
172 device_name.param().abi(),
173 role,
174 )
175 .ok()
176 }
177
178 pub unsafe fn SetEndpointVisibility(
179 &self,
180 device_name: impl Param<PCWSTR>,
181 visible: impl Into<BOOL>,
182 ) -> Result<()> {
183 (Interface::vtable(self).SetEndpointVisibility)(
184 Interface::as_raw(self),
185 device_name.param().abi(),
186 visible.into().0,
187 )
188 .ok()
189 }
190}
191
192unsafe impl Interface for IPolicyConfig {
193 type Vtable = IPolicyConfig_Vtbl;
194 const IID: GUID = GUID::from_u128(0xf8679f50_850a_41cf_9c72_430f290290c8);
195}
196
197#[repr(C)]
198#[doc(hidden)]
199#[allow(non_camel_case_types)]
200pub struct IPolicyConfig_Vtbl {
201 pub base__: ::windows::core::IUnknown_Vtbl,
202 pub GetMixFormat:
203 unsafe extern "system" fn(this: *mut c_void, PCWSTR, *mut *mut WAVEFORMATEX) -> HRESULT,
204 pub GetDeviceFormat: unsafe extern "system" fn(
205 this: *mut c_void,
206 PCWSTR,
207 i32,
208 *mut *mut WAVEFORMATEX,
209 ) -> HRESULT,
210 pub ResetDeviceFormat: unsafe extern "system" fn(this: *mut c_void, PCWSTR) -> HRESULT,
211 pub SetDeviceFormat: unsafe extern "system" fn(
212 this: *mut c_void,
213 PCWSTR,
214 *mut WAVEFORMATEX,
215 *mut WAVEFORMATEX,
216 ) -> HRESULT,
217 pub GetProcessingPeriod:
218 unsafe extern "system" fn(this: *mut c_void, PCWSTR, i32, *mut i64, *mut i64) -> HRESULT,
219 pub SetProcessingPeriod:
220 unsafe extern "system" fn(this: *mut c_void, PCWSTR, *mut i64) -> HRESULT,
221 pub GetShareMode:
222 unsafe extern "system" fn(this: *mut c_void, PCWSTR, *mut DeviceSharingMode) -> HRESULT,
223 pub SetShareMode:
224 unsafe extern "system" fn(this: *mut c_void, PCWSTR, *mut DeviceSharingMode) -> HRESULT,
225 pub GetPropertyValue: unsafe extern "system" fn(
226 this: *mut c_void,
227 PCWSTR,
228 i32,
229 *const PROPERTYKEY,
230 *mut PROPVARIANT,
231 ) -> HRESULT,
232 pub SetPropertyValue: unsafe extern "system" fn(
233 this: *mut c_void,
234 PCWSTR,
235 i32,
236 *const PROPERTYKEY,
237 *mut PROPVARIANT,
238 ) -> HRESULT,
239 pub SetDefaultEndpoint: unsafe extern "system" fn(this: *mut c_void, PCWSTR, ERole) -> HRESULT,
240 pub SetEndpointVisibility: unsafe extern "system" fn(this: *mut c_void, PCWSTR, i32) -> HRESULT,
241}