diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cli.rs | 24 | ||||
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | src/pa_effects.rs | 12 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/equalizing_manager.rs (renamed from src/dbus_api/equalizing_manager.rs) | 0 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/mod.rs (renamed from src/dbus_api/mod.rs) | 0 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/server_lookup.rs (renamed from src/dbus_api/server_lookup.rs) | 0 | ||||
-rw-r--r-- | src/pa_eq/dbus_api/sink.rs (renamed from src/dbus_api/sink.rs) | 0 | ||||
-rw-r--r-- | src/pa_eq/mod.rs (renamed from src/pa_eq.rs) | 8 | ||||
-rw-r--r-- | src/utils.rs | 4 |
9 files changed, 41 insertions, 18 deletions
@@ -4,23 +4,19 @@ use structopt; | |||
4 | 4 | ||
5 | #[derive(StructOpt, Debug)] | 5 | #[derive(StructOpt, Debug)] |
6 | #[structopt(raw(setting = "structopt::clap::AppSettings::ColoredHelp"))] | 6 | #[structopt(raw(setting = "structopt::clap::AppSettings::ColoredHelp"))] |
7 | /// Hello World! How are you doing? | 7 | /// A command-line tool to manipulate PulseAudio's equalizers |
8 | pub struct Cli { | 8 | pub struct Cli { |
9 | #[structopt(flatten)] | 9 | #[structopt(flatten)] |
10 | pub verbose: clap_verbosity_flag::Verbosity, | 10 | pub verbose: clap_verbosity_flag::Verbosity, |
11 | #[structopt(flatten)] | 11 | #[structopt(flatten)] |
12 | pub log: clap_log_flag::Log, | 12 | pub log: clap_log_flag::Log, |
13 | #[structopt(short = "s", long = "sink")] | ||
14 | /// Use the given sink. | ||
15 | /// | ||
16 | /// By default it will use the last equalized sink it finds | ||
17 | pub sink: Option<String>, | ||
18 | #[structopt(subcommand)] | 13 | #[structopt(subcommand)] |
19 | pub cmd: Command, | 14 | pub cmd: Command, |
20 | } | 15 | } |
21 | 16 | ||
22 | #[derive(StructOpt, Debug)] | 17 | #[derive(StructOpt, Debug)] |
23 | pub enum Command { | 18 | pub enum Command { |
19 | #[cfg(feature = "pa-eq")] | ||
24 | #[structopt(name = "pa-eq")] | 20 | #[structopt(name = "pa-eq")] |
25 | /// PulseAudio equalizer related commands | 21 | /// PulseAudio equalizer related commands |
26 | /// | 22 | /// |
@@ -28,6 +24,7 @@ pub enum Command { | |||
28 | /// and is known to sometimes cause crashes, latency or audible | 24 | /// and is known to sometimes cause crashes, latency or audible |
29 | /// artifacts | 25 | /// artifacts |
30 | PaEq(pa_eq::Command), | 26 | PaEq(pa_eq::Command), |
27 | #[cfg(feature = "pa-effects")] | ||
31 | #[structopt(name = "pa-effects")] | 28 | #[structopt(name = "pa-effects")] |
32 | /// PulseEffects equalizer related commands | 29 | /// PulseEffects equalizer related commands |
33 | PaEffects(pa_effects::Command), | 30 | PaEffects(pa_effects::Command), |
@@ -40,6 +37,7 @@ arg_enum! { | |||
40 | } | 37 | } |
41 | } | 38 | } |
42 | 39 | ||
40 | #[cfg(feature = "pa-eq")] | ||
43 | pub mod pa_eq { | 41 | pub mod pa_eq { |
44 | use super::EqualizerConfFormat; | 42 | use super::EqualizerConfFormat; |
45 | 43 | ||
@@ -71,13 +69,25 @@ pub mod pa_eq { | |||
71 | )] | 69 | )] |
72 | /// The file format of the equalizer configuration | 70 | /// The file format of the equalizer configuration |
73 | pub format: EqualizerConfFormat, | 71 | pub format: EqualizerConfFormat, |
72 | #[structopt(short = "s", long = "sink")] | ||
73 | /// Use the given sink. | ||
74 | /// | ||
75 | /// By default it will use the last equalized sink it finds | ||
76 | pub sink: Option<String>, | ||
74 | } | 77 | } |
75 | 78 | ||
76 | #[derive(StructOpt, Debug)] | 79 | #[derive(StructOpt, Debug)] |
77 | pub struct ResetCli {} | 80 | pub struct ResetCli { |
81 | #[structopt(short = "s", long = "sink")] | ||
82 | /// Use the given sink. | ||
83 | /// | ||
84 | /// By default it will use the last equalized sink it finds | ||
85 | pub sink: Option<String>, | ||
86 | } | ||
78 | 87 | ||
79 | } | 88 | } |
80 | 89 | ||
90 | #[cfg(feature = "pa-effects")] | ||
81 | pub mod pa_effects { | 91 | pub mod pa_effects { |
82 | use super::EqualizerConfFormat; | 92 | use super::EqualizerConfFormat; |
83 | 93 | ||
diff --git a/src/main.rs b/src/main.rs index a23034e..df1732d 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | extern crate dbus; | ||
2 | |||
3 | #[macro_use] | 1 | #[macro_use] |
4 | extern crate log; | 2 | extern crate log; |
5 | #[macro_use] | 3 | #[macro_use] |
@@ -14,15 +12,20 @@ extern crate structopt; | |||
14 | 12 | ||
15 | extern crate lalrpop_util; | 13 | extern crate lalrpop_util; |
16 | 14 | ||
15 | #[cfg(feature = "pa-eq")] | ||
16 | extern crate dbus; | ||
17 | |||
18 | #[cfg(feature = "pa-effects")] | ||
17 | #[macro_use] | 19 | #[macro_use] |
18 | extern crate serde_json; | 20 | extern crate serde_json; |
19 | 21 | ||
20 | mod cli; | 22 | mod cli; |
21 | mod dbus_api; | ||
22 | mod parsing; | 23 | mod parsing; |
23 | mod utils; | 24 | mod utils; |
24 | 25 | ||
26 | #[cfg(feature = "pa-eq")] | ||
25 | mod pa_eq; | 27 | mod pa_eq; |
28 | #[cfg(feature = "pa-effects")] | ||
26 | mod pa_effects; | 29 | mod pa_effects; |
27 | 30 | ||
28 | use cli::*; | 31 | use cli::*; |
@@ -75,7 +78,9 @@ fn start() -> Result<(), Error> { | |||
75 | use Command::*; | 78 | use Command::*; |
76 | 79 | ||
77 | match args.cmd { | 80 | match args.cmd { |
81 | #[cfg(feature = "pa-eq")] | ||
78 | PaEq(args) => pa_eq::main(args), | 82 | PaEq(args) => pa_eq::main(args), |
83 | #[cfg(feature = "pa-effects")] | ||
79 | PaEffects(args) => pa_effects::main(args), | 84 | PaEffects(args) => pa_effects::main(args), |
80 | } | 85 | } |
81 | } | 86 | } |
diff --git a/src/pa_effects.rs b/src/pa_effects.rs index 9ed0a1f..43d27cb 100644 --- a/src/pa_effects.rs +++ b/src/pa_effects.rs | |||
@@ -19,8 +19,14 @@ pub fn main(cmd: Command) -> Result<(), Error> { | |||
19 | fn export_preset(args: ExportPresetCli) -> Result<(), Error> { | 19 | fn export_preset(args: ExportPresetCli) -> Result<(), Error> { |
20 | debug!("Parsing base preset"); | 20 | debug!("Parsing base preset"); |
21 | let mut preset: serde_json::Value = match args.base_preset { | 21 | let mut preset: serde_json::Value = match args.base_preset { |
22 | Some(file) => serde_json::from_str(&read_filearg_to_str(&file)?), | 22 | Some(file) => { |
23 | None => serde_json::from_str(&DEFAULT_PRESET), | 23 | info!("Reading base PulseEffects preset from file '{}'", file); |
24 | serde_json::from_str(&read_filearg_to_str(&file)?) | ||
25 | } | ||
26 | None => { | ||
27 | info!("Using default PulseEffects preset"); | ||
28 | serde_json::from_str(&DEFAULT_PRESET) | ||
29 | } | ||
24 | }?; | 30 | }?; |
25 | 31 | ||
26 | let filter = read_filter_from_arg(&args.file)?; | 32 | let filter = read_filter_from_arg(&args.file)?; |
@@ -65,7 +71,7 @@ fn simplify_filter(filter: Filter) -> Filter { | |||
65 | let mut partition_size = filter.frequencies.len() / 30; | 71 | let mut partition_size = filter.frequencies.len() / 30; |
66 | let step_error = filter.frequencies.len() as f64 % 30f64; | 72 | let step_error = filter.frequencies.len() as f64 % 30f64; |
67 | if step_error != 0f64 { | 73 | if step_error != 0f64 { |
68 | info!("The approximation will be imperfect"); | 74 | trace!("The approximation will be imperfect"); |
69 | partition_size += 1; | 75 | partition_size += 1; |
70 | } | 76 | } |
71 | 77 | ||
diff --git a/src/dbus_api/equalizing_manager.rs b/src/pa_eq/dbus_api/equalizing_manager.rs index 5f6574f..5f6574f 100644 --- a/src/dbus_api/equalizing_manager.rs +++ b/src/pa_eq/dbus_api/equalizing_manager.rs | |||
diff --git a/src/dbus_api/mod.rs b/src/pa_eq/dbus_api/mod.rs index a184c55..a184c55 100644 --- a/src/dbus_api/mod.rs +++ b/src/pa_eq/dbus_api/mod.rs | |||
diff --git a/src/dbus_api/server_lookup.rs b/src/pa_eq/dbus_api/server_lookup.rs index 78ad4bd..78ad4bd 100644 --- a/src/dbus_api/server_lookup.rs +++ b/src/pa_eq/dbus_api/server_lookup.rs | |||
diff --git a/src/dbus_api/sink.rs b/src/pa_eq/dbus_api/sink.rs index 6bd1756..6bd1756 100644 --- a/src/dbus_api/sink.rs +++ b/src/pa_eq/dbus_api/sink.rs | |||
diff --git a/src/pa_eq.rs b/src/pa_eq/mod.rs index 4086c31..f7f1875 100644 --- a/src/pa_eq.rs +++ b/src/pa_eq/mod.rs | |||
@@ -1,10 +1,12 @@ | |||
1 | mod dbus_api; | ||
2 | |||
1 | use Filter; | 3 | use Filter; |
2 | use cli::pa_eq::*; | 4 | use cli::pa_eq::*; |
3 | use utils::*; | 5 | use utils::*; |
4 | 6 | ||
5 | use dbus_api::equalizing_manager::OrgPulseAudioExtEqualizing1Manager; | 7 | use self::dbus_api::equalizing_manager::OrgPulseAudioExtEqualizing1Manager; |
6 | use dbus_api::server_lookup::OrgPulseAudioServerLookup1; | 8 | use self::dbus_api::server_lookup::OrgPulseAudioServerLookup1; |
7 | use dbus_api::sink::OrgPulseAudioExtEqualizing1Equalizer; | 9 | use self::dbus_api::sink::OrgPulseAudioExtEqualizing1Equalizer; |
8 | 10 | ||
9 | use dbus::{BusType, ConnPath, Connection}; | 11 | use dbus::{BusType, ConnPath, Connection}; |
10 | 12 | ||
diff --git a/src/utils.rs b/src/utils.rs index d75971a..26facc4 100644 --- a/src/utils.rs +++ b/src/utils.rs | |||
@@ -26,7 +26,7 @@ pub fn read_filearg_to_str(file: &str) -> Result<String, Error> { | |||
26 | 26 | ||
27 | let mut buffer = String::new(); | 27 | let mut buffer = String::new(); |
28 | if file == "-" { | 28 | if file == "-" { |
29 | info!("Reading file from the command line"); | 29 | debug!("Reading file from the command line"); |
30 | let stdin = io::stdin(); | 30 | let stdin = io::stdin(); |
31 | let mut handle = stdin.lock(); | 31 | let mut handle = stdin.lock(); |
32 | handle.read_to_string(&mut buffer)?; | 32 | handle.read_to_string(&mut buffer)?; |
@@ -38,7 +38,7 @@ pub fn read_filearg_to_str(file: &str) -> Result<String, Error> { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | pub fn read_filter_from_arg(file: &str) -> Result<Filter, Error> { | 40 | pub fn read_filter_from_arg(file: &str) -> Result<Filter, Error> { |
41 | debug!("Reading filter from '{}' in the EqualizerAPO format", file); | 41 | info!("Reading filter from '{}' in the EqualizerAPO format", file); |
42 | let content = read_filearg_to_str(file)?; | 42 | let content = read_filearg_to_str(file)?; |
43 | parse_filter(&content) | 43 | parse_filter(&content) |
44 | } | 44 | } |