@@ -33,7 +33,7 @@ pub use self::platform_impl::*;
3333/// SupportedOutputConfigs and all their necessary trait implementations.
3434///
3535macro_rules! impl_platform_host {
36- ( $( $( #[ cfg( $feat: meta) ] ) ? $HostVariant: ident $host_mod : ident $host_name : literal ) ,* ) => {
36+ ( $( $( #[ cfg( $feat: meta) ] ) ? $HostVariant: ident => $Host : ty ) ,* $ ( , ) ? ) => {
3737 /// All hosts supported by CPAL on this platform.
3838 pub const ALL_HOSTS : & ' static [ HostId ] = & [
3939 $(
@@ -91,47 +91,47 @@ macro_rules! impl_platform_host {
9191 pub enum DeviceInner {
9292 $(
9393 $( #[ cfg( $feat) ] ) ?
94- $HostVariant( crate :: host :: $host_mod :: Device ) ,
94+ $HostVariant( <$Host as crate :: traits :: HostTrait > :: Device ) ,
9595 ) *
9696 }
9797
9898 /// Contains a platform specific [`Devices`] implementation.
9999 pub enum DevicesInner {
100100 $(
101101 $( #[ cfg( $feat) ] ) ?
102- $HostVariant( crate :: host :: $host_mod :: Devices ) ,
102+ $HostVariant( <$Host as crate :: traits :: HostTrait > :: Devices ) ,
103103 ) *
104104 }
105105
106106 /// Contains a platform specific [`Host`] implementation.
107107 pub enum HostInner {
108108 $(
109109 $( #[ cfg( $feat) ] ) ?
110- $HostVariant( crate :: host :: $host_mod :: Host ) ,
110+ $HostVariant( $ Host) ,
111111 ) *
112112 }
113113
114114 /// Contains a platform specific [`Stream`] implementation.
115115 pub enum StreamInner {
116116 $(
117117 $( #[ cfg( $feat) ] ) ?
118- $HostVariant( crate :: host :: $host_mod :: Stream ) ,
118+ $HostVariant( <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: Stream ) ,
119119 ) *
120120 }
121121
122122 #[ derive( Clone ) ]
123123 enum SupportedInputConfigsInner {
124124 $(
125125 $( #[ cfg( $feat) ] ) ?
126- $HostVariant( crate :: host :: $host_mod :: SupportedInputConfigs ) ,
126+ $HostVariant( <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: SupportedInputConfigs ) ,
127127 ) *
128128 }
129129
130130 #[ derive( Clone ) ]
131131 enum SupportedOutputConfigsInner {
132132 $(
133133 $( #[ cfg( $feat) ] ) ?
134- $HostVariant( crate :: host :: $host_mod :: SupportedOutputConfigs ) ,
134+ $HostVariant( <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: SupportedOutputConfigs ) ,
135135 ) *
136136 }
137137
@@ -140,7 +140,7 @@ macro_rules! impl_platform_host {
140140 match self {
141141 $(
142142 $( #[ cfg( $feat) ] ) ?
143- HostId :: $HostVariant => $host_name ,
143+ HostId :: $HostVariant => stringify! ( $HostVariant ) ,
144144 ) *
145145 }
146146 }
@@ -442,7 +442,7 @@ macro_rules! impl_platform_host {
442442 fn is_available( ) -> bool {
443443 $(
444444 $( #[ cfg( $feat) ] ) ?
445- if crate :: host :: $host_mod :: Host :: is_available( ) { return true ; }
445+ if <$ Host> :: is_available( ) { return true ; }
446446 ) *
447447 false
448448 }
@@ -531,29 +531,29 @@ macro_rules! impl_platform_host {
531531
532532 $(
533533 $( #[ cfg( $feat) ] ) ?
534- impl From <crate :: host :: $host_mod :: Device > for Device {
535- fn from( h: crate :: host :: $host_mod :: Device ) -> Self {
534+ impl From <<$Host as crate :: traits :: HostTrait > :: Device > for Device {
535+ fn from( h: <$Host as crate :: traits :: HostTrait > :: Device ) -> Self {
536536 DeviceInner :: $HostVariant( h) . into( )
537537 }
538538 }
539539
540540 $( #[ cfg( $feat) ] ) ?
541- impl From <crate :: host :: $host_mod :: Devices > for Devices {
542- fn from( h: crate :: host :: $host_mod :: Devices ) -> Self {
541+ impl From <<$Host as crate :: traits :: HostTrait > :: Devices > for Devices {
542+ fn from( h: <$Host as crate :: traits :: HostTrait > :: Devices ) -> Self {
543543 DevicesInner :: $HostVariant( h) . into( )
544544 }
545545 }
546546
547547 $( #[ cfg( $feat) ] ) ?
548- impl From <crate :: host :: $host_mod :: Host > for Host {
549- fn from( h: crate :: host :: $host_mod :: Host ) -> Self {
548+ impl From <$ Host> for Host {
549+ fn from( h: $ Host) -> Self {
550550 HostInner :: $HostVariant( h) . into( )
551551 }
552552 }
553553
554554 $( #[ cfg( $feat) ] ) ?
555- impl From <crate :: host :: $host_mod :: Stream > for Stream {
556- fn from( h: crate :: host :: $host_mod :: Stream ) -> Self {
555+ impl From <<<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: Stream > for Stream {
556+ fn from( h: <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: Stream ) -> Self {
557557 StreamInner :: $HostVariant( h) . into( )
558558 }
559559 }
@@ -564,7 +564,7 @@ macro_rules! impl_platform_host {
564564 let mut host_ids = vec![ ] ;
565565 $(
566566 $( #[ cfg( $feat) ] ) ?
567- if <crate :: host :: $host_mod :: Host as crate :: traits:: HostTrait >:: is_available( ) {
567+ if <$ Host as crate :: traits:: HostTrait >:: is_available( ) {
568568 host_ids. push( HostId :: $HostVariant) ;
569569 }
570570 ) *
@@ -577,7 +577,7 @@ macro_rules! impl_platform_host {
577577 $(
578578 $( #[ cfg( $feat) ] ) ?
579579 HostId :: $HostVariant => {
580- crate :: host :: $host_mod :: Host :: new( )
580+ <$ Host> :: new( )
581581 . map( HostInner :: $HostVariant)
582582 . map( Host :: from)
583583 }
@@ -601,19 +601,14 @@ macro_rules! impl_platform_host {
601601 target_os = "netbsd"
602602) ) ]
603603mod platform_impl {
604- pub use crate :: host:: alsa:: {
605- Device as AlsaDevice , Devices as AlsaDevices , Host as AlsaHost , Stream as AlsaStream ,
606- SupportedInputConfigs as AlsaSupportedInputConfigs ,
607- SupportedOutputConfigs as AlsaSupportedOutputConfigs ,
608- } ;
604+ pub use crate :: host:: alsa:: Host as AlsaHost ;
609605 #[ cfg( feature = "jack" ) ]
610- pub use crate :: host:: jack:: {
611- Device as JackDevice , Devices as JackDevices , Host as JackHost , Stream as JackStream ,
612- SupportedInputConfigs as JackSupportedInputConfigs ,
613- SupportedOutputConfigs as JackSupportedOutputConfigs ,
614- } ;
606+ pub use crate :: host:: jack:: Host as JackHost ;
615607
616- impl_platform_host ! ( #[ cfg( feature = "jack" ) ] Jack jack "JACK" , Alsa alsa "ALSA" ) ;
608+ impl_platform_host ! (
609+ #[ cfg( feature = "jack" ) ] Jack => JackHost ,
610+ Alsa => AlsaHost ,
611+ ) ;
617612
618613 /// The default host for the current compilation target platform.
619614 pub fn default_host ( ) -> Host {
@@ -625,13 +620,8 @@ mod platform_impl {
625620
626621#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
627622mod platform_impl {
628- pub use crate :: host:: coreaudio:: {
629- Device as CoreAudioDevice , Devices as CoreAudioDevices , Host as CoreAudioHost ,
630- Stream as CoreAudioStream , SupportedInputConfigs as CoreAudioSupportedInputConfigs ,
631- SupportedOutputConfigs as CoreAudioSupportedOutputConfigs ,
632- } ;
633-
634- impl_platform_host ! ( CoreAudio coreaudio "CoreAudio" ) ;
623+ pub use crate :: host:: coreaudio:: Host as CoreAudioHost ;
624+ impl_platform_host ! ( CoreAudio => CoreAudioHost ) ;
635625
636626 /// The default host for the current compilation target platform.
637627 pub fn default_host ( ) -> Host {
@@ -643,13 +633,8 @@ mod platform_impl {
643633
644634#[ cfg( target_os = "emscripten" ) ]
645635mod platform_impl {
646- pub use crate :: host:: emscripten:: {
647- Device as EmscriptenDevice , Devices as EmscriptenDevices , Host as EmscriptenHost ,
648- Stream as EmscriptenStream , SupportedInputConfigs as EmscriptenSupportedInputConfigs ,
649- SupportedOutputConfigs as EmscriptenSupportedOutputConfigs ,
650- } ;
651-
652- impl_platform_host ! ( Emscripten emscripten "Emscripten" ) ;
636+ pub use crate :: host:: emscripten:: Host as EmscriptenHost ;
637+ impl_platform_host ! ( Emscripten => EmscriptenHost ) ;
653638
654639 /// The default host for the current compilation target platform.
655640 pub fn default_host ( ) -> Host {
@@ -661,13 +646,8 @@ mod platform_impl {
661646
662647#[ cfg( all( target_arch = "wasm32" , feature = "wasm-bindgen" ) ) ]
663648mod platform_impl {
664- pub use crate :: host:: webaudio:: {
665- Device as WebAudioDevice , Devices as WebAudioDevices , Host as WebAudioHost ,
666- Stream as WebAudioStream , SupportedInputConfigs as WebAudioSupportedInputConfigs ,
667- SupportedOutputConfigs as WebAudioSupportedOutputConfigs ,
668- } ;
669-
670- impl_platform_host ! ( WebAudio webaudio "WebAudio" ) ;
649+ pub use crate :: host:: webaudio:: Host as WebAudioHost ;
650+ impl_platform_host ! ( WebAudio => WebAudioHost ) ;
671651
672652 /// The default host for the current compilation target platform.
673653 pub fn default_host ( ) -> Host {
@@ -680,18 +660,13 @@ mod platform_impl {
680660#[ cfg( windows) ]
681661mod platform_impl {
682662 #[ cfg( feature = "asio" ) ]
683- pub use crate :: host:: asio:: {
684- Device as AsioDevice , Devices as AsioDevices , Host as AsioHost , Stream as AsioStream ,
685- SupportedInputConfigs as AsioSupportedInputConfigs ,
686- SupportedOutputConfigs as AsioSupportedOutputConfigs ,
687- } ;
688- pub use crate :: host:: wasapi:: {
689- Device as WasapiDevice , Devices as WasapiDevices , Host as WasapiHost ,
690- Stream as WasapiStream , SupportedInputConfigs as WasapiSupportedInputConfigs ,
691- SupportedOutputConfigs as WasapiSupportedOutputConfigs ,
692- } ;
663+ pub use crate :: host:: asio:: Host as AsioHost ;
664+ pub use crate :: host:: wasapi:: Host as WasapiHost ;
693665
694- impl_platform_host ! ( #[ cfg( feature = "asio" ) ] Asio asio "ASIO" , Wasapi wasapi "WASAPI" ) ;
666+ impl_platform_host ! (
667+ #[ cfg( feature = "asio" ) ] Asio => AsioHost ,
668+ Wasapi => WasapiHost ,
669+ ) ;
695670
696671 /// The default host for the current compilation target platform.
697672 pub fn default_host ( ) -> Host {
@@ -703,13 +678,8 @@ mod platform_impl {
703678
704679#[ cfg( target_os = "android" ) ]
705680mod platform_impl {
706- pub use crate :: host:: aaudio:: {
707- Device as AAudioDevice , Devices as AAudioDevices , Host as AAudioHost ,
708- Stream as AAudioStream , SupportedInputConfigs as AAudioSupportedInputConfigs ,
709- SupportedOutputConfigs as AAudioSupportedOutputConfigs ,
710- } ;
711-
712- impl_platform_host ! ( AAudio aaudio "AAudio" ) ;
681+ pub use crate :: host:: aaudio:: Host as AAudioHost ;
682+ impl_platform_host ! ( AAudio => AAudioHost ) ;
713683
714684 /// The default host for the current compilation target platform.
715685 pub fn default_host ( ) -> Host {
@@ -732,13 +702,9 @@ mod platform_impl {
732702 all( target_arch = "wasm32" , feature = "wasm-bindgen" ) ,
733703) ) ) ]
734704mod platform_impl {
735- pub use crate :: host:: null:: {
736- Device as NullDevice , Devices as NullDevices , Host as NullHost ,
737- SupportedInputConfigs as NullSupportedInputConfigs ,
738- SupportedOutputConfigs as NullSupportedOutputConfigs ,
739- } ;
705+ pub use crate :: host:: null:: Host as NullHost ;
740706
741- impl_platform_host ! ( Null null "Null" ) ;
707+ impl_platform_host ! ( Null => NullHost ) ;
742708
743709 /// The default host for the current compilation target platform.
744710 pub fn default_host ( ) -> Host {
0 commit comments