Skip to content

Commit

Permalink
Merge branch 'fix/flex-config-apply' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mrene committed Jun 7, 2022
2 parents 964cb0e + 79bcc1f commit e52cb9b
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release build
on:
push:
branches:
- 'arm64'
- 'fix/flex-config-apply'
tags:
- 'v0.*'
- 'v1.*'
Expand Down
74 changes: 21 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Mathieu Rene <mathieu.rene@gmail.com>"]
edition = "2021"
name = "minidsp-daemon"
version = "0.1.6"
version = "0.1.7"
license = "Apache-2.0"
description = "A control interface for some MiniDSP products"
repository = "https://github.com/mrene/minidsp-rs"
Expand All @@ -23,7 +23,7 @@ env_logger = "0.9.0"
futures = "0.3.21"
futures-sink = "0.3.21"
futures-util = "0.3.21"
hyper = "0.14.18"
hyper = "0.14.19"
hyper-tungstenite = "0.8.0"
lazy_static = "1.4.0"
log = "0.4.17"
Expand All @@ -38,16 +38,16 @@ serde_json = "1.0.81"
strum = { version = "0.24.0", features = ["derive"], optional = true }
termcolor = "1.1.3"
thiserror = "1.0.31"
tokio-stream = { version = "0.1.8", features = ["sync"] }
tokio-stream = { version = "0.1.9", features = ["sync"] }
url2 = "0.0.6"

[dependencies.tokio]
features = ["rt-multi-thread", "net", "fs", "macros", "io-util"]
version = "1.18.2"
version = "1.19.2"

[dependencies.tokio-util]
features = ["net", "codec", "io"]
version = "0.7.2"
version = "0.7.3"

[target.'cfg(target_family="unix")'.dependencies]
hyperlocal = "0.8.0"
Expand Down
6 changes: 3 additions & 3 deletions devtools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Mathieu Rene <mathieu.rene@gmail.com>"]
edition = "2021"
name = "minidsp-devtools"
version = "0.1.6"
version = "0.1.7"
license = "Apache-2.0"

[features]
Expand All @@ -29,8 +29,8 @@ quote = "1.0.18"

[dependencies.tokio]
features = ["rt-multi-thread", "net", "fs", "macros", "io-util"]
version = "1.18.2"
version = "1.19.2"

[dependencies.tokio-util]
features = ["net", "codec", "io"]
version = "0.7.2"
version = "0.7.3"
14 changes: 7 additions & 7 deletions minidsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ keywords = ["minidsp", "audio", "dsp"]
license = "Apache-2.0"
name = "minidsp"
repository = "https://github.com/mrene/minidsp-rs"
version = "0.1.6"
version = "0.1.7"

[dependencies]
anyhow = "1.0.57"
async-trait = "0.1.53"
async-trait = "0.1.56"
atomic_refcell = "0.1.8"
bimap = "0.6.2"
bytes = "1.1.0"
Expand All @@ -22,10 +22,10 @@ futures-sink = "0.3.21"
futures-util = "0.3.21"
hex = "0.4.3"
hexplay = "0.2.1"
hyper = "0.14.18"
hyper = "0.14.19"
lazy_static = "1.4.0"
log = "0.4.17"
minidsp-protocol = {path = "../protocol", version = "0.1.6", default-features = false, features = ["use_serde", "debug", "devices"]}
minidsp-protocol = {path = "../protocol", version = "0.1.7", default-features = false, features = ["use_serde", "debug", "devices"]}
pin-project = "1.0.10"
schemars = "0.8.10"
serde = { version = "1.0.137", features = ["derive"] }
Expand All @@ -35,7 +35,7 @@ strong-xml = "0.6.3"
strum = { version = "0.24.0", features = ["derive"] }
termcolor = "1.1.3"
thiserror = "1.0.31"
tokio-stream = { version = "0.1.8", features = ["sync"] }
tokio-stream = { version = "0.1.9", features = ["sync"] }
tokio-tungstenite = "0.17.1"
tower = { version = "0.4.12", features = ["util", "timeout"] }
url2 = "0.0.6"
Expand All @@ -54,11 +54,11 @@ version = "1.4.1"

[dependencies.tokio]
features = ["rt-multi-thread", "net", "fs", "macros", "io-util"]
version = "1.18.2"
version = "1.19.2"

[dependencies.tokio-util]
features = ["net", "codec", "io"]
version = "0.7.2"
version = "0.7.3"

[target.'cfg(target_family="unix")'.dependencies]
hyperlocal = "0.8.0"
Expand Down
18 changes: 16 additions & 2 deletions minidsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,22 @@ impl MiniDSP<'_> {
reset: true,
})
.await?
.into_config_changed()
.err_into()
.into_config_changed()?;

// The MiniDSP Flex is immediately responding to `SetConfig` without waiting for it to be applied
// Try polling the master status until the new config is reported
loop {
let status = self.get_master_status().await?;
let preset = status.preset.unwrap();

if preset == config {
break;
}

tokio::time::sleep(Duration::from_millis(500)).await;
}

Ok(())
}

/// Enables or disables Dirac Live
Expand Down
24 changes: 18 additions & 6 deletions minidsp/src/utils/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct Decoder {
quiet: bool,
w: Box<dyn WriteColor + Send + Sync>,
name_map: Option<BiMap<String, usize>>,
start_instant: std::time::Instant,
}

impl Decoder {
Expand All @@ -28,7 +29,12 @@ impl Decoder {
quiet: bool,
name_map: Option<BiMap<String, usize>>,
) -> Self {
Decoder { quiet, w, name_map }
Decoder {
quiet,
w,
name_map,
start_instant: std::time::Instant::now(),
}
}

/// Sets the symbol names to be printed
Expand Down Expand Up @@ -86,6 +92,14 @@ impl Decoder {
}
}

fn print_time(&mut self) -> std::io::Result<()> {
let elapsed = self.start_instant.elapsed();
let secs = elapsed.as_secs();
let millis = elapsed.subsec_millis();
let _ = write!(self.w, "[{}.{:03}s] ", secs, millis);
Ok(())
}

fn print_frame(&mut self, sent: bool, frame: &Bytes) -> std::io::Result<()> {
let _ = self.print_direction(sent);
let _ = self
Expand Down Expand Up @@ -122,13 +136,15 @@ impl Decoder {
let _ = self.w.set_color(ColorSpec::new().set_fg(Some(Color::Blue)));
"Recv: "
};
let _ = self.print_time();
write!(self.w, "{}", direction)?;

Ok(())
}

fn print_error<T: fmt::Debug>(&mut self, err: T) -> std::io::Result<()> {
let _ = self.w.set_color(ColorSpec::new().set_fg(Some(Color::Red)));
let _ = self.print_time();
writeln!(self.w, "Decode error: {:?}", err)?;
Ok(())
}
Expand Down Expand Up @@ -180,11 +196,7 @@ mod test {
#[test]
fn test_print() {
let writer = Box::new(StandardStream::stderr(ColorChoice::Always));
let mut d = Decoder {
w: writer,
quiet: false,
name_map: None,
};
let mut d = Decoder::new(writer, false, None);
d.feed_sent(&Bytes::from_static(&[0x05, 0x14, 0x00, 0x46, 0x04, 0x63]));
d.feed_recv(&Bytes::from_static(&[
0x05, 0x14, 0x00, 0x46, 0x00, 0x00, 0x00,
Expand Down
Loading

0 comments on commit e52cb9b

Please # to comment.