diff options
author | Minijackson <minijackson@riseup.net> | 2021-05-20 20:18:33 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2021-05-20 20:18:33 +0200 |
commit | cc67030828bf31728ddc5c7064bf0a88e0bbb88a (patch) | |
tree | 2ce1ebd14fbae27bd9257db85f1b0afc3298924b /src | |
parent | 557074fb6dadf89ddbfce11d67fe8cac0f9eed80 (diff) | |
download | set_eq-cc67030828bf31728ddc5c7064bf0a88e0bbb88a.tar.gz set_eq-cc67030828bf31728ddc5c7064bf0a88e0bbb88a.zip |
update deps and nix, remove pa_eq as module is deprecated
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 20 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/equalizing_manager.rs | 291 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/mod.rs | 6 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/server_lookup.rs | 188 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/sink.rs | 1128 | ||||
-rw-r--r-- | src/pa_eq/mod.rs | 115 | ||||
-rw-r--r-- | src/utils.rs | 31 |
7 files changed, 0 insertions, 1779 deletions
diff --git a/src/main.rs b/src/main.rs index 062a77c..7a0d7c1 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -20,8 +20,6 @@ mod cli; | |||
20 | mod parsing; | 20 | mod parsing; |
21 | mod utils; | 21 | mod utils; |
22 | 22 | ||
23 | #[cfg(feature = "pa-eq")] | ||
24 | mod pa_eq; | ||
25 | #[cfg(feature = "pa-effects")] | 23 | #[cfg(feature = "pa-effects")] |
26 | mod pa_effects; | 24 | mod pa_effects; |
27 | 25 | ||
@@ -37,24 +35,6 @@ pub struct Filter { | |||
37 | coefficients: Vec<f64>, | 35 | coefficients: Vec<f64>, |
38 | } | 36 | } |
39 | 37 | ||
40 | impl Filter { | ||
41 | fn pad(self, filter_rate: u32) -> Self { | ||
42 | Filter { | ||
43 | preamp: self.preamp, | ||
44 | frequencies: vec![0u32] | ||
45 | .into_iter() | ||
46 | .chain(self.frequencies.into_iter()) | ||
47 | .chain(vec![filter_rate / 2u32]) | ||
48 | .collect(), | ||
49 | coefficients: vec![1f64] | ||
50 | .into_iter() | ||
51 | .chain(self.coefficients.into_iter()) | ||
52 | .chain(vec![1f64]) | ||
53 | .collect(), | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | fn main() { | 38 | fn main() { |
59 | match start() { | 39 | match start() { |
60 | Ok(()) => (), | 40 | Ok(()) => (), |
diff --git a/src/pa_eq/dbus_api/equalizing_manager.rs b/src/pa_eq/dbus_api/equalizing_manager.rs deleted file mode 100644 index a9eb7bc..0000000 --- a/src/pa_eq/dbus_api/equalizing_manager.rs +++ /dev/null | |||
@@ -1,291 +0,0 @@ | |||
1 | // This code was autogenerated with dbus-codegen-rust, see https://github.com/diwic/dbus-rs | ||
2 | |||
3 | #![allow(dead_code)] | ||
4 | use dbus as dbus; | ||
5 | use dbus::arg; | ||
6 | use dbus::tree; | ||
7 | |||
8 | pub trait OrgPulseAudioExtEqualizing1Manager { | ||
9 | type Err; | ||
10 | fn remove_profile(&self, name: &str) -> Result<(), Self::Err>; | ||
11 | fn get_interface_revision(&self) -> Result<u32, Self::Err>; | ||
12 | fn get_equalized_sinks(&self) -> Result<Vec<dbus::Path<'static>>, Self::Err>; | ||
13 | fn get_profiles(&self) -> Result<Vec<String>, Self::Err>; | ||
14 | } | ||
15 | |||
16 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioExtEqualizing1Manager for dbus::ConnPath<'a, C> { | ||
17 | type Err = dbus::Error; | ||
18 | |||
19 | fn remove_profile(&self, name: &str) -> Result<(), Self::Err> { | ||
20 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Manager".into(), &"RemoveProfile".into(), |msg| { | ||
21 | let mut i = arg::IterAppend::new(msg); | ||
22 | i.append(name); | ||
23 | })); | ||
24 | r#try!(m.as_result()); | ||
25 | Ok(()) | ||
26 | } | ||
27 | |||
28 | fn get_interface_revision(&self) -> Result<u32, Self::Err> { | ||
29 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Manager", "InterfaceRevision") | ||
30 | } | ||
31 | |||
32 | fn get_equalized_sinks(&self) -> Result<Vec<dbus::Path<'static>>, Self::Err> { | ||
33 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Manager", "EqualizedSinks") | ||
34 | } | ||
35 | |||
36 | fn get_profiles(&self) -> Result<Vec<String>, Self::Err> { | ||
37 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Manager", "Profiles") | ||
38 | } | ||
39 | } | ||
40 | |||
41 | pub fn org_pulse_audio_ext_equalizing1_manager_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
42 | where | ||
43 | D: tree::DataType, | ||
44 | D::Method: Default, | ||
45 | D::Property: Default, | ||
46 | T: OrgPulseAudioExtEqualizing1Manager<Err=tree::MethodErr>, | ||
47 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
48 | { | ||
49 | let i = factory.interface("org.PulseAudio.Ext.Equalizing1.Manager", data); | ||
50 | let f = ::std::sync::Arc::new(f); | ||
51 | let fclone = f.clone(); | ||
52 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
53 | let mut i = minfo.msg.iter_init(); | ||
54 | let name: &str = r#try!(i.read()); | ||
55 | let d = fclone(minfo); | ||
56 | r#try!(d.remove_profile(name)); | ||
57 | let rm = minfo.msg.method_return(); | ||
58 | Ok(vec!(rm)) | ||
59 | }; | ||
60 | let m = factory.method("RemoveProfile", Default::default(), h); | ||
61 | let m = m.in_arg(("name", "s")); | ||
62 | let i = i.add_m(m); | ||
63 | |||
64 | let p = factory.property::<u32, _>("InterfaceRevision", Default::default()); | ||
65 | let p = p.access(tree::Access::Read); | ||
66 | let fclone = f.clone(); | ||
67 | let p = p.on_get(move |a, pinfo| { | ||
68 | let minfo = pinfo.to_method_info(); | ||
69 | let d = fclone(&minfo); | ||
70 | a.append(r#try!(d.get_interface_revision())); | ||
71 | Ok(()) | ||
72 | }); | ||
73 | let i = i.add_p(p); | ||
74 | |||
75 | let p = factory.property::<Vec<dbus::Path<'_>>, _>("EqualizedSinks", Default::default()); | ||
76 | let p = p.access(tree::Access::Read); | ||
77 | let fclone = f.clone(); | ||
78 | let p = p.on_get(move |a, pinfo| { | ||
79 | let minfo = pinfo.to_method_info(); | ||
80 | let d = fclone(&minfo); | ||
81 | a.append(r#try!(d.get_equalized_sinks())); | ||
82 | Ok(()) | ||
83 | }); | ||
84 | let i = i.add_p(p); | ||
85 | |||
86 | let p = factory.property::<Vec<&str>, _>("Profiles", Default::default()); | ||
87 | let p = p.access(tree::Access::Read); | ||
88 | let fclone = f.clone(); | ||
89 | let p = p.on_get(move |a, pinfo| { | ||
90 | let minfo = pinfo.to_method_info(); | ||
91 | let d = fclone(&minfo); | ||
92 | a.append(r#try!(d.get_profiles())); | ||
93 | Ok(()) | ||
94 | }); | ||
95 | let i = i.add_p(p); | ||
96 | i | ||
97 | } | ||
98 | |||
99 | #[derive(Debug, Default)] | ||
100 | pub struct OrgPulseAudioExtEqualizing1ManagerSinkAdded { | ||
101 | pub sink: dbus::Path<'static>, | ||
102 | } | ||
103 | |||
104 | impl dbus::SignalArgs for OrgPulseAudioExtEqualizing1ManagerSinkAdded { | ||
105 | const NAME: &'static str = "SinkAdded"; | ||
106 | const INTERFACE: &'static str = "org.PulseAudio.Ext.Equalizing1.Manager"; | ||
107 | fn append(&self, i: &mut arg::IterAppend<'_>) { | ||
108 | (&self.sink as &dyn arg::RefArg).append(i); | ||
109 | } | ||
110 | fn get(&mut self, i: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
111 | self.sink = r#try!(i.read()); | ||
112 | Ok(()) | ||
113 | } | ||
114 | } | ||
115 | |||
116 | #[derive(Debug, Default)] | ||
117 | pub struct OrgPulseAudioExtEqualizing1ManagerSinkRemoved { | ||
118 | pub sink: dbus::Path<'static>, | ||
119 | } | ||
120 | |||
121 | impl dbus::SignalArgs for OrgPulseAudioExtEqualizing1ManagerSinkRemoved { | ||
122 | const NAME: &'static str = "SinkRemoved"; | ||
123 | const INTERFACE: &'static str = "org.PulseAudio.Ext.Equalizing1.Manager"; | ||
124 | fn append(&self, i: &mut arg::IterAppend<'_>) { | ||
125 | (&self.sink as &dyn arg::RefArg).append(i); | ||
126 | } | ||
127 | fn get(&mut self, i: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
128 | self.sink = r#try!(i.read()); | ||
129 | Ok(()) | ||
130 | } | ||
131 | } | ||
132 | |||
133 | #[derive(Debug, Default)] | ||
134 | pub struct OrgPulseAudioExtEqualizing1ManagerProfilesChanged { | ||
135 | } | ||
136 | |||
137 | impl dbus::SignalArgs for OrgPulseAudioExtEqualizing1ManagerProfilesChanged { | ||
138 | const NAME: &'static str = "ProfilesChanged"; | ||
139 | const INTERFACE: &'static str = "org.PulseAudio.Ext.Equalizing1.Manager"; | ||
140 | fn append(&self, _: &mut arg::IterAppend<'_>) { | ||
141 | } | ||
142 | fn get(&mut self, _: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
143 | Ok(()) | ||
144 | } | ||
145 | } | ||
146 | |||
147 | pub trait OrgFreedesktopDBusIntrospectable { | ||
148 | type Err; | ||
149 | fn introspect(&self) -> Result<String, Self::Err>; | ||
150 | } | ||
151 | |||
152 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusIntrospectable for dbus::ConnPath<'a, C> { | ||
153 | type Err = dbus::Error; | ||
154 | |||
155 | fn introspect(&self) -> Result<String, Self::Err> { | ||
156 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Introspectable".into(), &"Introspect".into(), |_| { | ||
157 | })); | ||
158 | r#try!(m.as_result()); | ||
159 | let mut i = m.iter_init(); | ||
160 | let data: String = r#try!(i.read()); | ||
161 | Ok(data) | ||
162 | } | ||
163 | } | ||
164 | |||
165 | pub fn org_freedesktop_dbus_introspectable_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
166 | where | ||
167 | D: tree::DataType, | ||
168 | D::Method: Default, | ||
169 | T: OrgFreedesktopDBusIntrospectable<Err=tree::MethodErr>, | ||
170 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
171 | { | ||
172 | let i = factory.interface("org.freedesktop.DBus.Introspectable", data); | ||
173 | let f = ::std::sync::Arc::new(f); | ||
174 | let fclone = f.clone(); | ||
175 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
176 | let d = fclone(minfo); | ||
177 | let data = r#try!(d.introspect()); | ||
178 | let rm = minfo.msg.method_return(); | ||
179 | let rm = rm.append1(data); | ||
180 | Ok(vec!(rm)) | ||
181 | }; | ||
182 | let m = factory.method("Introspect", Default::default(), h); | ||
183 | let m = m.out_arg(("data", "s")); | ||
184 | let i = i.add_m(m); | ||
185 | i | ||
186 | } | ||
187 | |||
188 | pub trait OrgFreedesktopDBusProperties { | ||
189 | type Err; | ||
190 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<dyn arg::RefArg>>, Self::Err>; | ||
191 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<dyn arg::RefArg>>) -> Result<(), Self::Err>; | ||
192 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>, Self::Err>; | ||
193 | } | ||
194 | |||
195 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusProperties for dbus::ConnPath<'a, C> { | ||
196 | type Err = dbus::Error; | ||
197 | |||
198 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<dyn arg::RefArg>>, Self::Err> { | ||
199 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Get".into(), |msg| { | ||
200 | let mut i = arg::IterAppend::new(msg); | ||
201 | i.append(interface_name); | ||
202 | i.append(property_name); | ||
203 | })); | ||
204 | r#try!(m.as_result()); | ||
205 | let mut i = m.iter_init(); | ||
206 | let value: arg::Variant<Box<dyn arg::RefArg>> = r#try!(i.read()); | ||
207 | Ok(value) | ||
208 | } | ||
209 | |||
210 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<dyn arg::RefArg>>) -> Result<(), Self::Err> { | ||
211 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Set".into(), |msg| { | ||
212 | let mut i = arg::IterAppend::new(msg); | ||
213 | i.append(interface_name); | ||
214 | i.append(property_name); | ||
215 | i.append(value); | ||
216 | })); | ||
217 | r#try!(m.as_result()); | ||
218 | Ok(()) | ||
219 | } | ||
220 | |||
221 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>, Self::Err> { | ||
222 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"GetAll".into(), |msg| { | ||
223 | let mut i = arg::IterAppend::new(msg); | ||
224 | i.append(interface_name); | ||
225 | })); | ||
226 | r#try!(m.as_result()); | ||
227 | let mut i = m.iter_init(); | ||
228 | let props: ::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>> = r#try!(i.read()); | ||
229 | Ok(props) | ||
230 | } | ||
231 | } | ||
232 | |||
233 | pub fn org_freedesktop_dbus_properties_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
234 | where | ||
235 | D: tree::DataType, | ||
236 | D::Method: Default, | ||
237 | T: OrgFreedesktopDBusProperties<Err=tree::MethodErr>, | ||
238 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
239 | { | ||
240 | let i = factory.interface("org.freedesktop.DBus.Properties", data); | ||
241 | let f = ::std::sync::Arc::new(f); | ||
242 | let fclone = f.clone(); | ||
243 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
244 | let mut i = minfo.msg.iter_init(); | ||
245 | let interface_name: &str = r#try!(i.read()); | ||
246 | let property_name: &str = r#try!(i.read()); | ||
247 | let d = fclone(minfo); | ||
248 | let value = r#try!(d.get(interface_name, property_name)); | ||
249 | let rm = minfo.msg.method_return(); | ||
250 | let rm = rm.append1(value); | ||
251 | Ok(vec!(rm)) | ||
252 | }; | ||
253 | let m = factory.method("Get", Default::default(), h); | ||
254 | let m = m.in_arg(("interface_name", "s")); | ||
255 | let m = m.in_arg(("property_name", "s")); | ||
256 | let m = m.out_arg(("value", "v")); | ||
257 | let i = i.add_m(m); | ||
258 | |||
259 | let fclone = f.clone(); | ||
260 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
261 | let mut i = minfo.msg.iter_init(); | ||
262 | let interface_name: &str = r#try!(i.read()); | ||
263 | let property_name: &str = r#try!(i.read()); | ||
264 | let value: arg::Variant<Box<dyn arg::RefArg>> = r#try!(i.read()); | ||
265 | let d = fclone(minfo); | ||
266 | r#try!(d.set(interface_name, property_name, value)); | ||
267 | let rm = minfo.msg.method_return(); | ||
268 | Ok(vec!(rm)) | ||
269 | }; | ||
270 | let m = factory.method("Set", Default::default(), h); | ||
271 | let m = m.in_arg(("interface_name", "s")); | ||
272 | let m = m.in_arg(("property_name", "s")); | ||
273 | let m = m.in_arg(("value", "v")); | ||
274 | let i = i.add_m(m); | ||
275 | |||
276 | let fclone = f.clone(); | ||
277 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
278 | let mut i = minfo.msg.iter_init(); | ||
279 | let interface_name: &str = r#try!(i.read()); | ||
280 | let d = fclone(minfo); | ||
281 | let props = r#try!(d.get_all(interface_name)); | ||
282 | let rm = minfo.msg.method_return(); | ||
283 | let rm = rm.append1(props); | ||
284 | Ok(vec!(rm)) | ||
285 | }; | ||
286 | let m = factory.method("GetAll", Default::default(), h); | ||
287 | let m = m.in_arg(("interface_name", "s")); | ||
288 | let m = m.out_arg(("props", "a{sv}")); | ||
289 | let i = i.add_m(m); | ||
290 | i | ||
291 | } | ||
diff --git a/src/pa_eq/dbus_api/mod.rs b/src/pa_eq/dbus_api/mod.rs deleted file mode 100644 index 79dd38a..0000000 --- a/src/pa_eq/dbus_api/mod.rs +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #[allow(clippy::all)] | ||
2 | pub mod equalizing_manager; | ||
3 | #[allow(clippy::all)] | ||
4 | pub mod server_lookup; | ||
5 | #[allow(clippy::all)] | ||
6 | pub mod sink; | ||
diff --git a/src/pa_eq/dbus_api/server_lookup.rs b/src/pa_eq/dbus_api/server_lookup.rs deleted file mode 100644 index c959df8..0000000 --- a/src/pa_eq/dbus_api/server_lookup.rs +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | // This code was autogenerated with dbus-codegen-rust, see https://github.com/diwic/dbus-rs | ||
2 | |||
3 | #![allow(dead_code)] | ||
4 | use dbus as dbus; | ||
5 | use dbus::arg; | ||
6 | use dbus::tree; | ||
7 | |||
8 | pub trait OrgPulseAudioServerLookup1 { | ||
9 | type Err; | ||
10 | fn get_address(&self) -> Result<String, Self::Err>; | ||
11 | } | ||
12 | |||
13 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioServerLookup1 for dbus::ConnPath<'a, C> { | ||
14 | type Err = dbus::Error; | ||
15 | |||
16 | fn get_address(&self) -> Result<String, Self::Err> { | ||
17 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.ServerLookup1", "Address") | ||
18 | } | ||
19 | } | ||
20 | |||
21 | pub fn org_pulse_audio_server_lookup1_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
22 | where | ||
23 | D: tree::DataType, | ||
24 | D::Method: Default, | ||
25 | D::Property: Default, | ||
26 | T: OrgPulseAudioServerLookup1<Err=tree::MethodErr>, | ||
27 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
28 | { | ||
29 | let i = factory.interface("org.PulseAudio.ServerLookup1", data); | ||
30 | let f = ::std::sync::Arc::new(f); | ||
31 | let p = factory.property::<&str, _>("Address", Default::default()); | ||
32 | let p = p.access(tree::Access::Read); | ||
33 | let fclone = f.clone(); | ||
34 | let p = p.on_get(move |a, pinfo| { | ||
35 | let minfo = pinfo.to_method_info(); | ||
36 | let d = fclone(&minfo); | ||
37 | a.append(r#try!(d.get_address())); | ||
38 | Ok(()) | ||
39 | }); | ||
40 | let i = i.add_p(p); | ||
41 | i | ||
42 | } | ||
43 | |||
44 | pub trait OrgFreedesktopDBusIntrospectable { | ||
45 | type Err; | ||
46 | fn introspect(&self) -> Result<String, Self::Err>; | ||
47 | } | ||
48 | |||
49 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusIntrospectable for dbus::ConnPath<'a, C> { | ||
50 | type Err = dbus::Error; | ||
51 | |||
52 | fn introspect(&self) -> Result<String, Self::Err> { | ||
53 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Introspectable".into(), &"Introspect".into(), |_| { | ||
54 | })); | ||
55 | r#try!(m.as_result()); | ||
56 | let mut i = m.iter_init(); | ||
57 | let data: String = r#try!(i.read()); | ||
58 | Ok(data) | ||
59 | } | ||
60 | } | ||
61 | |||
62 | pub fn org_freedesktop_dbus_introspectable_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
63 | where | ||
64 | D: tree::DataType, | ||
65 | D::Method: Default, | ||
66 | T: OrgFreedesktopDBusIntrospectable<Err=tree::MethodErr>, | ||
67 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
68 | { | ||
69 | let i = factory.interface("org.freedesktop.DBus.Introspectable", data); | ||
70 | let f = ::std::sync::Arc::new(f); | ||
71 | let fclone = f.clone(); | ||
72 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
73 | let d = fclone(minfo); | ||
74 | let data = r#try!(d.introspect()); | ||
75 | let rm = minfo.msg.method_return(); | ||
76 | let rm = rm.append1(data); | ||
77 | Ok(vec!(rm)) | ||
78 | }; | ||
79 | let m = factory.method("Introspect", Default::default(), h); | ||
80 | let m = m.out_arg(("data", "s")); | ||
81 | let i = i.add_m(m); | ||
82 | i | ||
83 | } | ||
84 | |||
85 | pub trait OrgFreedesktopDBusProperties { | ||
86 | type Err; | ||
87 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<dyn arg::RefArg>>, Self::Err>; | ||
88 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<dyn arg::RefArg>>) -> Result<(), Self::Err>; | ||
89 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>, Self::Err>; | ||
90 | } | ||
91 | |||
92 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusProperties for dbus::ConnPath<'a, C> { | ||
93 | type Err = dbus::Error; | ||
94 | |||
95 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<dyn arg::RefArg>>, Self::Err> { | ||
96 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Get".into(), |msg| { | ||
97 | let mut i = arg::IterAppend::new(msg); | ||
98 | i.append(interface_name); | ||
99 | i.append(property_name); | ||
100 | })); | ||
101 | r#try!(m.as_result()); | ||
102 | let mut i = m.iter_init(); | ||
103 | let value: arg::Variant<Box<dyn arg::RefArg>> = r#try!(i.read()); | ||
104 | Ok(value) | ||
105 | } | ||
106 | |||
107 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<dyn arg::RefArg>>) -> Result<(), Self::Err> { | ||
108 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Set".into(), |msg| { | ||
109 | let mut i = arg::IterAppend::new(msg); | ||
110 | i.append(interface_name); | ||
111 | i.append(property_name); | ||
112 | i.append(value); | ||
113 | })); | ||
114 | r#try!(m.as_result()); | ||
115 | Ok(()) | ||
116 | } | ||
117 | |||
118 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>, Self::Err> { | ||
119 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"GetAll".into(), |msg| { | ||
120 | let mut i = arg::IterAppend::new(msg); | ||
121 | i.append(interface_name); | ||
122 | })); | ||
123 | r#try!(m.as_result()); | ||
124 | let mut i = m.iter_init(); | ||
125 | let props: ::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>> = r#try!(i.read()); | ||
126 | Ok(props) | ||
127 | } | ||
128 | } | ||
129 | |||
130 | pub fn org_freedesktop_dbus_properties_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
131 | where | ||
132 | D: tree::DataType, | ||
133 | D::Method: Default, | ||
134 | T: OrgFreedesktopDBusProperties<Err=tree::MethodErr>, | ||
135 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
136 | { | ||
137 | let i = factory.interface("org.freedesktop.DBus.Properties", data); | ||
138 | let f = ::std::sync::Arc::new(f); | ||
139 | let fclone = f.clone(); | ||
140 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
141 | let mut i = minfo.msg.iter_init(); | ||
142 | let interface_name: &str = r#try!(i.read()); | ||
143 | let property_name: &str = r#try!(i.read()); | ||
144 | let d = fclone(minfo); | ||
145 | let value = r#try!(d.get(interface_name, property_name)); | ||
146 | let rm = minfo.msg.method_return(); | ||
147 | let rm = rm.append1(value); | ||
148 | Ok(vec!(rm)) | ||
149 | }; | ||
150 | let m = factory.method("Get", Default::default(), h); | ||
151 | let m = m.in_arg(("interface_name", "s")); | ||
152 | let m = m.in_arg(("property_name", "s")); | ||
153 | let m = m.out_arg(("value", "v")); | ||
154 | let i = i.add_m(m); | ||
155 | |||
156 | let fclone = f.clone(); | ||
157 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
158 | let mut i = minfo.msg.iter_init(); | ||
159 | let interface_name: &str = r#try!(i.read()); | ||
160 | let property_name: &str = r#try!(i.read()); | ||
161 | let value: arg::Variant<Box<dyn arg::RefArg>> = r#try!(i.read()); | ||
162 | let d = fclone(minfo); | ||
163 | r#try!(d.set(interface_name, property_name, value)); | ||
164 | let rm = minfo.msg.method_return(); | ||
165 | Ok(vec!(rm)) | ||
166 | }; | ||
167 | let m = factory.method("Set", Default::default(), h); | ||
168 | let m = m.in_arg(("interface_name", "s")); | ||
169 | let m = m.in_arg(("property_name", "s")); | ||
170 | let m = m.in_arg(("value", "v")); | ||
171 | let i = i.add_m(m); | ||
172 | |||
173 | let fclone = f.clone(); | ||
174 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
175 | let mut i = minfo.msg.iter_init(); | ||
176 | let interface_name: &str = r#try!(i.read()); | ||
177 | let d = fclone(minfo); | ||
178 | let props = r#try!(d.get_all(interface_name)); | ||
179 | let rm = minfo.msg.method_return(); | ||
180 | let rm = rm.append1(props); | ||
181 | Ok(vec!(rm)) | ||
182 | }; | ||
183 | let m = factory.method("GetAll", Default::default(), h); | ||
184 | let m = m.in_arg(("interface_name", "s")); | ||
185 | let m = m.out_arg(("props", "a{sv}")); | ||
186 | let i = i.add_m(m); | ||
187 | i | ||
188 | } | ||
diff --git a/src/pa_eq/dbus_api/sink.rs b/src/pa_eq/dbus_api/sink.rs deleted file mode 100644 index d902e64..0000000 --- a/src/pa_eq/dbus_api/sink.rs +++ /dev/null | |||
@@ -1,1128 +0,0 @@ | |||
1 | // This code was autogenerated with dbus-codegen-rust, see https://github.com/diwic/dbus-rs | ||
2 | |||
3 | #![allow(dead_code)] | ||
4 | use dbus as dbus; | ||
5 | use dbus::arg; | ||
6 | use dbus::tree; | ||
7 | |||
8 | pub trait OrgPulseAudioExtEqualizing1Equalizer { | ||
9 | type Err; | ||
10 | fn filter_at_points(&self, channel: u32, xs: Vec<u32>) -> Result<(Vec<f64>, f64), Self::Err>; | ||
11 | fn seed_filter(&self, channel: u32, xs: Vec<u32>, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err>; | ||
12 | fn save_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err>; | ||
13 | fn load_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err>; | ||
14 | fn set_filter(&self, channel: u32, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err>; | ||
15 | fn get_filter(&self, channel: u32) -> Result<(Vec<f64>, f64), Self::Err>; | ||
16 | fn save_state(&self) -> Result<(), Self::Err>; | ||
17 | fn base_profile(&self, channel: u32) -> Result<String, Self::Err>; | ||
18 | fn get_interface_revision(&self) -> Result<u32, Self::Err>; | ||
19 | fn get_sample_rate(&self) -> Result<u32, Self::Err>; | ||
20 | fn get_filter_sample_rate(&self) -> Result<u32, Self::Err>; | ||
21 | fn get_nfilter_coefficients(&self) -> Result<u32, Self::Err>; | ||
22 | fn get_nchannels(&self) -> Result<u32, Self::Err>; | ||
23 | } | ||
24 | |||
25 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioExtEqualizing1Equalizer for dbus::ConnPath<'a, C> { | ||
26 | type Err = dbus::Error; | ||
27 | |||
28 | fn filter_at_points(&self, channel: u32, xs: Vec<u32>) -> Result<(Vec<f64>, f64), Self::Err> { | ||
29 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"FilterAtPoints".into(), |msg| { | ||
30 | let mut i = arg::IterAppend::new(msg); | ||
31 | i.append(channel); | ||
32 | i.append(xs); | ||
33 | })); | ||
34 | r#try!(m.as_result()); | ||
35 | let mut i = m.iter_init(); | ||
36 | let ys: Vec<f64> = r#try!(i.read()); | ||
37 | let preamp: f64 = r#try!(i.read()); | ||
38 | Ok((ys, preamp)) | ||
39 | } | ||
40 | |||
41 | fn seed_filter(&self, channel: u32, xs: Vec<u32>, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err> { | ||
42 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SeedFilter".into(), |msg| { | ||
43 | let mut i = arg::IterAppend::new(msg); | ||
44 | i.append(channel); | ||
45 | i.append(xs); | ||
46 | i.append(ys); | ||
47 | i.append(preamp); | ||
48 | })); | ||
49 | r#try!(m.as_result()); | ||
50 | Ok(()) | ||
51 | } | ||
52 | |||
53 | fn save_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err> { | ||
54 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SaveProfile".into(), |msg| { | ||
55 | let mut i = arg::IterAppend::new(msg); | ||
56 | i.append(channel); | ||
57 | i.append(name); | ||
58 | })); | ||
59 | r#try!(m.as_result()); | ||
60 | Ok(()) | ||
61 | } | ||
62 | |||
63 | fn load_profile(&self, channel: u32, name: &str) -> Result<(), Self::Err> { | ||
64 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"LoadProfile".into(), |msg| { | ||
65 | let mut i = arg::IterAppend::new(msg); | ||
66 | i.append(channel); | ||
67 | i.append(name); | ||
68 | })); | ||
69 | r#try!(m.as_result()); | ||
70 | Ok(()) | ||
71 | } | ||
72 | |||
73 | fn set_filter(&self, channel: u32, ys: Vec<f64>, preamp: f64) -> Result<(), Self::Err> { | ||
74 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SetFilter".into(), |msg| { | ||
75 | let mut i = arg::IterAppend::new(msg); | ||
76 | i.append(channel); | ||
77 | i.append(ys); | ||
78 | i.append(preamp); | ||
79 | })); | ||
80 | r#try!(m.as_result()); | ||
81 | Ok(()) | ||
82 | } | ||
83 | |||
84 | fn get_filter(&self, channel: u32) -> Result<(Vec<f64>, f64), Self::Err> { | ||
85 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"GetFilter".into(), |msg| { | ||
86 | let mut i = arg::IterAppend::new(msg); | ||
87 | i.append(channel); | ||
88 | })); | ||
89 | r#try!(m.as_result()); | ||
90 | let mut i = m.iter_init(); | ||
91 | let ys: Vec<f64> = r#try!(i.read()); | ||
92 | let preamp: f64 = r#try!(i.read()); | ||
93 | Ok((ys, preamp)) | ||
94 | } | ||
95 | |||
96 | fn save_state(&self) -> Result<(), Self::Err> { | ||
97 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"SaveState".into(), |_| { | ||
98 | })); | ||
99 | r#try!(m.as_result()); | ||
100 | Ok(()) | ||
101 | } | ||
102 | |||
103 | fn base_profile(&self, channel: u32) -> Result<String, Self::Err> { | ||
104 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Ext.Equalizing1.Equalizer".into(), &"BaseProfile".into(), |msg| { | ||
105 | let mut i = arg::IterAppend::new(msg); | ||
106 | i.append(channel); | ||
107 | })); | ||
108 | r#try!(m.as_result()); | ||
109 | let mut i = m.iter_init(); | ||
110 | let name: String = r#try!(i.read()); | ||
111 | Ok(name) | ||
112 | } | ||
113 | |||
114 | fn get_interface_revision(&self) -> Result<u32, Self::Err> { | ||
115 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "InterfaceRevision") | ||
116 | } | ||
117 | |||
118 | fn get_sample_rate(&self) -> Result<u32, Self::Err> { | ||
119 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "SampleRate") | ||
120 | } | ||
121 | |||
122 | fn get_filter_sample_rate(&self) -> Result<u32, Self::Err> { | ||
123 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "FilterSampleRate") | ||
124 | } | ||
125 | |||
126 | fn get_nfilter_coefficients(&self) -> Result<u32, Self::Err> { | ||
127 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "NFilterCoefficients") | ||
128 | } | ||
129 | |||
130 | fn get_nchannels(&self) -> Result<u32, Self::Err> { | ||
131 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Ext.Equalizing1.Equalizer", "NChannels") | ||
132 | } | ||
133 | } | ||
134 | |||
135 | pub fn org_pulse_audio_ext_equalizing1_equalizer_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
136 | where | ||
137 | D: tree::DataType, | ||
138 | D::Method: Default, | ||
139 | D::Property: Default, | ||
140 | T: OrgPulseAudioExtEqualizing1Equalizer<Err=tree::MethodErr>, | ||
141 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
142 | { | ||
143 | let i = factory.interface("org.PulseAudio.Ext.Equalizing1.Equalizer", data); | ||
144 | let f = ::std::sync::Arc::new(f); | ||
145 | let fclone = f.clone(); | ||
146 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
147 | let mut i = minfo.msg.iter_init(); | ||
148 | let channel: u32 = r#try!(i.read()); | ||
149 | let xs: Vec<u32> = r#try!(i.read()); | ||
150 | let d = fclone(minfo); | ||
151 | let (ys, preamp) = r#try!(d.filter_at_points(channel, xs)); | ||
152 | let rm = minfo.msg.method_return(); | ||
153 | let rm = rm.append1(ys); | ||
154 | let rm = rm.append1(preamp); | ||
155 | Ok(vec!(rm)) | ||
156 | }; | ||
157 | let m = factory.method("FilterAtPoints", Default::default(), h); | ||
158 | let m = m.in_arg(("channel", "u")); | ||
159 | let m = m.in_arg(("xs", "au")); | ||
160 | let m = m.out_arg(("ys", "ad")); | ||
161 | let m = m.out_arg(("preamp", "d")); | ||
162 | let i = i.add_m(m); | ||
163 | |||
164 | let fclone = f.clone(); | ||
165 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
166 | let mut i = minfo.msg.iter_init(); | ||
167 | let channel: u32 = r#try!(i.read()); | ||
168 | let xs: Vec<u32> = r#try!(i.read()); | ||
169 | let ys: Vec<f64> = r#try!(i.read()); | ||
170 | let preamp: f64 = r#try!(i.read()); | ||
171 | let d = fclone(minfo); | ||
172 | r#try!(d.seed_filter(channel, xs, ys, preamp)); | ||
173 | let rm = minfo.msg.method_return(); | ||
174 | Ok(vec!(rm)) | ||
175 | }; | ||
176 | let m = factory.method("SeedFilter", Default::default(), h); | ||
177 | let m = m.in_arg(("channel", "u")); | ||
178 | let m = m.in_arg(("xs", "au")); | ||
179 | let m = m.in_arg(("ys", "ad")); | ||
180 | let m = m.in_arg(("preamp", "d")); | ||
181 | let i = i.add_m(m); | ||
182 | |||
183 | let fclone = f.clone(); | ||
184 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
185 | let mut i = minfo.msg.iter_init(); | ||
186 | let channel: u32 = r#try!(i.read()); | ||
187 | let name: &str = r#try!(i.read()); | ||
188 | let d = fclone(minfo); | ||
189 | r#try!(d.save_profile(channel, name)); | ||
190 | let rm = minfo.msg.method_return(); | ||
191 | Ok(vec!(rm)) | ||
192 | }; | ||
193 | let m = factory.method("SaveProfile", Default::default(), h); | ||
194 | let m = m.in_arg(("channel", "u")); | ||
195 | let m = m.in_arg(("name", "s")); | ||
196 | let i = i.add_m(m); | ||
197 | |||
198 | let fclone = f.clone(); | ||
199 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
200 | let mut i = minfo.msg.iter_init(); | ||
201 | let channel: u32 = r#try!(i.read()); | ||
202 | let name: &str = r#try!(i.read()); | ||
203 | let d = fclone(minfo); | ||
204 | r#try!(d.load_profile(channel, name)); | ||
205 | let rm = minfo.msg.method_return(); | ||
206 | Ok(vec!(rm)) | ||
207 | }; | ||
208 | let m = factory.method("LoadProfile", Default::default(), h); | ||
209 | let m = m.in_arg(("channel", "u")); | ||
210 | let m = m.in_arg(("name", "s")); | ||
211 | let i = i.add_m(m); | ||
212 | |||
213 | let fclone = f.clone(); | ||
214 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
215 | let mut i = minfo.msg.iter_init(); | ||
216 | let channel: u32 = r#try!(i.read()); | ||
217 | let ys: Vec<f64> = r#try!(i.read()); | ||
218 | let preamp: f64 = r#try!(i.read()); | ||
219 | let d = fclone(minfo); | ||
220 | r#try!(d.set_filter(channel, ys, preamp)); | ||
221 | let rm = minfo.msg.method_return(); | ||
222 | Ok(vec!(rm)) | ||
223 | }; | ||
224 | let m = factory.method("SetFilter", Default::default(), h); | ||
225 | let m = m.in_arg(("channel", "u")); | ||
226 | let m = m.in_arg(("ys", "ad")); | ||
227 | let m = m.in_arg(("preamp", "d")); | ||
228 | let i = i.add_m(m); | ||
229 | |||
230 | let fclone = f.clone(); | ||
231 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
232 | let mut i = minfo.msg.iter_init(); | ||
233 | let channel: u32 = r#try!(i.read()); | ||
234 | let d = fclone(minfo); | ||
235 | let (ys, preamp) = r#try!(d.get_filter(channel)); | ||
236 | let rm = minfo.msg.method_return(); | ||
237 | let rm = rm.append1(ys); | ||
238 | let rm = rm.append1(preamp); | ||
239 | Ok(vec!(rm)) | ||
240 | }; | ||
241 | let m = factory.method("GetFilter", Default::default(), h); | ||
242 | let m = m.in_arg(("channel", "u")); | ||
243 | let m = m.out_arg(("ys", "ad")); | ||
244 | let m = m.out_arg(("preamp", "d")); | ||
245 | let i = i.add_m(m); | ||
246 | |||
247 | let fclone = f.clone(); | ||
248 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
249 | let d = fclone(minfo); | ||
250 | r#try!(d.save_state()); | ||
251 | let rm = minfo.msg.method_return(); | ||
252 | Ok(vec!(rm)) | ||
253 | }; | ||
254 | let m = factory.method("SaveState", Default::default(), h); | ||
255 | let i = i.add_m(m); | ||
256 | |||
257 | let fclone = f.clone(); | ||
258 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
259 | let mut i = minfo.msg.iter_init(); | ||
260 | let channel: u32 = r#try!(i.read()); | ||
261 | let d = fclone(minfo); | ||
262 | let name = r#try!(d.base_profile(channel)); | ||
263 | let rm = minfo.msg.method_return(); | ||
264 | let rm = rm.append1(name); | ||
265 | Ok(vec!(rm)) | ||
266 | }; | ||
267 | let m = factory.method("BaseProfile", Default::default(), h); | ||
268 | let m = m.in_arg(("channel", "u")); | ||
269 | let m = m.out_arg(("name", "s")); | ||
270 | let i = i.add_m(m); | ||
271 | |||
272 | let p = factory.property::<u32, _>("InterfaceRevision", Default::default()); | ||
273 | let p = p.access(tree::Access::Read); | ||
274 | let fclone = f.clone(); | ||
275 | let p = p.on_get(move |a, pinfo| { | ||
276 | let minfo = pinfo.to_method_info(); | ||
277 | let d = fclone(&minfo); | ||
278 | a.append(r#try!(d.get_interface_revision())); | ||
279 | Ok(()) | ||
280 | }); | ||
281 | let i = i.add_p(p); | ||
282 | |||
283 | let p = factory.property::<u32, _>("SampleRate", Default::default()); | ||
284 | let p = p.access(tree::Access::Read); | ||
285 | let fclone = f.clone(); | ||
286 | let p = p.on_get(move |a, pinfo| { | ||
287 | let minfo = pinfo.to_method_info(); | ||
288 | let d = fclone(&minfo); | ||
289 | a.append(r#try!(d.get_sample_rate())); | ||
290 | Ok(()) | ||
291 | }); | ||
292 | let i = i.add_p(p); | ||
293 | |||
294 | let p = factory.property::<u32, _>("FilterSampleRate", Default::default()); | ||
295 | let p = p.access(tree::Access::Read); | ||
296 | let fclone = f.clone(); | ||
297 | let p = p.on_get(move |a, pinfo| { | ||
298 | let minfo = pinfo.to_method_info(); | ||
299 | let d = fclone(&minfo); | ||
300 | a.append(r#try!(d.get_filter_sample_rate())); | ||
301 | Ok(()) | ||
302 | }); | ||
303 | let i = i.add_p(p); | ||
304 | |||
305 | let p = factory.property::<u32, _>("NFilterCoefficients", Default::default()); | ||
306 | let p = p.access(tree::Access::Read); | ||
307 | let fclone = f.clone(); | ||
308 | let p = p.on_get(move |a, pinfo| { | ||
309 | let minfo = pinfo.to_method_info(); | ||
310 | let d = fclone(&minfo); | ||
311 | a.append(r#try!(d.get_nfilter_coefficients())); | ||
312 | Ok(()) | ||
313 | }); | ||
314 | let i = i.add_p(p); | ||
315 | |||
316 | let p = factory.property::<u32, _>("NChannels", Default::default()); | ||
317 | let p = p.access(tree::Access::Read); | ||
318 | let fclone = f.clone(); | ||
319 | let p = p.on_get(move |a, pinfo| { | ||
320 | let minfo = pinfo.to_method_info(); | ||
321 | let d = fclone(&minfo); | ||
322 | a.append(r#try!(d.get_nchannels())); | ||
323 | Ok(()) | ||
324 | }); | ||
325 | let i = i.add_p(p); | ||
326 | i | ||
327 | } | ||
328 | |||
329 | #[derive(Debug, Default)] | ||
330 | pub struct OrgPulseAudioExtEqualizing1EqualizerFilterChanged { | ||
331 | } | ||
332 | |||
333 | impl dbus::SignalArgs for OrgPulseAudioExtEqualizing1EqualizerFilterChanged { | ||
334 | const NAME: &'static str = "FilterChanged"; | ||
335 | const INTERFACE: &'static str = "org.PulseAudio.Ext.Equalizing1.Equalizer"; | ||
336 | fn append(&self, _: &mut arg::IterAppend<'_>) { | ||
337 | } | ||
338 | fn get(&mut self, _: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
339 | Ok(()) | ||
340 | } | ||
341 | } | ||
342 | |||
343 | #[derive(Debug, Default)] | ||
344 | pub struct OrgPulseAudioExtEqualizing1EqualizerSinkReconfigured { | ||
345 | } | ||
346 | |||
347 | impl dbus::SignalArgs for OrgPulseAudioExtEqualizing1EqualizerSinkReconfigured { | ||
348 | const NAME: &'static str = "SinkReconfigured"; | ||
349 | const INTERFACE: &'static str = "org.PulseAudio.Ext.Equalizing1.Equalizer"; | ||
350 | fn append(&self, _: &mut arg::IterAppend<'_>) { | ||
351 | } | ||
352 | fn get(&mut self, _: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
353 | Ok(()) | ||
354 | } | ||
355 | } | ||
356 | |||
357 | pub trait OrgPulseAudioCore1Device { | ||
358 | type Err; | ||
359 | fn suspend(&self, suspend: bool) -> Result<(), Self::Err>; | ||
360 | fn get_port_by_name(&self, name: &str) -> Result<dbus::Path<'static>, Self::Err>; | ||
361 | fn get_index(&self) -> Result<u32, Self::Err>; | ||
362 | fn get_name(&self) -> Result<String, Self::Err>; | ||
363 | fn get_driver(&self) -> Result<String, Self::Err>; | ||
364 | fn get_owner_module(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
365 | fn get_card(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
366 | fn get_sample_format(&self) -> Result<u32, Self::Err>; | ||
367 | fn get_sample_rate(&self) -> Result<u32, Self::Err>; | ||
368 | fn get_channels(&self) -> Result<Vec<u32>, Self::Err>; | ||
369 | fn get_volume(&self) -> Result<Vec<u32>, Self::Err>; | ||
370 | fn set_volume(&self, value: Vec<u32>) -> Result<(), Self::Err>; | ||
371 | fn get_has_flat_volume(&self) -> Result<bool, Self::Err>; | ||
372 | fn get_has_convertible_to_decibel_volume(&self) -> Result<bool, Self::Err>; | ||
373 | fn get_base_volume(&self) -> Result<u32, Self::Err>; | ||
374 | fn get_volume_steps(&self) -> Result<u32, Self::Err>; | ||
375 | fn get_mute(&self) -> Result<bool, Self::Err>; | ||
376 | fn set_mute(&self, value: bool) -> Result<(), Self::Err>; | ||
377 | fn get_has_hardware_volume(&self) -> Result<bool, Self::Err>; | ||
378 | fn get_has_hardware_mute(&self) -> Result<bool, Self::Err>; | ||
379 | fn get_configured_latency(&self) -> Result<u64, Self::Err>; | ||
380 | fn get_has_dynamic_latency(&self) -> Result<bool, Self::Err>; | ||
381 | fn get_latency(&self) -> Result<u64, Self::Err>; | ||
382 | fn get_is_hardware_device(&self) -> Result<bool, Self::Err>; | ||
383 | fn get_is_network_device(&self) -> Result<bool, Self::Err>; | ||
384 | fn get_state(&self) -> Result<u32, Self::Err>; | ||
385 | fn get_ports(&self) -> Result<Vec<dbus::Path<'static>>, Self::Err>; | ||
386 | fn get_active_port(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
387 | fn set_active_port(&self, value: dbus::Path<'static>) -> Result<(), Self::Err>; | ||
388 | fn get_property_list(&self) -> Result<::std::collections::HashMap<String, Vec<u8>>, Self::Err>; | ||
389 | } | ||
390 | |||
391 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioCore1Device for dbus::ConnPath<'a, C> { | ||
392 | type Err = dbus::Error; | ||
393 | |||
394 | fn suspend(&self, suspend: bool) -> Result<(), Self::Err> { | ||
395 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Core1.Device".into(), &"Suspend".into(), |msg| { | ||
396 | let mut i = arg::IterAppend::new(msg); | ||
397 | i.append(suspend); | ||
398 | })); | ||
399 | r#try!(m.as_result()); | ||
400 | Ok(()) | ||
401 | } | ||
402 | |||
403 | fn get_port_by_name(&self, name: &str) -> Result<dbus::Path<'static>, Self::Err> { | ||
404 | let mut m = r#try!(self.method_call_with_args(&"org.PulseAudio.Core1.Device".into(), &"GetPortByName".into(), |msg| { | ||
405 | let mut i = arg::IterAppend::new(msg); | ||
406 | i.append(name); | ||
407 | })); | ||
408 | r#try!(m.as_result()); | ||
409 | let mut i = m.iter_init(); | ||
410 | let port: dbus::Path<'static> = r#try!(i.read()); | ||
411 | Ok(port) | ||
412 | } | ||
413 | |||
414 | fn get_index(&self) -> Result<u32, Self::Err> { | ||
415 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Index") | ||
416 | } | ||
417 | |||
418 | fn get_name(&self) -> Result<String, Self::Err> { | ||
419 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Name") | ||
420 | } | ||
421 | |||
422 | fn get_driver(&self) -> Result<String, Self::Err> { | ||
423 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Driver") | ||
424 | } | ||
425 | |||
426 | fn get_owner_module(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
427 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "OwnerModule") | ||
428 | } | ||
429 | |||
430 | fn get_card(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
431 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Card") | ||
432 | } | ||
433 | |||
434 | fn get_sample_format(&self) -> Result<u32, Self::Err> { | ||
435 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "SampleFormat") | ||
436 | } | ||
437 | |||
438 | fn get_sample_rate(&self) -> Result<u32, Self::Err> { | ||
439 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "SampleRate") | ||
440 | } | ||
441 | |||
442 | fn get_channels(&self) -> Result<Vec<u32>, Self::Err> { | ||
443 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Channels") | ||
444 | } | ||
445 | |||
446 | fn get_volume(&self) -> Result<Vec<u32>, Self::Err> { | ||
447 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Volume") | ||
448 | } | ||
449 | |||
450 | fn get_has_flat_volume(&self) -> Result<bool, Self::Err> { | ||
451 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasFlatVolume") | ||
452 | } | ||
453 | |||
454 | fn get_has_convertible_to_decibel_volume(&self) -> Result<bool, Self::Err> { | ||
455 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasConvertibleToDecibelVolume") | ||
456 | } | ||
457 | |||
458 | fn get_base_volume(&self) -> Result<u32, Self::Err> { | ||
459 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "BaseVolume") | ||
460 | } | ||
461 | |||
462 | fn get_volume_steps(&self) -> Result<u32, Self::Err> { | ||
463 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "VolumeSteps") | ||
464 | } | ||
465 | |||
466 | fn get_mute(&self) -> Result<bool, Self::Err> { | ||
467 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Mute") | ||
468 | } | ||
469 | |||
470 | fn get_has_hardware_volume(&self) -> Result<bool, Self::Err> { | ||
471 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasHardwareVolume") | ||
472 | } | ||
473 | |||
474 | fn get_has_hardware_mute(&self) -> Result<bool, Self::Err> { | ||
475 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasHardwareMute") | ||
476 | } | ||
477 | |||
478 | fn get_configured_latency(&self) -> Result<u64, Self::Err> { | ||
479 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "ConfiguredLatency") | ||
480 | } | ||
481 | |||
482 | fn get_has_dynamic_latency(&self) -> Result<bool, Self::Err> { | ||
483 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "HasDynamicLatency") | ||
484 | } | ||
485 | |||
486 | fn get_latency(&self) -> Result<u64, Self::Err> { | ||
487 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Latency") | ||
488 | } | ||
489 | |||
490 | fn get_is_hardware_device(&self) -> Result<bool, Self::Err> { | ||
491 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "IsHardwareDevice") | ||
492 | } | ||
493 | |||
494 | fn get_is_network_device(&self) -> Result<bool, Self::Err> { | ||
495 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "IsNetworkDevice") | ||
496 | } | ||
497 | |||
498 | fn get_state(&self) -> Result<u32, Self::Err> { | ||
499 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "State") | ||
500 | } | ||
501 | |||
502 | fn get_ports(&self) -> Result<Vec<dbus::Path<'static>>, Self::Err> { | ||
503 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "Ports") | ||
504 | } | ||
505 | |||
506 | fn get_active_port(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
507 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "ActivePort") | ||
508 | } | ||
509 | |||
510 | fn get_property_list(&self) -> Result<::std::collections::HashMap<String, Vec<u8>>, Self::Err> { | ||
511 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Device", "PropertyList") | ||
512 | } | ||
513 | |||
514 | fn set_volume(&self, value: Vec<u32>) -> Result<(), Self::Err> { | ||
515 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.PulseAudio.Core1.Device", "Volume", value) | ||
516 | } | ||
517 | |||
518 | fn set_mute(&self, value: bool) -> Result<(), Self::Err> { | ||
519 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.PulseAudio.Core1.Device", "Mute", value) | ||
520 | } | ||
521 | |||
522 | fn set_active_port(&self, value: dbus::Path<'static>) -> Result<(), Self::Err> { | ||
523 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::set(&self, "org.PulseAudio.Core1.Device", "ActivePort", value) | ||
524 | } | ||
525 | } | ||
526 | |||
527 | pub fn org_pulse_audio_core1_device_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
528 | where | ||
529 | D: tree::DataType, | ||
530 | D::Method: Default, | ||
531 | D::Property: Default, | ||
532 | T: OrgPulseAudioCore1Device<Err=tree::MethodErr>, | ||
533 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
534 | { | ||
535 | let i = factory.interface("org.PulseAudio.Core1.Device", data); | ||
536 | let f = ::std::sync::Arc::new(f); | ||
537 | let fclone = f.clone(); | ||
538 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
539 | let mut i = minfo.msg.iter_init(); | ||
540 | let suspend: bool = r#try!(i.read()); | ||
541 | let d = fclone(minfo); | ||
542 | r#try!(d.suspend(suspend)); | ||
543 | let rm = minfo.msg.method_return(); | ||
544 | Ok(vec!(rm)) | ||
545 | }; | ||
546 | let m = factory.method("Suspend", Default::default(), h); | ||
547 | let m = m.in_arg(("suspend", "b")); | ||
548 | let i = i.add_m(m); | ||
549 | |||
550 | let fclone = f.clone(); | ||
551 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
552 | let mut i = minfo.msg.iter_init(); | ||
553 | let name: &str = r#try!(i.read()); | ||
554 | let d = fclone(minfo); | ||
555 | let port = r#try!(d.get_port_by_name(name)); | ||
556 | let rm = minfo.msg.method_return(); | ||
557 | let rm = rm.append1(port); | ||
558 | Ok(vec!(rm)) | ||
559 | }; | ||
560 | let m = factory.method("GetPortByName", Default::default(), h); | ||
561 | let m = m.in_arg(("name", "s")); | ||
562 | let m = m.out_arg(("port", "o")); | ||
563 | let i = i.add_m(m); | ||
564 | |||
565 | let p = factory.property::<u32, _>("Index", Default::default()); | ||
566 | let p = p.access(tree::Access::Read); | ||
567 | let fclone = f.clone(); | ||
568 | let p = p.on_get(move |a, pinfo| { | ||
569 | let minfo = pinfo.to_method_info(); | ||
570 | let d = fclone(&minfo); | ||
571 | a.append(r#try!(d.get_index())); | ||
572 | Ok(()) | ||
573 | }); | ||
574 | let i = i.add_p(p); | ||
575 | |||
576 | let p = factory.property::<&str, _>("Name", Default::default()); | ||
577 | let p = p.access(tree::Access::Read); | ||
578 | let fclone = f.clone(); | ||
579 | let p = p.on_get(move |a, pinfo| { | ||
580 | let minfo = pinfo.to_method_info(); | ||
581 | let d = fclone(&minfo); | ||
582 | a.append(r#try!(d.get_name())); | ||
583 | Ok(()) | ||
584 | }); | ||
585 | let i = i.add_p(p); | ||
586 | |||
587 | let p = factory.property::<&str, _>("Driver", Default::default()); | ||
588 | let p = p.access(tree::Access::Read); | ||
589 | let fclone = f.clone(); | ||
590 | let p = p.on_get(move |a, pinfo| { | ||
591 | let minfo = pinfo.to_method_info(); | ||
592 | let d = fclone(&minfo); | ||
593 | a.append(r#try!(d.get_driver())); | ||
594 | Ok(()) | ||
595 | }); | ||
596 | let i = i.add_p(p); | ||
597 | |||
598 | let p = factory.property::<dbus::Path<'_>, _>("OwnerModule", Default::default()); | ||
599 | let p = p.access(tree::Access::Read); | ||
600 | let fclone = f.clone(); | ||
601 | let p = p.on_get(move |a, pinfo| { | ||
602 | let minfo = pinfo.to_method_info(); | ||
603 | let d = fclone(&minfo); | ||
604 | a.append(r#try!(d.get_owner_module())); | ||
605 | Ok(()) | ||
606 | }); | ||
607 | let i = i.add_p(p); | ||
608 | |||
609 | let p = factory.property::<dbus::Path<'_>, _>("Card", Default::default()); | ||
610 | let p = p.access(tree::Access::Read); | ||
611 | let fclone = f.clone(); | ||
612 | let p = p.on_get(move |a, pinfo| { | ||
613 | let minfo = pinfo.to_method_info(); | ||
614 | let d = fclone(&minfo); | ||
615 | a.append(r#try!(d.get_card())); | ||
616 | Ok(()) | ||
617 | }); | ||
618 | let i = i.add_p(p); | ||
619 | |||
620 | let p = factory.property::<u32, _>("SampleFormat", Default::default()); | ||
621 | let p = p.access(tree::Access::Read); | ||
622 | let fclone = f.clone(); | ||
623 | let p = p.on_get(move |a, pinfo| { | ||
624 | let minfo = pinfo.to_method_info(); | ||
625 | let d = fclone(&minfo); | ||
626 | a.append(r#try!(d.get_sample_format())); | ||
627 | Ok(()) | ||
628 | }); | ||
629 | let i = i.add_p(p); | ||
630 | |||
631 | let p = factory.property::<u32, _>("SampleRate", Default::default()); | ||
632 | let p = p.access(tree::Access::Read); | ||
633 | let fclone = f.clone(); | ||
634 | let p = p.on_get(move |a, pinfo| { | ||
635 | let minfo = pinfo.to_method_info(); | ||
636 | let d = fclone(&minfo); | ||
637 | a.append(r#try!(d.get_sample_rate())); | ||
638 | Ok(()) | ||
639 | }); | ||
640 | let i = i.add_p(p); | ||
641 | |||
642 | let p = factory.property::<Vec<u32>, _>("Channels", Default::default()); | ||
643 | let p = p.access(tree::Access::Read); | ||
644 | let fclone = f.clone(); | ||
645 | let p = p.on_get(move |a, pinfo| { | ||
646 | let minfo = pinfo.to_method_info(); | ||
647 | let d = fclone(&minfo); | ||
648 | a.append(r#try!(d.get_channels())); | ||
649 | Ok(()) | ||
650 | }); | ||
651 | let i = i.add_p(p); | ||
652 | |||
653 | let p = factory.property::<Vec<u32>, _>("Volume", Default::default()); | ||
654 | let p = p.access(tree::Access::ReadWrite); | ||
655 | let fclone = f.clone(); | ||
656 | let p = p.on_get(move |a, pinfo| { | ||
657 | let minfo = pinfo.to_method_info(); | ||
658 | let d = fclone(&minfo); | ||
659 | a.append(r#try!(d.get_volume())); | ||
660 | Ok(()) | ||
661 | }); | ||
662 | let fclone = f.clone(); | ||
663 | let p = p.on_set(move |iter, pinfo| { | ||
664 | let minfo = pinfo.to_method_info(); | ||
665 | let d = fclone(&minfo); | ||
666 | r#try!(d.set_volume(r#try!(iter.read()))); | ||
667 | Ok(()) | ||
668 | }); | ||
669 | let i = i.add_p(p); | ||
670 | |||
671 | let p = factory.property::<bool, _>("HasFlatVolume", Default::default()); | ||
672 | let p = p.access(tree::Access::Read); | ||
673 | let fclone = f.clone(); | ||
674 | let p = p.on_get(move |a, pinfo| { | ||
675 | let minfo = pinfo.to_method_info(); | ||
676 | let d = fclone(&minfo); | ||
677 | a.append(r#try!(d.get_has_flat_volume())); | ||
678 | Ok(()) | ||
679 | }); | ||
680 | let i = i.add_p(p); | ||
681 | |||
682 | let p = factory.property::<bool, _>("HasConvertibleToDecibelVolume", Default::default()); | ||
683 | let p = p.access(tree::Access::Read); | ||
684 | let fclone = f.clone(); | ||
685 | let p = p.on_get(move |a, pinfo| { | ||
686 | let minfo = pinfo.to_method_info(); | ||
687 | let d = fclone(&minfo); | ||
688 | a.append(r#try!(d.get_has_convertible_to_decibel_volume())); | ||
689 | Ok(()) | ||
690 | }); | ||
691 | let i = i.add_p(p); | ||
692 | |||
693 | let p = factory.property::<u32, _>("BaseVolume", Default::default()); | ||
694 | let p = p.access(tree::Access::Read); | ||
695 | let fclone = f.clone(); | ||
696 | let p = p.on_get(move |a, pinfo| { | ||
697 | let minfo = pinfo.to_method_info(); | ||
698 | let d = fclone(&minfo); | ||
699 | a.append(r#try!(d.get_base_volume())); | ||
700 | Ok(()) | ||
701 | }); | ||
702 | let i = i.add_p(p); | ||
703 | |||
704 | let p = factory.property::<u32, _>("VolumeSteps", Default::default()); | ||
705 | let p = p.access(tree::Access::Read); | ||
706 | let fclone = f.clone(); | ||
707 | let p = p.on_get(move |a, pinfo| { | ||
708 | let minfo = pinfo.to_method_info(); | ||
709 | let d = fclone(&minfo); | ||
710 | a.append(r#try!(d.get_volume_steps())); | ||
711 | Ok(()) | ||
712 | }); | ||
713 | let i = i.add_p(p); | ||
714 | |||
715 | let p = factory.property::<bool, _>("Mute", Default::default()); | ||
716 | let p = p.access(tree::Access::ReadWrite); | ||
717 | let fclone = f.clone(); | ||
718 | let p = p.on_get(move |a, pinfo| { | ||
719 | let minfo = pinfo.to_method_info(); | ||
720 | let d = fclone(&minfo); | ||
721 | a.append(r#try!(d.get_mute())); | ||
722 | Ok(()) | ||
723 | }); | ||
724 | let fclone = f.clone(); | ||
725 | let p = p.on_set(move |iter, pinfo| { | ||
726 | let minfo = pinfo.to_method_info(); | ||
727 | let d = fclone(&minfo); | ||
728 | r#try!(d.set_mute(r#try!(iter.read()))); | ||
729 | Ok(()) | ||
730 | }); | ||
731 | let i = i.add_p(p); | ||
732 | |||
733 | let p = factory.property::<bool, _>("HasHardwareVolume", Default::default()); | ||
734 | let p = p.access(tree::Access::Read); | ||
735 | let fclone = f.clone(); | ||
736 | let p = p.on_get(move |a, pinfo| { | ||
737 | let minfo = pinfo.to_method_info(); | ||
738 | let d = fclone(&minfo); | ||
739 | a.append(r#try!(d.get_has_hardware_volume())); | ||
740 | Ok(()) | ||
741 | }); | ||
742 | let i = i.add_p(p); | ||
743 | |||
744 | let p = factory.property::<bool, _>("HasHardwareMute", Default::default()); | ||
745 | let p = p.access(tree::Access::Read); | ||
746 | let fclone = f.clone(); | ||
747 | let p = p.on_get(move |a, pinfo| { | ||
748 | let minfo = pinfo.to_method_info(); | ||
749 | let d = fclone(&minfo); | ||
750 | a.append(r#try!(d.get_has_hardware_mute())); | ||
751 | Ok(()) | ||
752 | }); | ||
753 | let i = i.add_p(p); | ||
754 | |||
755 | let p = factory.property::<u64, _>("ConfiguredLatency", Default::default()); | ||
756 | let p = p.access(tree::Access::Read); | ||
757 | let fclone = f.clone(); | ||
758 | let p = p.on_get(move |a, pinfo| { | ||
759 | let minfo = pinfo.to_method_info(); | ||
760 | let d = fclone(&minfo); | ||
761 | a.append(r#try!(d.get_configured_latency())); | ||
762 | Ok(()) | ||
763 | }); | ||
764 | let i = i.add_p(p); | ||
765 | |||
766 | let p = factory.property::<bool, _>("HasDynamicLatency", Default::default()); | ||
767 | let p = p.access(tree::Access::Read); | ||
768 | let fclone = f.clone(); | ||
769 | let p = p.on_get(move |a, pinfo| { | ||
770 | let minfo = pinfo.to_method_info(); | ||
771 | let d = fclone(&minfo); | ||
772 | a.append(r#try!(d.get_has_dynamic_latency())); | ||
773 | Ok(()) | ||
774 | }); | ||
775 | let i = i.add_p(p); | ||
776 | |||
777 | let p = factory.property::<u64, _>("Latency", Default::default()); | ||
778 | let p = p.access(tree::Access::Read); | ||
779 | let fclone = f.clone(); | ||
780 | let p = p.on_get(move |a, pinfo| { | ||
781 | let minfo = pinfo.to_method_info(); | ||
782 | let d = fclone(&minfo); | ||
783 | a.append(r#try!(d.get_latency())); | ||
784 | Ok(()) | ||
785 | }); | ||
786 | let i = i.add_p(p); | ||
787 | |||
788 | let p = factory.property::<bool, _>("IsHardwareDevice", Default::default()); | ||
789 | let p = p.access(tree::Access::Read); | ||
790 | let fclone = f.clone(); | ||
791 | let p = p.on_get(move |a, pinfo| { | ||
792 | let minfo = pinfo.to_method_info(); | ||
793 | let d = fclone(&minfo); | ||
794 | a.append(r#try!(d.get_is_hardware_device())); | ||
795 | Ok(()) | ||
796 | }); | ||
797 | let i = i.add_p(p); | ||
798 | |||
799 | let p = factory.property::<bool, _>("IsNetworkDevice", Default::default()); | ||
800 | let p = p.access(tree::Access::Read); | ||
801 | let fclone = f.clone(); | ||
802 | let p = p.on_get(move |a, pinfo| { | ||
803 | let minfo = pinfo.to_method_info(); | ||
804 | let d = fclone(&minfo); | ||
805 | a.append(r#try!(d.get_is_network_device())); | ||
806 | Ok(()) | ||
807 | }); | ||
808 | let i = i.add_p(p); | ||
809 | |||
810 | let p = factory.property::<u32, _>("State", Default::default()); | ||
811 | let p = p.access(tree::Access::Read); | ||
812 | let fclone = f.clone(); | ||
813 | let p = p.on_get(move |a, pinfo| { | ||
814 | let minfo = pinfo.to_method_info(); | ||
815 | let d = fclone(&minfo); | ||
816 | a.append(r#try!(d.get_state())); | ||
817 | Ok(()) | ||
818 | }); | ||
819 | let i = i.add_p(p); | ||
820 | |||
821 | let p = factory.property::<Vec<dbus::Path<'_>>, _>("Ports", Default::default()); | ||
822 | let p = p.access(tree::Access::Read); | ||
823 | let fclone = f.clone(); | ||
824 | let p = p.on_get(move |a, pinfo| { | ||
825 | let minfo = pinfo.to_method_info(); | ||
826 | let d = fclone(&minfo); | ||
827 | a.append(r#try!(d.get_ports())); | ||
828 | Ok(()) | ||
829 | }); | ||
830 | let i = i.add_p(p); | ||
831 | |||
832 | let p = factory.property::<dbus::Path<'_>, _>("ActivePort", Default::default()); | ||
833 | let p = p.access(tree::Access::ReadWrite); | ||
834 | let fclone = f.clone(); | ||
835 | let p = p.on_get(move |a, pinfo| { | ||
836 | let minfo = pinfo.to_method_info(); | ||
837 | let d = fclone(&minfo); | ||
838 | a.append(r#try!(d.get_active_port())); | ||
839 | Ok(()) | ||
840 | }); | ||
841 | let fclone = f.clone(); | ||
842 | let p = p.on_set(move |iter, pinfo| { | ||
843 | let minfo = pinfo.to_method_info(); | ||
844 | let d = fclone(&minfo); | ||
845 | r#try!(d.set_active_port(r#try!(iter.read()))); | ||
846 | Ok(()) | ||
847 | }); | ||
848 | let i = i.add_p(p); | ||
849 | |||
850 | let p = factory.property::<::std::collections::HashMap<&str, Vec<u8>>, _>("PropertyList", Default::default()); | ||
851 | let p = p.access(tree::Access::Read); | ||
852 | let fclone = f.clone(); | ||
853 | let p = p.on_get(move |a, pinfo| { | ||
854 | let minfo = pinfo.to_method_info(); | ||
855 | let d = fclone(&minfo); | ||
856 | a.append(r#try!(d.get_property_list())); | ||
857 | Ok(()) | ||
858 | }); | ||
859 | let i = i.add_p(p); | ||
860 | i | ||
861 | } | ||
862 | |||
863 | #[derive(Debug, Default)] | ||
864 | pub struct OrgPulseAudioCore1DeviceVolumeUpdated { | ||
865 | pub volume: Vec<u32>, | ||
866 | } | ||
867 | |||
868 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceVolumeUpdated { | ||
869 | const NAME: &'static str = "VolumeUpdated"; | ||
870 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
871 | fn append(&self, i: &mut arg::IterAppend<'_>) { | ||
872 | (&self.volume as &dyn arg::RefArg).append(i); | ||
873 | } | ||
874 | fn get(&mut self, i: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
875 | self.volume = r#try!(i.read()); | ||
876 | Ok(()) | ||
877 | } | ||
878 | } | ||
879 | |||
880 | #[derive(Debug, Default)] | ||
881 | pub struct OrgPulseAudioCore1DeviceMuteUpdated { | ||
882 | pub muted: bool, | ||
883 | } | ||
884 | |||
885 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceMuteUpdated { | ||
886 | const NAME: &'static str = "MuteUpdated"; | ||
887 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
888 | fn append(&self, i: &mut arg::IterAppend<'_>) { | ||
889 | (&self.muted as &dyn arg::RefArg).append(i); | ||
890 | } | ||
891 | fn get(&mut self, i: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
892 | self.muted = r#try!(i.read()); | ||
893 | Ok(()) | ||
894 | } | ||
895 | } | ||
896 | |||
897 | #[derive(Debug, Default)] | ||
898 | pub struct OrgPulseAudioCore1DeviceStateUpdated { | ||
899 | pub state: u32, | ||
900 | } | ||
901 | |||
902 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceStateUpdated { | ||
903 | const NAME: &'static str = "StateUpdated"; | ||
904 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
905 | fn append(&self, i: &mut arg::IterAppend<'_>) { | ||
906 | (&self.state as &dyn arg::RefArg).append(i); | ||
907 | } | ||
908 | fn get(&mut self, i: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
909 | self.state = r#try!(i.read()); | ||
910 | Ok(()) | ||
911 | } | ||
912 | } | ||
913 | |||
914 | #[derive(Debug, Default)] | ||
915 | pub struct OrgPulseAudioCore1DeviceActivePortUpdated { | ||
916 | pub port: dbus::Path<'static>, | ||
917 | } | ||
918 | |||
919 | impl dbus::SignalArgs for OrgPulseAudioCore1DeviceActivePortUpdated { | ||
920 | const NAME: &'static str = "ActivePortUpdated"; | ||
921 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
922 | fn append(&self, i: &mut arg::IterAppend<'_>) { | ||
923 | (&self.port as &dyn arg::RefArg).append(i); | ||
924 | } | ||
925 | fn get(&mut self, i: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
926 | self.port = r#try!(i.read()); | ||
927 | Ok(()) | ||
928 | } | ||
929 | } | ||
930 | |||
931 | #[derive(Debug, Default)] | ||
932 | pub struct OrgPulseAudioCore1DevicePropertyListUpdated { | ||
933 | pub property_list: ::std::collections::HashMap<String, Vec<u8>>, | ||
934 | } | ||
935 | |||
936 | impl dbus::SignalArgs for OrgPulseAudioCore1DevicePropertyListUpdated { | ||
937 | const NAME: &'static str = "PropertyListUpdated"; | ||
938 | const INTERFACE: &'static str = "org.PulseAudio.Core1.Device"; | ||
939 | fn append(&self, i: &mut arg::IterAppend<'_>) { | ||
940 | (&self.property_list as &dyn arg::RefArg).append(i); | ||
941 | } | ||
942 | fn get(&mut self, i: &mut arg::Iter<'_>) -> Result<(), arg::TypeMismatchError> { | ||
943 | self.property_list = r#try!(i.read()); | ||
944 | Ok(()) | ||
945 | } | ||
946 | } | ||
947 | |||
948 | pub trait OrgPulseAudioCore1Sink { | ||
949 | type Err; | ||
950 | fn get_monitor_source(&self) -> Result<dbus::Path<'static>, Self::Err>; | ||
951 | } | ||
952 | |||
953 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgPulseAudioCore1Sink for dbus::ConnPath<'a, C> { | ||
954 | type Err = dbus::Error; | ||
955 | |||
956 | fn get_monitor_source(&self) -> Result<dbus::Path<'static>, Self::Err> { | ||
957 | <Self as dbus::stdintf::org_freedesktop_dbus::Properties>::get(&self, "org.PulseAudio.Core1.Sink", "MonitorSource") | ||
958 | } | ||
959 | } | ||
960 | |||
961 | pub fn org_pulse_audio_core1_sink_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
962 | where | ||
963 | D: tree::DataType, | ||
964 | D::Method: Default, | ||
965 | D::Property: Default, | ||
966 | T: OrgPulseAudioCore1Sink<Err=tree::MethodErr>, | ||
967 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
968 | { | ||
969 | let i = factory.interface("org.PulseAudio.Core1.Sink", data); | ||
970 | let f = ::std::sync::Arc::new(f); | ||
971 | let p = factory.property::<dbus::Path<'_>, _>("MonitorSource", Default::default()); | ||
972 | let p = p.access(tree::Access::Read); | ||
973 | let fclone = f.clone(); | ||
974 | let p = p.on_get(move |a, pinfo| { | ||
975 | let minfo = pinfo.to_method_info(); | ||
976 | let d = fclone(&minfo); | ||
977 | a.append(r#try!(d.get_monitor_source())); | ||
978 | Ok(()) | ||
979 | }); | ||
980 | let i = i.add_p(p); | ||
981 | i | ||
982 | } | ||
983 | |||
984 | pub trait OrgFreedesktopDBusIntrospectable { | ||
985 | type Err; | ||
986 | fn introspect(&self) -> Result<String, Self::Err>; | ||
987 | } | ||
988 | |||
989 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusIntrospectable for dbus::ConnPath<'a, C> { | ||
990 | type Err = dbus::Error; | ||
991 | |||
992 | fn introspect(&self) -> Result<String, Self::Err> { | ||
993 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Introspectable".into(), &"Introspect".into(), |_| { | ||
994 | })); | ||
995 | r#try!(m.as_result()); | ||
996 | let mut i = m.iter_init(); | ||
997 | let data: String = r#try!(i.read()); | ||
998 | Ok(data) | ||
999 | } | ||
1000 | } | ||
1001 | |||
1002 | pub fn org_freedesktop_dbus_introspectable_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
1003 | where | ||
1004 | D: tree::DataType, | ||
1005 | D::Method: Default, | ||
1006 | T: OrgFreedesktopDBusIntrospectable<Err=tree::MethodErr>, | ||
1007 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
1008 | { | ||
1009 | let i = factory.interface("org.freedesktop.DBus.Introspectable", data); | ||
1010 | let f = ::std::sync::Arc::new(f); | ||
1011 | let fclone = f.clone(); | ||
1012 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
1013 | let d = fclone(minfo); | ||
1014 | let data = r#try!(d.introspect()); | ||
1015 | let rm = minfo.msg.method_return(); | ||
1016 | let rm = rm.append1(data); | ||
1017 | Ok(vec!(rm)) | ||
1018 | }; | ||
1019 | let m = factory.method("Introspect", Default::default(), h); | ||
1020 | let m = m.out_arg(("data", "s")); | ||
1021 | let i = i.add_m(m); | ||
1022 | i | ||
1023 | } | ||
1024 | |||
1025 | pub trait OrgFreedesktopDBusProperties { | ||
1026 | type Err; | ||
1027 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<dyn arg::RefArg>>, Self::Err>; | ||
1028 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<dyn arg::RefArg>>) -> Result<(), Self::Err>; | ||
1029 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>, Self::Err>; | ||
1030 | } | ||
1031 | |||
1032 | impl<'a, C: ::std::ops::Deref<Target=dbus::Connection>> OrgFreedesktopDBusProperties for dbus::ConnPath<'a, C> { | ||
1033 | type Err = dbus::Error; | ||
1034 | |||
1035 | fn get(&self, interface_name: &str, property_name: &str) -> Result<arg::Variant<Box<dyn arg::RefArg>>, Self::Err> { | ||
1036 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Get".into(), |msg| { | ||
1037 | let mut i = arg::IterAppend::new(msg); | ||
1038 | i.append(interface_name); | ||
1039 | i.append(property_name); | ||
1040 | })); | ||
1041 | r#try!(m.as_result()); | ||
1042 | let mut i = m.iter_init(); | ||
1043 | let value: arg::Variant<Box<dyn arg::RefArg>> = r#try!(i.read()); | ||
1044 | Ok(value) | ||
1045 | } | ||
1046 | |||
1047 | fn set(&self, interface_name: &str, property_name: &str, value: arg::Variant<Box<dyn arg::RefArg>>) -> Result<(), Self::Err> { | ||
1048 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"Set".into(), |msg| { | ||
1049 | let mut i = arg::IterAppend::new(msg); | ||
1050 | i.append(interface_name); | ||
1051 | i.append(property_name); | ||
1052 | i.append(value); | ||
1053 | })); | ||
1054 | r#try!(m.as_result()); | ||
1055 | Ok(()) | ||
1056 | } | ||
1057 | |||
1058 | fn get_all(&self, interface_name: &str) -> Result<::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>, Self::Err> { | ||
1059 | let mut m = r#try!(self.method_call_with_args(&"org.freedesktop.DBus.Properties".into(), &"GetAll".into(), |msg| { | ||
1060 | let mut i = arg::IterAppend::new(msg); | ||
1061 | i.append(interface_name); | ||
1062 | })); | ||
1063 | r#try!(m.as_result()); | ||
1064 | let mut i = m.iter_init(); | ||
1065 | let props: ::std::collections::HashMap<String, arg::Variant<Box<dyn arg::RefArg>>> = r#try!(i.read()); | ||
1066 | Ok(props) | ||
1067 | } | ||
1068 | } | ||
1069 | |||
1070 | pub fn org_freedesktop_dbus_properties_server<F, T, D>(factory: &tree::Factory<tree::MTFn<D>, D>, data: D::Interface, f: F) -> tree::Interface<tree::MTFn<D>, D> | ||
1071 | where | ||
1072 | D: tree::DataType, | ||
1073 | D::Method: Default, | ||
1074 | T: OrgFreedesktopDBusProperties<Err=tree::MethodErr>, | ||
1075 | F: 'static + for <'z> Fn(& 'z tree::MethodInfo<'_, tree::MTFn<D>, D>) -> & 'z T, | ||
1076 | { | ||
1077 | let i = factory.interface("org.freedesktop.DBus.Properties", data); | ||
1078 | let f = ::std::sync::Arc::new(f); | ||
1079 | let fclone = f.clone(); | ||
1080 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
1081 | let mut i = minfo.msg.iter_init(); | ||
1082 | let interface_name: &str = r#try!(i.read()); | ||
1083 | let property_name: &str = r#try!(i.read()); | ||
1084 | let d = fclone(minfo); | ||
1085 | let value = r#try!(d.get(interface_name, property_name)); | ||
1086 | let rm = minfo.msg.method_return(); | ||
1087 | let rm = rm.append1(value); | ||
1088 | Ok(vec!(rm)) | ||
1089 | }; | ||
1090 | let m = factory.method("Get", Default::default(), h); | ||
1091 | let m = m.in_arg(("interface_name", "s")); | ||
1092 | let m = m.in_arg(("property_name", "s")); | ||
1093 | let m = m.out_arg(("value", "v")); | ||
1094 | let i = i.add_m(m); | ||
1095 | |||
1096 | let fclone = f.clone(); | ||
1097 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
1098 | let mut i = minfo.msg.iter_init(); | ||
1099 | let interface_name: &str = r#try!(i.read()); | ||
1100 | let property_name: &str = r#try!(i.read()); | ||
1101 | let value: arg::Variant<Box<dyn arg::RefArg>> = r#try!(i.read()); | ||
1102 | let d = fclone(minfo); | ||
1103 | r#try!(d.set(interface_name, property_name, value)); | ||
1104 | let rm = minfo.msg.method_return(); | ||
1105 | Ok(vec!(rm)) | ||
1106 | }; | ||
1107 | let m = factory.method("Set", Default::default(), h); | ||
1108 | let m = m.in_arg(("interface_name", "s")); | ||
1109 | let m = m.in_arg(("property_name", "s")); | ||
1110 | let m = m.in_arg(("value", "v")); | ||
1111 | let i = i.add_m(m); | ||
1112 | |||
1113 | let fclone = f.clone(); | ||
1114 | let h = move |minfo: &tree::MethodInfo<'_, tree::MTFn<D>, D>| { | ||
1115 | let mut i = minfo.msg.iter_init(); | ||
1116 | let interface_name: &str = r#try!(i.read()); | ||
1117 | let d = fclone(minfo); | ||
1118 | let props = r#try!(d.get_all(interface_name)); | ||
1119 | let rm = minfo.msg.method_return(); | ||
1120 | let rm = rm.append1(props); | ||
1121 | Ok(vec!(rm)) | ||
1122 | }; | ||
1123 | let m = factory.method("GetAll", Default::default(), h); | ||
1124 | let m = m.in_arg(("interface_name", "s")); | ||
1125 | let m = m.out_arg(("props", "a{sv}")); | ||
1126 | let i = i.add_m(m); | ||
1127 | i | ||
1128 | } | ||
diff --git a/src/pa_eq/mod.rs b/src/pa_eq/mod.rs deleted file mode 100644 index 09b2039..0000000 --- a/src/pa_eq/mod.rs +++ /dev/null | |||
@@ -1,115 +0,0 @@ | |||
1 | mod dbus_api; | ||
2 | |||
3 | use crate::cli::pa_eq::*; | ||
4 | use crate::utils::*; | ||
5 | use crate::Filter; | ||
6 | |||
7 | use self::dbus_api::equalizing_manager::OrgPulseAudioExtEqualizing1Manager; | ||
8 | use self::dbus_api::server_lookup::OrgPulseAudioServerLookup1; | ||
9 | use self::dbus_api::sink::OrgPulseAudioExtEqualizing1Equalizer; | ||
10 | |||
11 | use dbus::{BusType, ConnPath, Connection}; | ||
12 | |||
13 | use failure::{Error, ResultExt}; | ||
14 | |||
15 | #[derive(Fail, Debug)] | ||
16 | #[fail(display = "No equalized sink found")] | ||
17 | struct NoEqualizedSink; | ||
18 | |||
19 | pub fn main(cmd: Command) -> Result<(), Error> { | ||
20 | use crate::cli::pa_eq::Command::*; | ||
21 | |||
22 | warn!("The PulseAudio equalizer has been deprecated for a while, and is known to sometimes cause crashes, latency or audible artifacts"); | ||
23 | |||
24 | match cmd { | ||
25 | Load(args) => load(args), | ||
26 | Reset(args) => reset(args), | ||
27 | } | ||
28 | } | ||
29 | |||
30 | pub fn reset(_args: ResetCli) -> Result<(), Error> { | ||
31 | let conn = connect()?; | ||
32 | let conn_sink = get_equalized_sink(&conn)?; | ||
33 | let filter_rate = conn_sink.get_filter_sample_rate()?; | ||
34 | let filter = Filter { | ||
35 | preamp: 1f64, | ||
36 | frequencies: vec![], | ||
37 | coefficients: vec![], | ||
38 | } | ||
39 | .pad(filter_rate); | ||
40 | |||
41 | send_filter(&conn_sink, filter)?; | ||
42 | |||
43 | Ok(()) | ||
44 | } | ||
45 | |||
46 | pub fn load(args: LoadCli) -> Result<(), Error> { | ||
47 | let conn = connect()?; | ||
48 | let conn_sink = get_equalized_sink(&conn)?; | ||
49 | |||
50 | let filter = read_filter_from_arg(&args.file)?; | ||
51 | |||
52 | let filter_rate = conn_sink.get_filter_sample_rate()?; | ||
53 | send_filter(&conn_sink, filter.pad(filter_rate))?; | ||
54 | |||
55 | Ok(()) | ||
56 | } | ||
57 | |||
58 | fn connect() -> Result<Connection, Error> { | ||
59 | Ok(connect_impl().context( | ||
60 | "Could not connect to PulseAudio's D-Bus socket. Have you loaded the 'module-dbus-protocol' module?" | ||
61 | )?) | ||
62 | } | ||
63 | |||
64 | fn connect_impl() -> Result<Connection, Error> { | ||
65 | let pulse_sock_path = get_pulse_dbus_sock()?; | ||
66 | info!("PulseAudio's D-Bus socket path is: {}", pulse_sock_path); | ||
67 | |||
68 | trace!("Connecting to PulseAudio's D-Bus socket"); | ||
69 | Ok(Connection::open_private(&pulse_sock_path)?) | ||
70 | } | ||
71 | |||
72 | fn get_equalized_sink(conn: &Connection) -> Result<ConnPath<'_, &Connection>, Error> { | ||
73 | Ok(get_equalized_sink_impl(conn).context( | ||
74 | "Could not find an equalized sink. Have you loaded the 'module-equalizer-sink' module?", | ||
75 | )?) | ||
76 | } | ||
77 | |||
78 | fn get_equalized_sink_impl(conn: &Connection) -> Result<ConnPath<'_, &Connection>, Error> { | ||
79 | let conn_manager = conn.with_path("org.PulseAudio.Core1", "/org/pulseaudio/equalizing1", 2000); | ||
80 | |||
81 | // TODO: make that a command-line option | ||
82 | trace!("Getting (one of) the equalized sink(s)"); | ||
83 | let mut sinks = conn_manager.get_equalized_sinks()?; | ||
84 | let sink_path = sinks.pop().ok_or(NoEqualizedSink {})?; | ||
85 | info!("Using equalized sink: {:?}", sink_path.as_cstr()); | ||
86 | |||
87 | trace!("Connecting to equalized sink"); | ||
88 | Ok(conn.with_path("org.PulseAudio.Core1", sink_path, 2000)) | ||
89 | } | ||
90 | |||
91 | fn send_filter(conn_sink: &ConnPath<'_, &Connection>, filter: Filter) -> Result<(), Error> { | ||
92 | let channel = conn_sink.get_nchannels()?; | ||
93 | info!("Using channel: {}", channel); | ||
94 | trace!("Sending filter: {:?}", filter); | ||
95 | conn_sink.seed_filter( | ||
96 | channel, | ||
97 | filter.frequencies, | ||
98 | filter | ||
99 | .coefficients | ||
100 | .into_iter() | ||
101 | .map(decibel_to_ratio) | ||
102 | .collect(), | ||
103 | decibel_to_ratio(filter.preamp), | ||
104 | )?; | ||
105 | Ok(()) | ||
106 | } | ||
107 | |||
108 | fn get_pulse_dbus_sock() -> Result<String, Error> { | ||
109 | trace!("Connecting to the D-Bus' session bus"); | ||
110 | let conn = Connection::get_private(BusType::Session)?; | ||
111 | let conn = conn.with_path("org.PulseAudio1", "/org/pulseaudio/server_lookup1", 2000); | ||
112 | |||
113 | trace!("Checking PulseAudio's D-Bus socket path"); | ||
114 | Ok(conn.get_address()?) | ||
115 | } | ||
diff --git a/src/utils.rs b/src/utils.rs index 2e585b0..4596b3f 100644 --- a/src/utils.rs +++ b/src/utils.rs | |||
@@ -67,34 +67,3 @@ where | |||
67 | message: format!("{}", error), | 67 | message: format!("{}", error), |
68 | } | 68 | } |
69 | } | 69 | } |
70 | |||
71 | pub fn decibel_to_ratio(decibel: f64) -> f64 { | ||
72 | 10f64.powf(decibel / 10f64).sqrt() | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | fn introspect(conn: &dbus::ConnPath<&Connection>) { | ||
77 | let mut thing = conn | ||
78 | .method_call_with_args( | ||
79 | &"org.freedesktop.DBus.Introspectable".into(), | ||
80 | &"Introspect".into(), | ||
81 | |_| {}, | ||
82 | ).unwrap(); | ||
83 | thing.as_result().unwrap(); | ||
84 | |||
85 | println!("{}", thing.iter_init().read::<String>().unwrap()); | ||
86 | } | ||
87 | */ | ||
88 | |||
89 | #[cfg(test)] | ||
90 | mod tests { | ||
91 | |||
92 | #[test] | ||
93 | fn decibel_to_ratio() { | ||
94 | assert_eq!(super::decibel_to_ratio(0f64), 1f64); | ||
95 | assert_eq!(super::decibel_to_ratio(20f64), 10f64); | ||
96 | assert_eq!(super::decibel_to_ratio(40f64), 100f64); | ||
97 | assert_eq!(super::decibel_to_ratio(60f64), 1000f64); | ||
98 | } | ||
99 | |||
100 | } | ||