@@ -29,7 +29,6 @@ use winreg::RegKey;
2929use goxlr_types:: VersionNumber ;
3030
3131use crate :: device:: base:: GoXLRDevice ;
32- use crate :: { PID_GOXLR_FULL , PID_GOXLR_MINI , VID_GOXLR } ;
3332
3433// Define the Types of the various methods..
3534type EnumerateDevices = unsafe extern "C" fn ( ) -> u32 ;
@@ -659,97 +658,97 @@ impl TUSBAudio<'_> {
659658 Ok ( ( ) )
660659 }
661660
662- #[ allow( dead_code) ]
663- pub fn spawn_pnp_handle_rusb ( & self ) -> Result < ( ) > {
664- // Comment for future me: Use CM_Register_Notification instead of rusb
665-
666- let mut spawned = self . pnp_thread_running . lock ( ) . unwrap ( ) ;
667- if * spawned {
668- bail ! ( "Handler Thread already running.." ) ;
669- }
670-
671- debug ! ( "Spawning RUSB PnP Thread" ) ;
672-
673- // We should not return from this method until at least one run has been done by the
674- // thread, this is primarily to prevent conflicts on startup when everything changes.
675-
676- let ( ready_tx, mut ready_rx) = tokio:: sync:: oneshot:: channel :: < bool > ( ) ;
677-
678- thread:: spawn ( move || -> Result < ( ) > {
679- let mut devices = vec ! [ ] ;
680- let mut ready_sender = Some ( ready_tx) ;
681-
682- debug ! ( "PnP Thread Spawned" ) ;
683- loop {
684- let mut found_devices = vec ! [ ] ;
685-
686- if let Ok ( devices) = rusb:: devices ( ) {
687- for device in devices. iter ( ) {
688- if let Ok ( descriptor) = device. device_descriptor ( ) {
689- let bus_number = device. bus_number ( ) ;
690- let address = device. address ( ) ;
691-
692- if descriptor. vendor_id ( ) == VID_GOXLR
693- && ( descriptor. product_id ( ) == PID_GOXLR_FULL
694- || descriptor. product_id ( ) == PID_GOXLR_MINI )
695- {
696- found_devices. push ( USBDevice {
697- bus_number,
698- address,
699- } ) ;
700- }
701- }
702- }
703- } else {
704- debug ! ( "Unable to Poll Devices" ) ;
705- }
706-
707- // Make sure our two vecs are the same..
708- if !iters_equal_anyorder (
709- devices. clone ( ) . into_iter ( ) ,
710- found_devices. clone ( ) . into_iter ( ) ,
711- ) {
712- debug ! ( "Device Change Detected" ) ;
713- let _ = TUSB_INTERFACE . detect_devices ( ) ;
714- devices. clear ( ) ;
715- devices. append ( & mut found_devices) ;
716- }
717-
718- // If a driver takes a couple of hundred milliseconds to load, it's theoretically
719- // possible that we'll have detected the device and run detect_devices() too early
720- // leaving the detected device list empty and causing a desync in the lists.
721- //
722- // The following simply checks what's already been found, and if the list size
723- // isn't the same as we have detected here, attempts to force a resync of the
724- // devices from the API.
725- if devices. len ( ) != TUSB_INTERFACE . get_devices ( ) . len ( ) {
726- debug ! ( "Device Desync Detected, attempting to resync.." ) ;
727- let _ = TUSB_INTERFACE . detect_devices ( ) ;
728- }
729-
730- if let Some ( sender) = ready_sender. take ( ) {
731- let _ = sender. send ( true ) ;
732- }
733- sleep ( Duration :: from_secs ( 1 ) ) ;
734- }
735- } ) ;
736-
737- // Block until the 'ready' message has been sent..
738- while ready_rx. try_recv ( ) . is_err ( ) {
739- sleep ( Duration :: from_millis ( 5 ) ) ;
740- }
741- debug ! ( "RUSB PnP Handler Started" ) ;
742-
743- * spawned = true ;
744- Ok ( ( ) )
745- }
661+ // #[allow(dead_code)]
662+ // pub fn spawn_pnp_handle_rusb(&self) -> Result<()> {
663+ // // Comment for future me: Use CM_Register_Notification instead of rusb
664+ //
665+ // let mut spawned = self.pnp_thread_running.lock().unwrap();
666+ // if *spawned {
667+ // bail!("Handler Thread already running..");
668+ // }
669+ //
670+ // debug!("Spawning RUSB PnP Thread");
671+ //
672+ // // We should not return from this method until at least one run has been done by the
673+ // // thread, this is primarily to prevent conflicts on startup when everything changes.
674+ //
675+ // let (ready_tx, mut ready_rx) = tokio::sync::oneshot::channel::<bool>();
676+ //
677+ // thread::spawn(move || -> Result<()> {
678+ // let mut devices = vec![];
679+ // let mut ready_sender = Some(ready_tx);
680+ //
681+ // debug!("PnP Thread Spawned");
682+ // loop {
683+ // let mut found_devices = vec![];
684+ //
685+ // if let Ok(devices) = rusb::devices() {
686+ // for device in devices.iter() {
687+ // if let Ok(descriptor) = device.device_descriptor() {
688+ // let bus_number = device.bus_number();
689+ // let address = device.address();
690+ //
691+ // if descriptor.vendor_id() == VID_GOXLR
692+ // && (descriptor.product_id() == PID_GOXLR_FULL
693+ // || descriptor.product_id() == PID_GOXLR_MINI)
694+ // {
695+ // found_devices.push(USBDevice {
696+ // bus_number,
697+ // address,
698+ // });
699+ // }
700+ // }
701+ // }
702+ // } else {
703+ // debug!("Unable to Poll Devices");
704+ // }
705+ //
706+ // // Make sure our two vecs are the same..
707+ // if !iters_equal_anyorder(
708+ // devices.clone().into_iter(),
709+ // found_devices.clone().into_iter(),
710+ // ) {
711+ // debug!("Device Change Detected");
712+ // let _ = TUSB_INTERFACE.detect_devices();
713+ // devices.clear();
714+ // devices.append(&mut found_devices);
715+ // }
716+ //
717+ // // If a driver takes a couple of hundred milliseconds to load, it's theoretically
718+ // // possible that we'll have detected the device and run detect_devices() too early
719+ // // leaving the detected device list empty and causing a desync in the lists.
720+ // //
721+ // // The following simply checks what's already been found, and if the list size
722+ // // isn't the same as we have detected here, attempts to force a resync of the
723+ // // devices from the API.
724+ // if devices.len() != TUSB_INTERFACE.get_devices().len() {
725+ // debug!("Device Desync Detected, attempting to resync..");
726+ // let _ = TUSB_INTERFACE.detect_devices();
727+ // }
728+ //
729+ // if let Some(sender) = ready_sender.take() {
730+ // let _ = sender.send(true);
731+ // }
732+ // sleep(Duration::from_secs(1));
733+ // }
734+ // });
735+ //
736+ // // Block until the 'ready' message has been sent..
737+ // while ready_rx.try_recv().is_err() {
738+ // sleep(Duration::from_millis(5));
739+ // }
740+ // debug!("RUSB PnP Handler Started");
741+ //
742+ // *spawned = true;
743+ // Ok(())
744+ // }
746745}
747746
748- #[ derive( Debug , Copy , Clone , Hash , Eq , PartialEq ) ]
749- struct USBDevice {
750- pub ( crate ) bus_number : u8 ,
751- pub ( crate ) address : u8 ,
752- }
747+ // #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
748+ // struct USBDevice {
749+ // pub(crate) bus_number: u8,
750+ // pub(crate) address: u8,
751+ // }
753752
754753pub struct DeviceHandle {
755754 handle : u32 ,
0 commit comments