diff --git a/src/netmd/base.rs b/src/netmd/base.rs index 63fa07c..1b7a643 100644 --- a/src/netmd/base.rs +++ b/src/netmd/base.rs @@ -14,238 +14,56 @@ use super::utils::cross_sleep; const BULK_WRITE_ENDPOINT: u8 = 0x02; const BULK_READ_ENDPOINT: u8 = 0x81; +nofmt::pls! { // Skip formatting the following info pub static DEVICE_IDS: &[DeviceId] = &[ - DeviceId { - vendor_id: 0x04dd, - product_id: 0x7202, - name: Some("Sharp IM-MT899H"), - }, - DeviceId { - vendor_id: 0x04dd, - product_id: 0x9013, - name: Some("Sharp IM-DR400"), - }, - DeviceId { - vendor_id: 0x04dd, - product_id: 0x9014, - name: Some("Sharp IM-DR80"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0034, - name: Some("Sony PCLK-XX"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0036, - name: Some("Sony"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0075, - name: Some("Sony MZ-N1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x007c, - name: Some("Sony"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0080, - name: Some("Sony LAM-1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0081, - name: Some("Sony MDS-JB980/MDS-NT1/MDS-JE780"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0084, - name: Some("Sony MZ-N505"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0085, - name: Some("Sony MZ-S1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0086, - name: Some("Sony MZ-N707"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x008e, - name: Some("Sony CMT-C7NT"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0097, - name: Some("Sony PCGA-MDN1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00ad, - name: Some("Sony CMT-L7HD"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00c6, - name: Some("Sony MZ-N10"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00c7, - name: Some("Sony MZ-N910"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00c8, - name: Some("Sony MZ-N710/NF810"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00c9, - name: Some("Sony MZ-N510/N610"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00ca, - name: Some("Sony MZ-NE410/NF520D"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00e7, - name: Some("Sony CMT-M333NT/M373NT"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x00eb, - name: Some("Sony MZ-NE810/NE910"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0101, - name: Some("Sony LAM"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0113, - name: Some("Aiwa AM-NX1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x013f, - name: Some("Sony MDS-S500"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x014c, - name: Some("Aiwa AM-NX9"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x017e, - name: Some("Sony MZ-NH1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0180, - name: Some("Sony MZ-NH3D"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0182, - name: Some("Sony MZ-NH900"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0184, - name: Some("Sony MZ-NH700/NH800"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0186, - name: Some("Sony MZ-NH600"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0187, - name: Some("Sony MZ-NH600D"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0188, - name: Some("Sony MZ-N920"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x018a, - name: Some("Sony LAM-3"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x01e9, - name: Some("Sony MZ-DH10P"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0219, - name: Some("Sony MZ-RH10"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x021b, - name: Some("Sony MZ-RH710/MZ-RH910"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x021d, - name: Some("Sony CMT-AH10"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x022c, - name: Some("Sony CMT-AH10"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x023c, - name: Some("Sony DS-HMD1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0286, - name: Some("Sony MZ-RH1"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x011a, - name: Some("Sony CMT-SE7"), - }, - DeviceId { - vendor_id: 0x054c, - product_id: 0x0148, - name: Some("Sony MDS-A1"), - }, - DeviceId { - vendor_id: 0x0b28, - product_id: 0x1004, - name: Some("Kenwood MDX-J9"), - }, - DeviceId { - vendor_id: 0x04da, - product_id: 0x23b3, - name: Some("Panasonic SJ-MR250"), - }, - DeviceId { - vendor_id: 0x04da, - product_id: 0x23b6, - name: Some("Panasonic SJ-MR270"), - }, + DeviceId { vendor_id: 0x04dd, product_id: 0x7202, name: Some("Sharp IM-MT899H") }, + DeviceId { vendor_id: 0x04dd, product_id: 0x9013, name: Some("Sharp IM-DR400") }, + DeviceId { vendor_id: 0x04dd, product_id: 0x9014, name: Some("Sharp IM-DR80") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0034, name: Some("Sony PCLK-XX") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0036, name: Some("Sony") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0075, name: Some("Sony MZ-N1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x007c, name: Some("Sony") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0080, name: Some("Sony LAM-1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0081, name: Some("Sony MDS-JB980/MDS-NT1/MDS-JE780") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0084, name: Some("Sony MZ-N505") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0085, name: Some("Sony MZ-S1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0086, name: Some("Sony MZ-N707") }, + DeviceId { vendor_id: 0x054c, product_id: 0x008e, name: Some("Sony CMT-C7NT") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0097, name: Some("Sony PCGA-MDN1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00ad, name: Some("Sony CMT-L7HD") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00c6, name: Some("Sony MZ-N10") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00c7, name: Some("Sony MZ-N910") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00c8, name: Some("Sony MZ-N710/NF810") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00c9, name: Some("Sony MZ-N510/N610") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00ca, name: Some("Sony MZ-NE410/NF520D") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00e7, name: Some("Sony CMT-M333NT/M373NT") }, + DeviceId { vendor_id: 0x054c, product_id: 0x00eb, name: Some("Sony MZ-NE810/NE910") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0101, name: Some("Sony LAM") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0113, name: Some("Aiwa AM-NX1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x013f, name: Some("Sony MDS-S500") }, + DeviceId { vendor_id: 0x054c, product_id: 0x014c, name: Some("Aiwa AM-NX9") }, + DeviceId { vendor_id: 0x054c, product_id: 0x017e, name: Some("Sony MZ-NH1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0180, name: Some("Sony MZ-NH3D") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0182, name: Some("Sony MZ-NH900") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0184, name: Some("Sony MZ-NH700/NH800") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0186, name: Some("Sony MZ-NH600") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0187, name: Some("Sony MZ-NH600D") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0188, name: Some("Sony MZ-N920") }, + DeviceId { vendor_id: 0x054c, product_id: 0x018a, name: Some("Sony LAM-3") }, + DeviceId { vendor_id: 0x054c, product_id: 0x01e9, name: Some("Sony MZ-DH10P") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0219, name: Some("Sony MZ-RH10") }, + DeviceId { vendor_id: 0x054c, product_id: 0x021b, name: Some("Sony MZ-RH710/MZ-RH910") }, + DeviceId { vendor_id: 0x054c, product_id: 0x021d, name: Some("Sony CMT-AH10") }, + DeviceId { vendor_id: 0x054c, product_id: 0x022c, name: Some("Sony CMT-AH10") }, + DeviceId { vendor_id: 0x054c, product_id: 0x023c, name: Some("Sony DS-HMD1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0286, name: Some("Sony MZ-RH1") }, + DeviceId { vendor_id: 0x054c, product_id: 0x011a, name: Some("Sony CMT-SE7") }, + DeviceId { vendor_id: 0x054c, product_id: 0x0148, name: Some("Sony MDS-A1") }, + DeviceId { vendor_id: 0x0b28, product_id: 0x1004, name: Some("Kenwood MDX-J9") }, + DeviceId { vendor_id: 0x04da, product_id: 0x23b3, name: Some("Panasonic SJ-MR250") }, + DeviceId { vendor_id: 0x04da, product_id: 0x23b6, name: Some("Panasonic SJ-MR270") }, ]; +} pub static DEVICE_IDS_CROSSUSB: Lazy> = Lazy::new(|| { DEVICE_IDS diff --git a/src/netmd/commands.rs b/src/netmd/commands.rs index d082efa..f402524 100644 --- a/src/netmd/commands.rs +++ b/src/netmd/commands.rs @@ -409,8 +409,8 @@ impl NetMDContext { let old_raw_name = self.interface.raw_disc_title(false).await?; let old_raw_fw_name = self.interface.raw_disc_title(true).await?; - let has_groups = old_raw_name.find("//").is_some(); - let has_fw_groups = old_raw_fw_name.find("//").is_some(); + let has_groups = old_raw_name.contains("//"); + let has_fw_groups = old_raw_fw_name.contains("//"); let has_groups_and_title = old_raw_name.starts_with("0;"); let has_fw_groups_and_title = old_raw_fw_name.starts_with("0;"); @@ -560,9 +560,7 @@ impl NetMDContext { impl From for NetMDContext { fn from(value: NetMDInterface) -> Self { - Self { - interface: value - } + Self { interface: value } } } diff --git a/src/netmd/encryption.rs b/src/netmd/encryption.rs index 8516d14..fb1b9ab 100644 --- a/src/netmd/encryption.rs +++ b/src/netmd/encryption.rs @@ -4,11 +4,6 @@ use rand::RngCore; use std::thread; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver}; -#[cfg(target_family = "wasm")] -use gloo::worker::{Spawnable, reactor::{reactor, ReactorScope}}; -#[cfg(target_family = "wasm")] -use futures::{sink::SinkExt, StreamExt}; - use super::interface::DataEncryptorInput; type DesEcbEnc = ecb::Decryptor; @@ -18,7 +13,7 @@ pub fn new_thread_encryptor( _input: DataEncryptorInput, ) -> UnboundedReceiver<(Vec, Vec, Vec)> { let (tx, rx) = unbounded_channel::<(Vec, Vec, Vec)>(); - let input = _input; + let input = Box::from(_input); thread::spawn(move || { let mut iv = [0u8; 8]; @@ -81,13 +76,3 @@ pub fn new_thread_encryptor( rx } - -#[cfg(target_family = "wasm")] -#[reactor] -async fn Encryptor(mut scope: ReactorScope) { - while let Some(m) = scope.next().await { - if scope.send(m.pow(2)).await.is_err() { - break; - } - } -} diff --git a/src/netmd/interface.rs b/src/netmd/interface.rs index 7a2fa16..14b8eb9 100644 --- a/src/netmd/interface.rs +++ b/src/netmd/interface.rs @@ -53,8 +53,8 @@ impl WireFormat { const fn frame_size(&self) -> u16 { match self { WireFormat::Pcm => 2048, - WireFormat::L105kbps => 152, WireFormat::LP2 => 192, + WireFormat::L105kbps => 152, WireFormat::LP4 => 96, } } diff --git a/src/netmd/utils.rs b/src/netmd/utils.rs index 1b7ed77..7f97304 100644 --- a/src/netmd/utils.rs +++ b/src/netmd/utils.rs @@ -150,7 +150,7 @@ pub fn sanitize_full_width_title(title: &str) -> String { /// Convert a UTF-8 string to Shift-JIS for use on the player pub fn to_sjis(sjis_str: &str) -> Vec { - let sjis_string = SHIFT_JIS.encode(&sjis_str).0; + let sjis_string = SHIFT_JIS.encode(sjis_str).0; if validate_sjis(sjis_string.clone().into()) { return agressive_sanitize_title(sjis_str).into(); @@ -203,7 +203,7 @@ pub fn create_aea_header(options: AeaOptions) -> Vec { .write_all(&vec![0; 256 - encoded_name.len()]) .unwrap(); header - .write_u32::(options.sound_groups as u32) + .write_u32::(options.sound_groups) .unwrap(); header.write_all(&[options.channels as u8, 0]).unwrap(); @@ -235,11 +235,9 @@ pub fn create_aea_header(options: AeaOptions) -> Vec { header.write_u32::(0).unwrap(); + header.write_u32::(options.encrypted).unwrap(); header - .write_u32::(options.encrypted as u32) - .unwrap(); - header - .write_u32::(options.group_start as u32) + .write_u32::(options.group_start) .unwrap(); // return the header @@ -295,9 +293,9 @@ pub struct RawTime { pub frames: u64, } -impl Into for RawTime { - fn into(self) -> std::time::Duration { - self.as_duration() +impl From for Duration { + fn from(val: RawTime) -> Self { + val.as_duration() } }