sound feature flag

This commit is contained in:
Aiden McClelland
2021-09-09 17:35:07 -06:00
committed by Aiden McClelland
parent 6b6dc404ab
commit 0cf1a45da7
3 changed files with 23 additions and 17 deletions

View File

@@ -38,9 +38,8 @@ path = "src/bin/embassy-cli.rs"
[features]
avahi = ["avahi-sys"]
default = ["avahi"]
portable = []
production = []
default = ["avahi", "sound"]
sound = []
[dependencies]
aes = { version = "0.7.5", features = ["ctr"] }

View File

@@ -50,18 +50,22 @@ impl Shutdown {
#[command(display(display_none))]
pub async fn shutdown(#[context] ctx: RpcContext) -> Result<(), Error> {
ctx.shutdown.send(Some(Shutdown {
zfs_pool: ctx.zfs_pool_name.clone(),
restart: false,
}));
ctx.shutdown
.send(Some(Shutdown {
zfs_pool: ctx.zfs_pool_name.clone(),
restart: false,
}))
.expect("receiver dropped");
Ok(())
}
#[command(display(display_none))]
pub async fn restart(#[context] ctx: RpcContext) -> Result<(), Error> {
ctx.shutdown.send(Some(Shutdown {
zfs_pool: ctx.zfs_pool_name.clone(),
restart: true,
}));
ctx.shutdown
.send(Some(Shutdown {
zfs_pool: ctx.zfs_pool_name.clone(),
restart: true,
}))
.expect("receiver dropped");
Ok(())
}

View File

@@ -113,12 +113,15 @@ where
&'a T: IntoIterator<Item = &'a (Option<Note>, TimeSlice)>,
{
pub async fn play(&'a self) -> Result<(), Error> {
let mut sound = SoundInterface::lease().await?;
for (note, slice) in &self.note_sequence {
match note {
None => tokio::time::sleep(slice.to_duration(self.tempo_qpm)).await,
Some(n) => sound.play_for_time_slice(self.tempo_qpm, n, slice).await?,
};
#[cfg(feature = "sound")]
{
let mut sound = SoundInterface::lease().await?;
for (note, slice) in &self.note_sequence {
match note {
None => tokio::time::sleep(slice.to_duration(self.tempo_qpm)).await,
Some(n) => sound.play_for_time_slice(self.tempo_qpm, n, slice).await?,
};
}
}
Ok(())
}