mirror of
https://github.com/G2-Games/minidisc-cli.git
synced 2025-04-19 11:42:53 -05:00
Made remaining merged functions async
and fixed them appropriately
This commit is contained in:
parent
1dadbd697d
commit
9dce1e328e
2 changed files with 16 additions and 16 deletions
|
@ -31,12 +31,12 @@ pub struct DeviceStatus {
|
|||
time: Time,
|
||||
}
|
||||
|
||||
pub fn device_status(interface: &mut NetMDInterface) -> Result<DeviceStatus, Box<dyn Error>> {
|
||||
let status = interface.status()?;
|
||||
let playback_status = interface.playback_status2()?;
|
||||
pub async fn device_status(interface: &mut NetMDInterface) -> Result<DeviceStatus, Box<dyn Error>> {
|
||||
let status = interface.status().await?;
|
||||
let playback_status = interface.playback_status2().await?;
|
||||
let b1: u16 = playback_status[4] as u16;
|
||||
let b2: u16 = playback_status[5] as u16;
|
||||
let position = interface.position()?;
|
||||
let position = interface.position().await?;
|
||||
let operating_status = b1 << 8 | b2;
|
||||
|
||||
let track = position[0] as u8;
|
||||
|
@ -56,22 +56,22 @@ pub fn device_status(interface: &mut NetMDInterface) -> Result<DeviceStatus, Box
|
|||
Ok(DeviceStatus { disc_present, state, track, time })
|
||||
}
|
||||
|
||||
pub fn prepare_download(interface: &mut NetMDInterface) -> Result<(), Box<dyn Error>>{
|
||||
while ![OperatingStatus::DiscBlank, OperatingStatus::Ready].contains(&device_status(interface)?.state.or(Some(OperatingStatus::NoDisc)).unwrap()) {
|
||||
pub async fn prepare_download(interface: &mut NetMDInterface) -> Result<(), Box<dyn Error>>{
|
||||
while ![OperatingStatus::DiscBlank, OperatingStatus::Ready].contains(&device_status(interface).await?.state.or(Some(OperatingStatus::NoDisc)).unwrap()) {
|
||||
sleep(Duration::from_millis(200));
|
||||
}
|
||||
|
||||
let _ = interface.session_key_forget();
|
||||
let _ = interface.leave_secure_session();
|
||||
|
||||
interface.acquire()?;
|
||||
interface.acquire().await?;
|
||||
let _ = interface.disable_new_track_protection(1);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn download(interface: &mut NetMDInterface, track: MDTrack) -> Result<(), Box<dyn Error>>{
|
||||
prepare_download(interface)?;
|
||||
pub async fn download(interface: &mut NetMDInterface, track: MDTrack) -> Result<(), Box<dyn Error>>{
|
||||
prepare_download(interface).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -38,7 +38,7 @@ pub enum DiscFormat {
|
|||
}
|
||||
|
||||
#[derive(Clone, Hash, Eq, PartialEq)]
|
||||
enum WireFormat {
|
||||
pub enum WireFormat {
|
||||
Pcm = 0x00,
|
||||
L105kbps = 0x90,
|
||||
LP2 = 0x94,
|
||||
|
@ -447,7 +447,7 @@ impl NetMDInterface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn acquire(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
pub async fn acquire(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
let mut query = format_query("ff 010c ffff ffff ffff ffff ffff ffff".to_string(), vec![])?;
|
||||
let reply = self.send_query(&mut query, false, false).await?;
|
||||
|
||||
|
@ -1708,12 +1708,12 @@ pub struct MDSession {
|
|||
}
|
||||
|
||||
impl MDSession {
|
||||
pub fn init(&mut self) -> Result<(), Box<dyn Error>>{
|
||||
self.md.enter_secure_session()?;
|
||||
self.md.leaf_id()?;
|
||||
pub async fn init(&mut self) -> Result<(), Box<dyn Error>>{
|
||||
self.md.enter_secure_session().await?;
|
||||
self.md.leaf_id().await?;
|
||||
|
||||
let ekb = self.ekb_object.ekb_data_for_leaf_id();
|
||||
self.md.send_key_data(self.ekb_object.ekb_id(), ekb.chains, ekb.depth, ekb.signature)?;
|
||||
self.md.send_key_data(self.ekb_object.ekb_id(), ekb.chains, ekb.depth, ekb.signature).await?;
|
||||
let mut nonce = vec![0u8, 8];
|
||||
rand::thread_rng().fill_bytes(&mut nonce);
|
||||
|
||||
|
|
Loading…
Reference in a new issue