summaryrefslogtreecommitdiffstats
path: root/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 5aae29d..6d7ae58 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -9,7 +9,7 @@ use ::dbus_api::sink::OrgPulseAudioExtEqualizing1Equalizer;
9use dbus::{BusType, Connection, ConnPath}; 9use dbus::{BusType, Connection, ConnPath};
10use failure::{Error, ResultExt}; 10use failure::{Error, ResultExt};
11 11
12use std::io::{self, Read}; 12use std::io;
13 13
14pub fn connect() -> Result<Connection, Error> { 14pub fn connect() -> Result<Connection, Error> {
15 let pulse_sock_path = 15 let pulse_sock_path =
@@ -36,7 +36,7 @@ pub fn get_equalized_sink<'a>(conn: &'a Connection) -> Result<ConnPath<'a, &'a C
36pub fn send_filter(conn_sink: &ConnPath<&Connection>, filter: Filter) -> Result<(), Error> { 36pub fn send_filter(conn_sink: &ConnPath<&Connection>, filter: Filter) -> Result<(), Error> {
37 let channel = conn_sink.get_nchannels()?; 37 let channel = conn_sink.get_nchannels()?;
38 info!("Using channel: {}", channel); 38 info!("Using channel: {}", channel);
39 trace!("Sending filter"); 39 trace!("Sending filter: {:?}", filter);
40 conn_sink.seed_filter( 40 conn_sink.seed_filter(
41 channel, 41 channel,
42 filter.frequencies, 42 filter.frequencies,
@@ -46,17 +46,15 @@ pub fn send_filter(conn_sink: &ConnPath<&Connection>, filter: Filter) -> Result<
46 Ok(()) 46 Ok(())
47} 47}
48 48
49pub fn read_filter() -> Result<Filter, Error> { 49pub fn read_filter(file: &mut impl io::Read) -> Result<Filter, Error> {
50 let mut buffer = String::new(); 50 let mut buffer = String::new();
51 let stdin = io::stdin();
52 let mut handle = stdin.lock();
53 51
54 info!("Reading filter in GraphicEQ format from the command line"); 52 info!("Reading filter in GraphicEQ format from the command line");
55 handle.read_to_string(&mut buffer)?; 53 file.read_to_string(&mut buffer)?;
56 54
57 // TODO: lifetime issue when "throwing" parse error 55 // TODO: lifetime issue when "throwing" parse error
58 let filter = EqualizerApoParser::new().parse(&buffer).unwrap(); 56 let filter = EqualizerApoParser::new().parse(&buffer).unwrap();
59 info!("Parsed filter: {:?}", filter); 57 trace!("Parsed filter: {:?}", filter);
60 58
61 Ok(filter) 59 Ok(filter)
62} 60}
@@ -69,3 +67,17 @@ fn get_pulse_dbus_sock() -> Result<String, Error> {
69 trace!("Checking PulseAudio's D-Bus socket path"); 67 trace!("Checking PulseAudio's D-Bus socket path");
70 Ok(conn.get_address()?) 68 Ok(conn.get_address()?)
71} 69}
70
71/*
72fn introspect(conn: &dbus::ConnPath<&Connection>) {
73 let mut thing = conn
74 .method_call_with_args(
75 &"org.freedesktop.DBus.Introspectable".into(),
76 &"Introspect".into(),
77 |_| {},
78 ).unwrap();
79 thing.as_result().unwrap();
80
81 println!("{}", thing.iter_init().read::<String>().unwrap());
82}
83*/